Example #1
0
        public void No_Repeated_Word_Returns_Null()
        {
            //act
            var actual = HashTableChallenges.FindRepeatedWord("One Two Three");

            //Assert
            Assert.Null(actual);
        }
Example #2
0
        public void Find_Repeated_Word_Test(string input, string expected)
        {
            //act
            var actual = HashTableChallenges.FindRepeatedWord(input);

            //Assert
            Assert.Equal(expected, actual);
        }
Example #3
0
        public void Counts_Of_Each_Word_Test()
        {
            //arrange
            string input = "Penultimate is the penultimate word in this penultimate sentence. See?";

            string[] expected = new string[] { "in : 1", "this : 1", "the : 1", "penultimate : 3", "word : 1", "see? : 1", "sentence. : 1", "" };

            //act
            string[] actual = HashTableChallenges.CountsOfEachWord(input);

            //Assert
            Assert.Equal(expected, actual);
        }
Example #4
0
        public void Left_Join_Test()
        {
            //arrange
            MyHashTable <string> leftHT = new MyHashTable <string>(1024);

            leftHT.Add("Thunderous", "Loud");
            leftHT.Add("Icy", "Cold");
            leftHT.Add("Quick", "Fast");
            MyHashTable <string> rightHT = new MyHashTable <string>(1024);

            rightHT.Add("Thunderous", "quiet");
            rightHT.Add("Icy", "warm");

            //act
            HashSet <string[]> actual   = HashTableChallenges.LeftJoin(leftHT, rightHT);
            HashSet <string[]> expected = new HashSet <string[]>();

            expected.Add(new string[] { "Icy", "Cold", "warm" });
            expected.Add(new string[] { "Quick", "Fast", "NULL" });
            expected.Add(new string[] { "Thunderous", "Loud", "quiet" });

            //assert
            Assert.Equal(expected.ToString(), actual.ToString());
        }