public void TryGet_From_Empty() { IHashTable <string, int> table = new DataStructures.HashTable.LinkedListHashTable <string, int>(); int value; Assert.IsFalse(table.TryGetValue("missing", out value)); }
public void Get_Missing() { IHashTable <string, int> table = new DataStructures.HashTable.LinkedListHashTable <string, int>(); table.Add("100", 100); int value = table["missing"]; }
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"); }
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)); }
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"); } }
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"); } }
public void Get_From_Empty() { IHashTable <string, int> table = new DataStructures.HashTable.LinkedListHashTable <string, int>(); int value = table["missing"]; }