2 // ListViewGroupCollectionTest.cs
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 // Copyright (c) 2006 Daniel Nauck
26 // Daniel Nauck (dna(at)mono-project(dot)de)
31 using System.Windows.Forms;
33 using System.Reflection;
34 using System.Collections;
35 using NUnit.Framework;
37 namespace MonoTests.System.Windows.Forms
40 public class ListViewGroupCollectionTest
42 ListViewGroupCollection grpCol = null;
47 ListView lv = new ListView ();
52 public void DefaultProperties ()
54 Assert.AreEqual (false, ((IList)grpCol).IsReadOnly, "#A1");
55 Assert.AreEqual (false, ((IList)grpCol).IsFixedSize, "#A2");
56 Assert.AreEqual (true, ((ICollection)grpCol).IsSynchronized, "#A3");
57 Assert.AreEqual (grpCol, ((ICollection)grpCol).SyncRoot, "#A4");
58 Assert.AreEqual (0, grpCol.Count, "#A5");
62 public void AddTest ()
64 grpCol.Add (new ListViewGroup ("Item1"));
65 grpCol.Add (new ListViewGroup ("Item2"));
66 Assert.AreEqual (2, grpCol.Count, "#B1");
70 public void ClearTest ()
72 grpCol.Add (new ListViewGroup ("Item1"));
73 grpCol.Add (new ListViewGroup ("Item2"));
75 Assert.AreEqual (0, grpCol.Count, "#C1");
79 public void ContainsTest ()
81 ListViewGroup obj = new ListViewGroup ("Item1");
82 ListViewGroup obj2 = new ListViewGroup ("Item2");
84 Assert.AreEqual (true, grpCol.Contains (obj), "#D1");
85 Assert.AreEqual (false, grpCol.Contains (obj2), "#D2");
89 public void IndexOfTest ()
91 ListViewGroup obj = new ListViewGroup ("Item1");
92 ListViewGroup obj2 = new ListViewGroup ("Item2");
95 Assert.AreEqual (1, grpCol.IndexOf (obj2), "#E1");
99 public void RemoveTest ()
101 ListViewGroup obj = new ListViewGroup ("Item1");
102 ListViewGroup obj2 = new ListViewGroup ("Item2");
106 Assert.AreEqual (1, grpCol.Count, "#F1");
110 public void RemoveAtTest ()
112 ListViewGroup obj = new ListViewGroup ("Item1");
113 ListViewGroup obj2 = new ListViewGroup ("Item2");
117 Assert.AreEqual (1, grpCol.Count, "#G1");
118 Assert.AreEqual (true, grpCol.Contains (obj2), "#G2");
122 [ExpectedException (typeof (ArgumentOutOfRangeException))]
123 public void IndexerOutOfRangeTest ()
125 grpCol.Add (new ListViewGroup ("Item1"));
130 public void IndexerOutOfRangeTest2()
131 { //.NET 2.0 don't throw a exception here
132 grpCol.Add (new ListViewGroup ("Item1"));
133 grpCol["TestItemThatDoesNotExist"] = null;