public void QuadraticHashTable_GetAddRemove() { // Arrange var hashTable = new QuadraticHashTable <int, string>(); // Act for (int i = 0; i < 100; i++) { hashTable.Add(i, i.ToString()); } hashTable.Remove(50); hashTable.Remove(40); // Assert for (int i = 0; i < 100; i++) { if (i != 40 && i != 50) { Assert.AreEqual(i.ToString(), hashTable.Get(i)); } else { Assert.AreEqual(null, hashTable.Get(i)); } } }
public void QuadraticHashTableOverloadingRemoveTest() { IHashTable hashTable = new QuadraticHashTable(2); Assert.IsTrue(hashTable.Add(3)); Assert.IsTrue(hashTable.Add(3)); Assert.IsFalse(hashTable.Add(6), "quadritic hash table should not be able to add element"); Assert.IsFalse(hashTable.Remove(6), "quadritic hash table should not be able to remove not-added element"); Assert.IsTrue(hashTable.Remove(3), "quadritic hash table should be able to remove existed element"); Assert.IsTrue(hashTable.Add(3), "quadritic hash table should be able to add element again"); Assert.IsTrue(hashTable.Count() == 2, "quadritic hash table has 2 elements after testing"); }