2005-08-08 Jordi Mas i Hernandez <jordi@ximian.com>
authorJordi Mas i Hernandez <jordi@mono-cvs.ximian.com>
Mon, 8 Aug 2005 14:07:47 +0000 (14:07 -0000)
committerJordi Mas i Hernandez <jordi@mono-cvs.ximian.com>
Mon, 8 Aug 2005 14:07:47 +0000 (14:07 -0000)
* ComboBoxTest.cs: new tests for properties, exceptions, and colletions
* ListBoxTest.cs: new tests for properties, exceptions, and colletionss

svn path=/trunk/mcs/; revision=48125

mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTest.cs
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ListBoxTest.cs

index 2f3cdf81f85a40c1020436ac9271b6f3612687ce..299fcf5caac418c99dcb94aaabefa12517695481 100644 (file)
@@ -1,3 +1,8 @@
+2005-08-08  Jordi Mas i Hernandez <jordi@ximian.com>
+
+       * ComboBoxTest.cs: new tests for properties, exceptions, and colletions
+       * ListBoxTest.cs: new tests for properties, exceptions, and colletionss
+
 2005-08-06  Ritvik Mayank  <mritvik@novell.com>
 
        * ComboBoxTest.cs, ListBoxTest.cs : Cleanup, added few more tests   
index fed1b32ed8e98dc543154cc66b7e84f06fa0418a..67765f281d6550be5bd3c01fec9d74f1803cad48 100644 (file)
@@ -1,17 +1,39 @@
 //
 // ComboBoxTest.cs: Test cases for ComboBox.
 //
-// Author:
-//   Ritvik Mayank (mritvik@novell.com)
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
 //
-// (C) 2005 Novell, Inc. (http://www.novell.com)
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
 //
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+//     Ritvik Mayank <mritvik@novell.com>
+//     Jordi Mas i Hernandez <jordi@ximian.com>
+
 
 using System;
 using System.Windows.Forms;
 using System.Drawing;
 using System.Reflection;
 using NUnit.Framework;
+using System.Collections;
+using System.ComponentModel;
 
 namespace MonoTests.System.Windows.Forms
 {
@@ -21,7 +43,6 @@ namespace MonoTests.System.Windows.Forms
                [Test]
                public void ComboBoxPropertyTest ()
                {
-                       Form myfrm = new Form ();
                        ComboBox mycmbbox = new ComboBox ();
                        Assert.AreEqual (DrawMode.Normal, mycmbbox.DrawMode, "#1");
                        Assert.AreEqual (ComboBoxStyle.DropDown, mycmbbox.DropDownStyle, "#2");
@@ -29,7 +50,7 @@ namespace MonoTests.System.Windows.Forms
                        Assert.AreEqual (false, mycmbbox.DroppedDown, "#4");
                        Assert.AreEqual (true, mycmbbox.IntegralHeight, "#5");
                        Assert.AreEqual (0, mycmbbox.Items.Count, "#6");
-                       Assert.AreEqual (15, mycmbbox.ItemHeight, "#7");
+                       //Assert.AreEqual (15, mycmbbox.ItemHeight, "#7");      // Note: Item height depends on the current font.
                        Assert.AreEqual (8, mycmbbox.MaxDropDownItems, "#8");
                        Assert.AreEqual (0, mycmbbox.MaxLength, "#9");
                        Assert.AreEqual (20, mycmbbox.PreferredHeight, "#10");
@@ -53,29 +74,43 @@ namespace MonoTests.System.Windows.Forms
                        myform.Controls.Add (cmbbox);
                        cmbbox.BeginUpdate ();
                        for (int x = 1 ; x < 5000 ; x++) {
-                               cmbbox.Items.Add ("Item " + x.ToString ());   
+                               cmbbox.Items.Add ("Item " + x.ToString ());
                        }
                        cmbbox.EndUpdate ();
-               }               
+               }
 
                [Test]
                public void FindStringTest ()
                {
                        ComboBox cmbbox = new ComboBox ();
+                       cmbbox.FindString ("Hola", -5); // No exception, it's empty
+                       int x = cmbbox.FindString ("Hello");
+                       Assert.AreEqual (-1, x, "#19");
                        cmbbox.Items.AddRange(new object[] {"ACBD", "ABDC", "ACBD", "ABCD"});
                        String myString = "ABC";
-                       int x = cmbbox.FindString (myString);
-                       Assert.AreEqual (3, x, "#19");
+                       x = cmbbox.FindString (myString);
+                       Assert.AreEqual (3, x, "#191");
+                       x = cmbbox.FindString (string.Empty);
+                       Assert.AreEqual (0, x, "#192");
+                       x = cmbbox.FindString ("NonExistant");
+                       Assert.AreEqual (-1, x, "#193");
                }
 
                [Test]
                public void FindStringExactTest ()
                {
                        ComboBox cmbbox = new ComboBox ();
+                       cmbbox.FindStringExact ("Hola", -5); // No exception, it's empty
+                       int x = cmbbox.FindStringExact ("Hello");
+                       Assert.AreEqual (-1, x, "#20");
                        cmbbox.Items.AddRange (new object[] {"ABCD","ABC","ABDC"});
                        String myString = "ABC";
-                       int x = cmbbox.FindStringExact (myString);
-                       Assert.AreEqual (1, x, "#20");
+                       x = cmbbox.FindStringExact (myString);
+                       Assert.AreEqual (1, x, "#201");
+                       x = cmbbox.FindStringExact (string.Empty);
+                       Assert.AreEqual (-1, x, "#202");
+                       x = cmbbox.FindStringExact ("NonExistant");
+                       Assert.AreEqual (-1, x, "#203");
                }
 
                [Test]
