2 // ListDictionaryTest.cs
3 // - NUnit Test Cases for System.Collections.Specialized.ListDictionary.cs
6 // Duncan Mak (duncan@ximian.com)
7 // Alon Gazit (along@mainsoft.com)
8 // Sebastien Pouliot <sebastien@ximian.com>
10 // Copyright (C) 2003 Ximian Inc.
11 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
14 using NUnit.Framework;
16 using System.Collections;
17 using System.Collections.Specialized;
19 namespace MonoTests.System.Collections.Specialized {
22 public class ListDictionaryTest {
24 private void BasicTests (ListDictionary ld)
26 Assert.AreEqual (0, ld.Count, "Count");
27 Assert.IsFalse (ld.IsFixedSize, "IsFixedSize");
28 Assert.IsFalse (ld.IsReadOnly, "IsReadOnly");
29 Assert.IsFalse (ld.IsSynchronized, "IsSynchronized");
30 Assert.AreEqual (0, ld.Keys.Count, "Keys");
31 Assert.AreEqual (0, ld.Values.Count, "Values");
32 Assert.IsNotNull (ld.SyncRoot, "SyncRoot");
33 Assert.IsNotNull (ld.GetEnumerator (), "GetEnumerator");
34 Assert.IsNotNull ((ld as IEnumerable).GetEnumerator (), "IEnumerable.GetEnumerator");
37 Assert.AreEqual (1, ld.Count, "Count-1");
38 Assert.IsTrue (ld.Contains ("a"), "Contains(a)");
39 Assert.IsFalse (ld.Contains ("1"), "Contains(1)");
42 Assert.AreEqual (2, ld.Count, "Count-2");
43 Assert.IsNull (ld["b"], "this[b]");
45 DictionaryEntry[] entries = new DictionaryEntry[2];
46 ld.CopyTo (entries, 0);
49 Assert.AreEqual ("2", ld["b"], "this[b]2");
52 Assert.AreEqual (1, ld.Count, "Count-3");
54 Assert.AreEqual (0, ld.Count, "Count-4");
58 public void Constructor_Default ()
60 ListDictionary ld = new ListDictionary ();
65 public void Constructor_IComparer_Null ()
67 ListDictionary ld = new ListDictionary (null);
72 public void Constructor_IComparer ()
74 ListDictionary ld = new ListDictionary (new CaseInsensitiveComparer ());
78 [Test, ExpectedException (typeof (ArgumentNullException))]
79 public void CopyTo1 ()
81 ListDictionary ld = new ListDictionary ();
85 [Test, ExpectedException (typeof (ArgumentOutOfRangeException))]
86 public void CopyTo2 ()
88 ListDictionary ld = new ListDictionary ();
89 ld.CopyTo (new int[1],-1);
92 [Test, ExpectedException (typeof (ArgumentNullException))]
95 ListDictionary ld = new ListDictionary ();