Beispiel #1
0
        public void AddTwoKeyValueAndRetrieveBoth()
        {
            var customHashTable = new CustomHashTable <string, Person>();

            var person = new Person {
                Name = "Vaibhav", Age = 35
            };

            customHashTable.Add(person.Name, person);

            var personTwo = new Person {
                Name = "Vaibhav Bali", Age = 35
            };

            customHashTable.Add(personTwo.Name, personTwo);

            Assert.IsTrue(customHashTable.Contains(person.Name));

            var element = customHashTable.GetElement(person.Name);

            Assert.IsNotNull(element);

            Assert.AreEqual(person.Name, element.Name);
            Assert.AreEqual(person.Age, element.Age);

            Assert.IsTrue(customHashTable.Contains(personTwo.Name));

            var secondElement = customHashTable.GetElement(personTwo.Name);

            Assert.IsNotNull(secondElement);

            Assert.AreEqual(personTwo.Name, secondElement.Name);
            Assert.AreEqual(personTwo.Age, secondElement.Age);
        }