public virtual void TestDifferentKeysSameHashCode() { Hashtable4TestCase.Key key1 = new Hashtable4TestCase.Key(1); Hashtable4TestCase.Key key2 = new Hashtable4TestCase.Key(1); Hashtable4TestCase.Key key3 = new Hashtable4TestCase.Key(2); 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)); table.Put(key2, "baz"); Assert.AreEqual("foo", table.Get(key1)); Assert.AreEqual("baz", table.Get(key2)); Assert.AreEqual(2, CountKeys(table)); table.Put(key1, "spam"); Assert.AreEqual("spam", table.Get(key1)); Assert.AreEqual("baz", table.Get(key2)); Assert.AreEqual(2, CountKeys(table)); table.Put(key3, "eggs"); Assert.AreEqual("spam", table.Get(key1)); Assert.AreEqual("baz", table.Get(key2)); Assert.AreEqual("eggs", table.Get(key3)); Assert.AreEqual(3, CountKeys(table)); table.Put(key2, "mice"); Assert.AreEqual("spam", table.Get(key1)); Assert.AreEqual("mice", table.Get(key2)); Assert.AreEqual("eggs", table.Get(key3)); Assert.AreEqual(3, CountKeys(table)); }
private Hashtable4TestCase.Key[] CreateKeys(int begin, int end) { int factor = 10; int count = (end - begin); Hashtable4TestCase.Key[] keys = new Hashtable4TestCase.Key[count * factor]; for (int i = 0; i < count; ++i) { int baseIndex = i * factor; for (int j = 0; j < factor; ++j) { keys[baseIndex + j] = new Hashtable4TestCase.Key(begin + i); } } return(keys); }
private Hashtable4TestCase.Key[] CreateKeys(int begin, int end) { int factor = 10; int count = (end - begin); Hashtable4TestCase.Key[] keys = new Hashtable4TestCase.Key[count * factor]; for (int i = 0; i < count; ++i) { int baseIndex = i * factor; for (int j = 0; j < factor; ++j) { keys[baseIndex + j] = new Hashtable4TestCase.Key(begin + i); } } return keys; }