public void TestOfContainsOnEmptyHashTable() { MinMaxHashTable<int, string> table = new MinMaxHashTable<int, string>(); Assert.IsFalse(table.Contains(-1)); Assert.IsFalse(table.Contains(0)); Assert.IsFalse(table.Contains(1)); }
public void TestOfAddingMultipleDistinctElementToHashTable() { MinMaxHashTable<int, string> table = new MinMaxHashTable<int, string>(); table.Add(1, "one"); table.Add(2, "two"); table.Add(3, "three"); Assert.IsTrue(table.Contains(1)); Assert.AreEqual("one", table.Get(1)); Assert.IsTrue(table.Contains(2)); Assert.AreEqual("two", table.Get(2)); Assert.IsTrue(table.Contains(3)); Assert.AreEqual("three", table.Get(3)); Assert.AreEqual(3, table.Count); }
public void TestOfAddingSingleElementToHashTable() { MinMaxHashTable<int, string> table = new MinMaxHashTable<int, string>(); table.Add(1, "one"); Assert.IsTrue(table.Contains(1)); Assert.AreEqual("one", table.Get(1)); Assert.AreEqual(1, table.Count); }
public void TestOfAddingManyDistinctElementToHashTable() { MinMaxHashTable<int, string> table = new MinMaxHashTable<int, string>(capacity: 16384); const int elements = 1000000; for (int i = 0; i < elements; i++) { table.Add(i, i.ToString()); } Assert.AreEqual(elements, table.Count); for (int i = 0; i < elements; i++) { Assert.IsTrue(table.Contains(i)); Assert.AreEqual(i.ToString(), table.Get(i)); } Assert.IsFalse(table.Contains(-1)); Assert.IsFalse(table.Contains(elements)); }
public void TestOfRemovingElementFromHashTable() { MinMaxHashTable<int, string> table = new MinMaxHashTable<int, string>(); table.Add(1, "one"); table.Add(2, "two"); table.Add(3, "three"); var value = table.Remove(2); Assert.AreEqual("two", value); Assert.IsTrue(table.Contains(1)); Assert.AreEqual("one", table.Get(1)); Assert.IsFalse(table.Contains(2)); Assert.IsTrue(table.Contains(3)); Assert.AreEqual("three", table.Get(3)); Assert.AreEqual(2, table.Count); }