@@ -87,19 +122,205 @@ namespace MonoTests.System.Windows.Forms
                        cmbbox.Items.Add ("DEF");
                        int x = -1;
                        x = cmbbox.GetItemHeight (x);
-                       Assert.IsTrue (cmbbox.ItemHeight > 0, "#21");  
+                       Assert.IsTrue (cmbbox.ItemHeight > 0, "#21");
                }
 
+
+               //
+               // Exceptions
+               //
+
                [Test]
-               public void SelectAllTest ()
+               [ExpectedException (typeof (InvalidEnumArgumentException))]
+               public void DropDownStyleException ()
                {
                        ComboBox cmbbox = new ComboBox ();
-                       cmbbox.Items.Add ("ABC");
-                       cmbbox.Items.Add ("BCD");
-                       cmbbox.Items.Add ("DEF");
-                       int x = -1;
-                       x = cmbbox.GetItemHeight (x);
-                       Assert.AreEqual (15, cmbbox.ItemHeight, "#22");
+                       cmbbox.DropDownStyle = (ComboBoxStyle) 10;
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidEnumArgumentException))]
+               public void DrawModeException ()
+               {
+                       ComboBox cmbbox = new ComboBox ();
+                       cmbbox.DrawMode = (DrawMode) 10;
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void DropDownWidthException ()
+               {
+                       ComboBox cmbbox = new ComboBox ();
+                       cmbbox.DropDownWidth = 0;
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void ItemHeightException ()
+               {
+                       ComboBox cmbbox = new ComboBox ();
+                       cmbbox.ItemHeight = -1;
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void SelectedIndexException ()
+               {
+                       ComboBox cmbbox = new ComboBox ();
+                       cmbbox.SelectedIndex = -2;
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void FindStringExactMinException ()
+               {
+                       ComboBox cmbbox = new ComboBox ();
+                       cmbbox.Items.AddRange(new object[] {"ACBD", "ABDC", "ACBD", "ABCD"});
+                       cmbbox.FindStringExact ("Hola", -2);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void FindStringExactMaxException ()
+               {
+                       ComboBox cmbbox = new ComboBox ();
+                       cmbbox.Items.AddRange(new object[] {"ACBD", "ABDC", "ACBD", "ABCD"});
+                       cmbbox.FindStringExact ("Hola", 3);
+               }
+
+               //
+               // Events
+               //
+               private bool eventFired;
+               private DrawItemEventArgs drawItemsArgs;
+               private void DrawItemEventH (object sender,  DrawItemEventArgs e)
+               {
+                       eventFired = true;
+                       drawItemsArgs = e;
+               }
+
+               private void GenericHandler (object sender,  EventArgs e)
+               {
+                       eventFired = true;
+               }
+
+               [Ignore ("Bugs in X11 prevent this test to run properly")]
+               public void DrawItemEventTest ()
+               {
+                       eventFired = false;
+                       drawItemsArgs = null;
+                       Form myform = new Form ();
+                       ComboBox cmbbox = new ComboBox ();
+                       cmbbox.DropDownStyle = ComboBoxStyle.Simple;
+                       cmbbox.DrawMode = DrawMode.OwnerDrawFixed;
+                       cmbbox.DrawItem += new DrawItemEventHandler (DrawItemEventH);
+
+                       myform.Controls.Add (cmbbox);
+                       cmbbox.Items.AddRange(new object[] {"Item1"});
+
+                       myform.Visible = true;
+                       cmbbox.Visible = true;
+                       cmbbox.Refresh ();
+
+                       Assert.AreEqual (true, eventFired, "DW1");
+                       Assert.AreEqual (0, drawItemsArgs.Index, "DW2");
+               }
+
+               [Test]
+               public void DropDownStyleEventTest ()
+               {
+                       eventFired = false;
+                       ComboBox cmbbox = new ComboBox ();
+                       cmbbox.DropDownStyleChanged += new EventHandler (GenericHandler);
+                       cmbbox.DropDownStyle = ComboBoxStyle.Simple;
+
+                       Assert.AreEqual (true, eventFired, "DI1");
+               }
+
+               [Test]
+               public void SelectedIndextTest ()
+               {
+                       eventFired = false;
+                       ComboBox cmbbox = new ComboBox ();
+                       cmbbox.Items.AddRange(new object[] {"Item1", "Item2"});
+                       cmbbox.SelectedIndexChanged += new EventHandler (GenericHandler);
+                       cmbbox.SelectedIndex = 1;
+                       Assert.AreEqual (true, eventFired, "SI1");
+               }
+
+       }
+
+       [TestFixture]
+       public class ComboBoxObjectCollectionTest
+       {
+               [Test]
+               public void ComboBoxObjectCollectionPropertyTest ()
+               {
+                       ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+                       Assert.AreEqual (false, col.IsReadOnly, "#B1");
+                       Assert.AreEqual (false, ((ICollection)col).IsSynchronized, "#B2");
+                       Assert.AreEqual (col, ((ICollection)col).SyncRoot, "#B3");
+                       Assert.AreEqual (false, ((IList)col).IsFixedSize, "#B4");
+               }
+
+               [Test]
+               public void AddTest ()
+               {
+                       ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+                       col.Add ("Item1");
+                       col.Add ("Item2");
+                       Assert.AreEqual (2, col.Count, "#C1");
+               }
+
+               [Test]
+               public void ClearTest ()
+               {
+                       ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+                       col.Add ("Item1");
+                       col.Add ("Item2");
+                       col.Clear ();
+                       Assert.AreEqual (0, col.Count, "#D1");
+               }
+
+               [Test]
+               public void ContainsTest ()
+               {
+                       ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+                       object obj = "Item1";
+                       col.Add (obj);
+                       Assert.AreEqual (true, col.Contains ("Item1"), "#E1");
+                       Assert.AreEqual (false, col.Contains ("Item2"), "#E2");
+               }
+
+               [Test]
+               public void IndexOfTest ()
+               {
+                       ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+                       col.Add ("Item1");
+                       col.Add ("Item2");
+                       Assert.AreEqual (1, col.IndexOf ("Item2"), "#F1");
+               }
+
+               [Test]
+               public void RemoveTest ()
+               {
+                       ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+                       col.Add ("Item1");
+                       col.Add ("Item2");
+                       col.Remove ("Item1");
+                       Assert.AreEqual (1, col.Count, "#G1");
+               }
+
+               [Test]
+               public void RemoveAtTest ()
+               {
+                       ComboBox.ObjectCollection col = new ComboBox.ObjectCollection (new ComboBox ());
+                       col.Add ("Item1");
+                       col.Add ("Item2");
+                       col.RemoveAt (0);
+                       Assert.AreEqual (1, col.Count, "#H1");
+                       Assert.AreEqual (true, col.Contains ("Item2"), "#H1");
                }
        }
+
 }
index e1c01a377afe75986fc390c775c1a6517d2b6945..d946b7a38fbb35f6ba45fa62242231e76903ddf7 100644 (file)
@@ -1,15 +1,40 @@
 //
-// Copyright (c) 2005 Novell, Inc.
+// ComboBoxTest.cs: Test cases for ComboBox.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
 //
 // Authors:
-//             Ritvik Mayank (mritvik@novell.com)
+//     Ritvik Mayank <mritvik@novell.com>
+//     Jordi Mas i Hernandez <jordi@ximian.com>
 //
 
+
 using System;
 using System.Windows.Forms;
 using System.Drawing;
 using System.Reflection;
 using NUnit.Framework;
+using System.Collections;
+using System.ComponentModel;
 
 namespace MonoTests.System.Windows.Forms
 {
@@ -25,22 +50,22 @@ namespace MonoTests.System.Windows.Forms
                        Assert.AreEqual (0, lb1.HorizontalExtent, "#3");
                        Assert.AreEqual (false, lb1.HorizontalScrollbar, "#4");
                        Assert.AreEqual (true, lb1.IntegralHeight, "#5");
-                       Assert.AreEqual (13, lb1.ItemHeight, "#6");
+                       //Assert.AreEqual (13, lb1.ItemHeight, "#6"); // Note: Item height depends on the current font.
                        lb1.Items.Add ("a");
                        lb1.Items.Add ("b");
                        lb1.Items.Add ("c");
                        Assert.AreEqual (3,  lb1.Items.Count, "#7");
                        Assert.AreEqual (false, lb1.MultiColumn, "#8");
-                       Assert.AreEqual (46, lb1.PreferredHeight, "#9");
-                       Assert.AreEqual (RightToLeft.No , lb1.RightToLeft, "#10");
+                       //Assert.AreEqual (46, lb1.PreferredHeight, "#9"); // Note: Item height depends on the current font.
+                       //Assert.AreEqual (RightToLeft.No , lb1.RightToLeft, "#10"); // Depends on Windows version
                        Assert.AreEqual (false, lb1.ScrollAlwaysVisible, "#11");
                        Assert.AreEqual (-1, lb1.SelectedIndex, "#12");
-                       lb1.SetSelected (2,true);       
+                       lb1.SetSelected (2,true);
                        Assert.AreEqual (2, lb1.SelectedIndices[0], "#13");
                        Assert.AreEqual ("c", lb1.SelectedItem, "#14");
                        Assert.AreEqual ("c", lb1.SelectedItems[0], "#15");
                        Assert.AreEqual (SelectionMode.One, lb1.SelectionMode, "#16");
-                       lb1.SetSelected (2,false);      
+                       lb1.SetSelected (2,false);
                        Assert.AreEqual (false, lb1.Sorted, "#17");
                        Assert.AreEqual ("", lb1.Text, "#18");
                        Assert.AreEqual (0, lb1.TopIndex, "#19");
@@ -59,13 +84,13 @@ namespace MonoTests.System.Windows.Forms
                        lb1.BeginUpdate ();
                        for (int x = 1; x < 5000; x++)
                        {
-                               lb1.Items.Add ("Item " + x.ToString ());   
+                               lb1.Items.Add ("Item " + x.ToString ());
                        }
                        lb1.EndUpdate ();
                        lb1.SetSelected (1, true);
                        lb1.SetSelected (3, true);
-                       Assert.AreEqual ("Item 3", lb1.SelectedItems [0].ToString (),"#21");
-               }               
+                       Assert.AreEqual (true, lb1.SelectedItems.Contains ("Item 3"), "#21");
+               }
 
                [Test]
                public void ClearSelectedTest ()
@@ -82,36 +107,7 @@ namespace MonoTests.System.Windows.Forms
                        Assert.AreEqual (0, lb1.SelectedItems.Count,"#23");
                }
 
-               [Test]
-               public void FindStringTest ()
-               {
-                       ListBox lb1 = new ListBox ();
-                       lb1.Items.Add ("ABCD");
-                       lb1.Items.Add ("DABCD");
-                       lb1.Items.Add ("ABDC");
-                       lb1.SelectionMode = SelectionMode.MultiExtended;
-                       int x = -1;
-                       x = lb1.FindString ("ABC", x );
-                       lb1.SetSelected (x,true);
-                       Assert.AreEqual ("ABCD", lb1.SelectedItems [0],"#24");
-                       Assert.AreEqual (1, lb1.SelectedItems.Count,"#25");
-               }
-
-               [Test]
-               public void FindExactTest ()
-               {
-                       ListBox lb2 = new ListBox ();
-                       lb2.Items.Add ("ABC");
-                       lb2.Items.Add ("DEFGHI");
-                       lb2.Items.Add ("DEF");
-                       int x = -1;
-                       x = lb2.FindStringExact ("DEF", x);
-                       lb2.SetSelected (x,true);
-                       Assert.AreEqual (1, lb2.SelectedItems.Count,"#26");
-                       Assert.AreEqual ("DEF", lb2.SelectedItems [0],"#27");
-               }
-
-               [Test]
+               [Ignore ("It depends on user system settings")]
                public void GetItemHeightTest ()
                {
                        Form f = new Form ();
@@ -122,7 +118,7 @@ namespace MonoTests.System.Windows.Forms
                        Assert.AreEqual (13, lb1.GetItemHeight (0) , "#28");
                }
 
-               [Test]
+               [Ignore ("It depends on user system settings")]
                public void GetItemRectangleTest ()
                {
                        Form f = new Form ();
@@ -157,8 +153,199 @@ namespace MonoTests.System.Windows.Forms
                        ListBox lb1 = new ListBox ();
                        lb1.Items.Add ("A");
                        Point pt = new Point (100,100);
-                       int index = lb1.IndexFromPoint (pt);
+                               lb1.IndexFromPoint (pt);
                        Assert.AreEqual (-1, lb1.IndexFromPoint (100,100), "#32");
                }
+
+               [Test]
+               public void FindStringTest ()
+               {
+                       ListBox cmbbox = new ListBox ();
+                       cmbbox.FindString ("Hola", -5); // No exception, it's empty
+                       int x = cmbbox.FindString ("Hello");
+                       Assert.AreEqual (-1, x, "#19");
+                       cmbbox.Items.AddRange(new object[] {"ACBD", "ABDC", "ACBD", "ABCD"});
+                       String myString = "ABC";
+                       x = cmbbox.FindString (myString);
+                       Assert.AreEqual (3, x, "#191");
+                       x = cmbbox.FindString (string.Empty);
+                       Assert.AreEqual (0, x, "#192");
+                       x = cmbbox.FindString ("NonExistant");
+                       Assert.AreEqual (-1, x, "#193");
+               }
+
+               [Test]
+               public void FindStringExactTest ()
+               {
+                       ListBox cmbbox = new ListBox ();
+                       cmbbox.FindStringExact ("Hola", -5); // No exception, it's empty
+                       int x = cmbbox.FindStringExact ("Hello");
+                       Assert.AreEqual (-1, x, "#20");
+                       cmbbox.Items.AddRange (new object[] {"ABCD","ABC","ABDC"});
+                       String myString = "ABC";
+                       x = cmbbox.FindStringExact (myString);
+                       Assert.AreEqual (1, x, "#201");
+                       x = cmbbox.FindStringExact (string.Empty);
+                       Assert.AreEqual (-1, x, "#202");
+                       x = cmbbox.FindStringExact ("NonExistant");
+                       Assert.AreEqual (-1, x, "#203");
+               }
+
+               //
+               // Exceptions
+               //
+
+               [Test]
+               [ExpectedException (typeof (InvalidEnumArgumentException))]
+               public void BorderStyleException ()
+               {
+                       ListBox lstbox = new ListBox ();
+                       lstbox.BorderStyle = (BorderStyle) 10;
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void ColumnWidthException ()
+               {
+                       ListBox lstbox = new ListBox ();
+                       lstbox.ColumnWidth = -1;
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidEnumArgumentException))]
+               public void DrawModeException ()
+               {
+                       ListBox lstbox = new ListBox ();
+                       lstbox.DrawMode = (DrawMode) 10;
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void DrawModeAndMultiColumnException ()
+               {
+                       ListBox lstbox = new ListBox ();
+                       lstbox.MultiColumn = true;
+                       lstbox.DrawMode = DrawMode.OwnerDrawVariable;
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void ItemHeightException ()
+               {
+                       ListBox lstbox = new ListBox ();
+                       lstbox.ItemHeight = 256;
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void SelectedIndexException ()
+               {
+                       ListBox lstbox = new ListBox ();
+                       lstbox.SelectedIndex = -2;
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void SelectedIndexModeNoneException ()
+               {
+                       ListBox lstbox = new ListBox ();
+                       lstbox.SelectionMode = SelectionMode.None;
+                       lstbox.SelectedIndex = -1;
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidEnumArgumentException))]
+               public void SelectionModeException ()
+               {
+                       ListBox lstbox = new ListBox ();
+                       lstbox.SelectionMode = (SelectionMode) 10;
+               }
+
+               //
+               // Events
+               //
+               private bool eventFired;
+
+               private void GenericHandler (object sender,  EventArgs e)
+               {
+                       eventFired = true;
+               }
+
+
+       }
+
+       [TestFixture]
+       public class ListBoxObjectCollectionTest
+       {
+               [Test]
+               public void ComboBoxObjectCollectionPropertyTest ()
+               {
+                       ListBox.ObjectCollection col = new ListBox.ObjectCollection (new ListBox ());
+                       Assert.AreEqual (false, col.IsReadOnly, "#B1");
+                       Assert.AreEqual (false, ((ICollection)col).IsSynchronized, "#B2");
+                       Assert.AreEqual (col, ((ICollection)col).SyncRoot, "#B3");
+                       Assert.AreEqual (false, ((IList)col).IsFixedSize, "#B4");
+               }
+
+               [Test]
+               public void AddTest ()
+               {
+                       ListBox.ObjectCollection col = new ListBox.ObjectCollection (new ListBox ());
+                       col.Add ("Item1");
+                       col.Add ("Item2");
+                       Assert.AreEqual (2, col.Count, "#C1");
+               }
+
+               [Test]
+               public void ClearTest ()
+               {
+                       ListBox.ObjectCollection col = new ListBox.ObjectCollection (new ListBox ());
+                       col.Add ("Item1");
+                       col.Add ("Item2");
+                       col.Clear ();
+                       Assert.AreEqual (0, col.Count, "#D1");
+               }
+
+               [Test]
+               public void ContainsTest ()
+               {
+                       ListBox.ObjectCollection col = new ListBox.ObjectCollection (new ListBox ());
+                       object obj = "Item1";
+                       col.Add (obj);
+                       Assert.AreEqual (true, col.Contains ("Item1"), "#E1");
+                       Assert.AreEqual (false, col.Contains ("Item2"), "#E2");
+               }
+
+               [Test]
+               public void IndexOfTest ()
+               {
+                       ListBox.ObjectCollection col = new ListBox.ObjectCollection (new ListBox ());
+                       col.Add ("Item1");
+                       col.Add ("Item2");
+                       Assert.AreEqual (1, col.IndexOf ("Item2"), "#F1");
+               }
+
+               [Test]
+               public void RemoveTest ()
+               {
+                       ListBox.ObjectCollection col = new ListBox.ObjectCollection (new ListBox ());
+                       col.Add ("Item1");
+                       col.Add ("Item2");
+                       col.Remove ("Item1");
+                       Assert.AreEqual (1, col.Count, "#G1");
+               }
+
+               [Test]
+               public void RemoveAtTest ()
+               {
+                       ListBox.ObjectCollection col = new ListBox.ObjectCollection (new ListBox ());
+                       col.Add ("Item1");
+                       col.Add ("Item2");
+                       col.RemoveAt (0);
+                       Assert.AreEqual (1, col.Count, "#H1");
+                       Assert.AreEqual (true, col.Contains ("Item2"), "#H1");
+               }
+
+
        }
 }