Example #1
0
        public void TestOfRemovingNonExistentElementFromHashTable()
        {
            MinMaxHashTable<int, string> table = new MinMaxHashTable<int, string>();

            table.Add(1, "one");
            table.Add(2, "two");
            table.Add(3, "three");


            var value = table.Remove(20);
            // Exception should be thrown at previous line
        }
Example #2
0
        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);
        }