Beispiel #1
0
 public void InsertTest()
 {
     var hashMap = new HashMap(11);
     hashMap.Insert(22, 0);
     hashMap.Insert(44, 1);
     hashMap.Insert(33, 2);
     hashMap.Insert(11, 3);
     Assert.AreEqual(hashMap.Count(), 4);
 }
Beispiel #2
0
        public void RemoveTest()
        {
            var hashMap = new HashMap(11);

            hashMap.Insert(22, 1);
            hashMap.Insert(33, 1);
            hashMap.Insert(44, 1);
            hashMap.Remove(33);

            try
            {
                hashMap.Remove(21);
            }
            catch (KeyNotFoundException exception)
            {
                Console.Out.WriteLine("Key not found for remove which doesn't exist in hashmap and hence exception raised");
            }
        }
Beispiel #3
0
        public void SearchTest()
        {
            bool expected = true;
            var hashMap = new HashMap(11);
            hashMap.Insert(22, 1);
            hashMap.Insert(44, 1);

            var actual = hashMap.Search(22);
            Assert.AreEqual(expected, actual);

            expected = false;
            actual = hashMap.Search(33);
            Assert.AreEqual(expected, actual);
        }