예제 #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"));
        }