示例#1
0
        public void TryGet_From_Empty()
        {
            IHashTable <string, int> table = new DataStructures.HashTable.LinkedListHashTable <string, int>();
            int value;

            Assert.IsFalse(table.TryGetValue("missing", out value));
        }
示例#2
0
        public void Get_Missing()
        {
            IHashTable <string, int> table = new DataStructures.HashTable.LinkedListHashTable <string, int>();

            table.Add("100", 100);

            int value = table["missing"];
        }
示例#3
0
        public void Remove_Missing()
        {
            IHashTable <string, int> table = new DataStructures.HashTable.LinkedListHashTable <string, int>();

            table.Add("100", 100);

            Assert.IsFalse(table.Remove("missing"), "Remove on an empty collection should return false");
        }
示例#4
0
        public void TryGet_Missing()
        {
            IHashTable <string, int> table = new DataStructures.HashTable.LinkedListHashTable <string, int>();

            table.Add("100", 100);

            int value;

            Assert.IsFalse(table.TryGetValue("missing", out value));
        }
示例#5
0
        public void Remove_Found()
        {
            IHashTable <string, int> table = new DataStructures.HashTable.LinkedListHashTable <string, int>();

            for (int i = 0; i < 100; i++)
            {
                table.Add(i.ToString(), i);
            }

            for (int i = 0; i < 100; i++)
            {
                Assert.IsTrue(table.ContainsKey(i.ToString()), "The key was not found in the collection");
                Assert.IsTrue(table.Remove(i.ToString()), "The value was not removed (or remove returned false)");
                Assert.IsFalse(table.ContainsKey(i.ToString()), "The key should not have been found in the collection");
            }
        }
示例#6
0
        public void Get_Succeeds()
        {
            IHashTable <string, int> table = new DataStructures.HashTable.LinkedListHashTable <string, int>();

            table.Add("100", 100);

            int value = table["100"];

            Assert.AreEqual(100, value, "The returned value was incorrect");

            for (int i = 0; i < 100; i++)
            {
                table.Add(i.ToString(), i);

                value = table["100"];
                Assert.AreEqual(100, value, "The returned value was incorrect");
            }
        }
示例#7
0
 public void Get_From_Empty()
 {
     IHashTable <string, int> table = new DataStructures.HashTable.LinkedListHashTable <string, int>();
     int value = table["missing"];
 }