public virtual void TestByteArrayKeys() { byte[] key1 = new byte[] { 1, 2, 3 }; byte[] key2 = new byte[] { 3, 2, 1 }; byte[] key3 = new byte[] { 3, 2, 1 }; // same values as key2 Hashtable4 table = new Hashtable4(2); table.Put(key1, "foo"); table.Put(key2, "bar"); Assert.AreEqual("foo", table.Get(key1)); Assert.AreEqual("bar", table.Get(key2)); Assert.AreEqual(2, CountKeys(table)); Assert.AreEqual(2, table.Size()); table.Put(key3, "baz"); Assert.AreEqual("foo", table.Get(key1)); Assert.AreEqual("baz", table.Get(key2)); Assert.AreEqual(2, CountKeys(table)); Assert.AreEqual(2, table.Size()); Assert.AreEqual("baz", table.Remove(key2)); Assert.AreEqual(1, CountKeys(table)); Assert.AreEqual(1, table.Size()); Assert.AreEqual("foo", table.Remove(key1)); Assert.AreEqual(0, CountKeys(table)); Assert.AreEqual(0, table.Size()); }
public virtual void TestClear() { Hashtable4 table = new Hashtable4(); for (int i = 0; i < 2; ++i) { table.Clear(); Assert.AreEqual(0, table.Size()); table.Put("foo", "bar"); Assert.AreEqual(1, table.Size()); AssertIterator(table, new object[] { "foo" }); } }
public override string ToString() { return("CustomClassRepository(classes: " + _classes.Size() + ")"); }
public virtual bool IsEmpty() { return(_table.Size() == 0); }