public void SearchingOneElement() { var rnd = new Random(); var List = new HashTableList(10000); var toFindKey = RandomString(10); var toFindValue = RandomString(10); var put = rnd.Next(0, 1000); for (int i = 0; i < 10000; i++) { if (i == put) { List.PutPair(toFindKey, toFindValue); } else { List.PutPair(RandomString(5), RandomString(5)); } } Assert.AreEqual(toFindValue, List.GetValueByKey(toFindKey)); for (int i = 1; i < 10000; i++) { List.PutPair(RandomString(10), RandomString(10)); } Assert.AreEqual(toFindValue, List.GetValueByKey(toFindKey)); }
public void ThreeElements() { var List = new HashTableList(3); List.PutPair("BMW", "E39"); List.PutPair("Audi", "A6"); List.PutPair("JDM", "Tourer V"); Assert.AreEqual("E39", List.GetValueByKey("BMW")); Assert.AreEqual("A6", List.GetValueByKey("Audi")); Assert.AreEqual("Tourer V", List.GetValueByKey("JDM")); }
static void Main(string[] args) { var List = new HashTableList(3); List.PutPair("BMW", "E39"); List.PutPair("Audi", "A6"); List.PutPair("JDM", "Tourer V"); List.PutPair("Mercedes", "V-klasse"); List.PutPair("BMW", "M5"); Console.WriteLine(List.GetValueByKey("Mercedes")); Console.WriteLine(List.GetValueByKey("BMW")); Console.WriteLine(List.GetValueByKey("Audi")); Console.WriteLine(List.GetValueByKey("JDM")); }
public void AddingTheSameElement() { var List = new HashTableList(2); List.PutPair("BMW", "E39"); List.PutPair("BMW", "M5"); Assert.AreEqual("M5", List.GetValueByKey("BMW")); }