Пример #1
0
        public static void displayHashes()
        {
            Hashtables hashTables = new Hashtables();

            hashTables.Add("abc", "Josie");
            hashTables.Add("Dog", "Woof");
            hashTables.Add("333", "ponies");
            hashTables.Add("moons", "44");
            hashTables.Add("cba", "Doctor"); //Collision abc same as cba
            Console.WriteLine($"Should return as 'True' for contains:  {hashTables.Contains("moons")}");
            Console.WriteLine($"Should return as 'False' for contains: {hashTables.Contains("planet")}");
            Console.WriteLine($"Should return the value 'Woof' from key:  {hashTables.GetValue("Dog")}");
            Console.WriteLine($"Should return the value 'Doctor' from collision: {hashTables.GetValue("cba")}");
        }
Пример #2
0
        public void GetValue(string key, object value)
        {
            Hashtables hashTables = new Hashtables();

            hashTables.Add(key, value);

            Assert.Equal(value, hashTables.GetValue(key));
        }
Пример #3
0
        public void GetCollision1()
        {
            Hashtables hashTables = new Hashtables();

            hashTables.Add("abc", "Josie");
            hashTables.Add("cba", 22);
            hashTables.Add("acb", true);

            Assert.Equal("Josie", hashTables.GetValue("abc"));
        }
Пример #4
0
        public void GetNull3()
        {
            Hashtables hashTables = new Hashtables();

            hashTables.Add("abc", "Josie");
            hashTables.Add("Dog", "Woof");
            hashTables.Add("333", "ponies");
            hashTables.Add("moons", "44");

            Assert.Null(hashTables.GetValue("three"));
        }