public void Constructor_Default() { UnitTestNameObjectCollectionBase coll = new UnitTestNameObjectCollectionBase(); Assert.AreEqual(0, coll.Count, "Count-0"); Assert.IsFalse(coll._IsReadOnly, "IsReadOnly"); Assert.IsFalse(coll.HasKeys(), "HasKeys-0"); coll.Add("a", "1"); CheckICollection(coll, 1); Assert.AreEqual(1, coll.Count, "Count-1"); Assert.AreEqual("1", coll.Get(0), "Get(0)"); Assert.AreEqual(1, coll.GetAllKeys().Length, "GetAllKeys"); Assert.IsTrue(coll.HasKeys(), "HasKeys-1"); coll.Add("b", "2"); Assert.AreEqual(2, coll.Count, "Count-2"); Assert.AreEqual("b", coll.GetKey(1), "GetKey(1)"); Assert.AreEqual(2, coll.GetAllValues().Length, "GetAllValues"); coll.Remove("a"); Assert.AreEqual(1, coll.Count, "Count-3"); coll.Set(0, "3"); Assert.AreEqual("3", coll.Get(0), "Get(0)b"); coll.Set("b", "4"); Assert.AreEqual("4", coll.Get(0), "Get(0)c"); coll.RemoveAt(0); Assert.AreEqual(0, coll.Count, "Count-4"); Assert.IsFalse(coll.HasKeys(), "HasKeys-2"); }
private void CheckICollection(UnitTestNameObjectCollectionBase coll, int count) { ICollection collection = (coll as ICollection); Assert.AreEqual(count, collection.Count, "Count"); Assert.IsFalse(collection.IsSynchronized, "IsSynchronized"); Assert.IsNotNull(collection.SyncRoot, "SyncRoot"); string[] array = new string[count]; collection.CopyTo(array, 0); for (int i = 0; i < count; i++) { Assert.AreEqual(coll.GetKey(i), array[i], "#" + i.ToString()); } }
public void Constructor_Default () { UnitTestNameObjectCollectionBase coll = new UnitTestNameObjectCollectionBase (); Assert.AreEqual (0, coll.Count, "Count-0"); Assert.IsFalse (coll._IsReadOnly, "IsReadOnly"); Assert.IsFalse (coll.HasKeys (), "HasKeys-0"); coll.Add ("a", "1"); CheckICollection (coll, 1); Assert.AreEqual (1, coll.Count, "Count-1"); Assert.AreEqual ("1", coll.Get (0), "Get(0)"); Assert.AreEqual (1, coll.GetAllKeys ().Length, "GetAllKeys"); Assert.IsTrue (coll.HasKeys (), "HasKeys-1"); coll.Add ("b", "2"); Assert.AreEqual (2, coll.Count, "Count-2"); Assert.AreEqual ("b", coll.GetKey (1), "GetKey(1)"); Assert.AreEqual (2, coll.GetAllValues ().Length, "GetAllValues"); coll.Remove ("a"); Assert.AreEqual (1, coll.Count, "Count-3"); coll.Set (0, "3"); Assert.AreEqual ("3", coll.Get (0), "Get(0)b"); coll.Set ("b", "4"); Assert.AreEqual ("4", coll.Get (0), "Get(0)c"); coll.RemoveAt (0); Assert.AreEqual (0, coll.Count, "Count-4"); Assert.IsFalse (coll.HasKeys (), "HasKeys-2"); }
private void CheckICollection (UnitTestNameObjectCollectionBase coll, int count) { ICollection collection = (coll as ICollection); Assert.AreEqual (count, collection.Count, "Count"); Assert.IsFalse (collection.IsSynchronized, "IsSynchronized"); Assert.IsNotNull (collection.SyncRoot, "SyncRoot"); string[] array = new string[count]; collection.CopyTo (array, 0); for (int i = 0; i < count; i++) { Assert.AreEqual (coll.GetKey (i), array[i], "#" + i.ToString ()); } }