public void Test_Delete_Ovarlapped(int personCount) { TestFabrics.Init(personCount, ht); LinearHashTable ini = ht; Person p = new Person(2, "Vasya2", "Pupkin2", 42); ht.Add(p); int expectedPos = p.GetHashCode() % ht.Capacity; int actualPos = ht.GetPosition(p); ht.Delete(p); bool res = ini.Equals(ht); Assert.AreNotEqual(expectedPos, actualPos); Assert.IsTrue(res); }
public static void HashTableAddAssert(int personCount, IHashTable ht) { bool result = false; IHashTable localHT = null; if (ht.GetType() == typeof(LinearHashTable)) { localHT = new LinearHashTable(); } else if (ht.GetType() == typeof(ChainedHashTable)) { localHT = new ChainedHashTable(); } Init(personCount, localHT); localHT.Add(new Person(5, "Sasya", "Lapkin", 45)); result = localHT.Equals(ht); Assert.IsTrue(result); }
public static void HashTableDeleteAssert(int personCount, IHashTable ht) { bool result = false; IHashTable localHT = null; if (ht.GetType() == typeof(LinearHashTable)) { localHT = new LinearHashTable(); } else if (ht.GetType() == typeof(ChainedHashTable)) { localHT = new ChainedHashTable(); } switch (personCount) { case 2: localHT.Add(new Person(2, "Vasya", "Pupkin", 42)); break; case 7: localHT.Add(new Person(2, "Vasya", "Pupkin", 42)); localHT.Add(new Person(3, "Vasya", "Papkin", 43)); localHT.Add(new Person(4, "Kasya", "Babkin", 44)); localHT.Add(new Person(5, "Masya", "Lapkin", 45)); localHT.Add(new Person(6, "Figasya", "Lupkin", 46)); localHT.Add(new Person(7, "Pupasya", "Lurkin", 47)); break; default: break; } result = localHT.Equals(ht); Assert.IsTrue(result); }
protected void SetUp() { ht = new LinearHashTable(); }