public void GetCountTest()
        {
            Dictionary <string, int> Dictionary1 = new Dictionary <string, int>();

            Dictionary1.Add("ba", 2);
            Dictionary1.Add("black", 1);
            Dictionary1.Add("sheep", 1);

            Dictionary <string, int> Dictionary2 = new Dictionary <string, int>();

            Dictionary2.Add("b", 2);
            Dictionary2.Add("c", 1);
            Dictionary2.Add("a", 2);

            Dictionary <string, int> Dictionary3 = new Dictionary <string, int>();

            Dictionary3.Add("b", 1);
            Dictionary3.Add("c", 1);
            Dictionary3.Add("a", 1);

            WordCount myWordCount = new WordCount();


            CollectionAssert.AreEquivalent(Dictionary1, myWordCount.GetCount(new string[] { "ba", "ba", "black", "sheep" }));
            CollectionAssert.AreEquivalent(Dictionary2, myWordCount.GetCount(new string[] { "a", "b", "a", "c", "b" }));
            CollectionAssert.AreEquivalent(Dictionary3, myWordCount.GetCount(new string[] { "c", "b", "a" }));
        }
Ejemplo n.º 2
0
        public void WordCountTests()
        {
            WordCount wordCountTest = new WordCount();

            Dictionary <string, int> expected = new Dictionary <string, int>()
            {
                { "ba", 2 }, { "black", 1 }, { "sheep", 1 }
            };

            CollectionAssert.AreEqual(expected, wordCountTest.GetCount(new string[] { "ba", "ba", "black", "sheep" }));

            expected = new Dictionary <string, int>()
            {
                { "a", 2 }, { "b", 2 }, { "c", 1 }
            };
            CollectionAssert.AreEqual(expected, wordCountTest.GetCount(new string[] { "a", "b", "a", "c", "b" }));

            expected = new Dictionary <string, int>()
            {
                { "c", 1 }, { "b", 1 }, { "a", 1 }
            };
            CollectionAssert.AreEqual(expected, wordCountTest.GetCount(new string[] { "c", "b", "a" }));

            expected = new Dictionary <string, int>()
            {
            };
            CollectionAssert.AreEqual(expected, wordCountTest.GetCount(new string[] {  }));
        }
        public void GetCount()
        {
            Dictionary <string, int> testDict = new Dictionary <string, int>();

            testDict.Add("ba", 2);
            testDict.Add("black", 1);
            testDict.Add("sheep", 1);

            CollectionAssert.AreEqual(testDict, test.GetCount(new string[] { "ba", "ba", "black", "sheep" }),
                                      "Test 1: Input \"ba\", \"ba\", \"black\", \"sheep\"");

            testDict.Clear();

            testDict.Add("a", 2);
            testDict.Add("b", 2);
            testDict.Add("c", 1);

            CollectionAssert.AreEqual(testDict, test.GetCount(new string[] { "a", "b", "a", "c", "b" }),
                                      "Test 2: Input \"a\", \"b\", \"a\", \"c\", \"b\"");

            testDict.Clear();

            CollectionAssert.AreEqual(testDict, test.GetCount(new string[0]),
                                      "Test 3: Input empty array");

            testDict.Add("c", 1);
            testDict.Add("b", 1);
            testDict.Add("a", 1);

            CollectionAssert.AreEqual(testDict, test.GetCount(new string[] { "c", "b", "a" }),
                                      "Test 4: \"c\", \"b\", \"a\"");
        }
Ejemplo n.º 4
0
        public void GetCount()
        {
            Dictionary <string, int> result1 = wordCount.GetCount(array1);
            Dictionary <string, int> result2 = wordCount.GetCount(array2);
            Dictionary <string, int> result3 = wordCount.GetCount(array3);

            CollectionAssert.AreEqual(expected1, result1, "The returned dictionary does not match the expected result.");
            CollectionAssert.AreEqual(expected2, result2, "The returned dictionary does not match the expected result.");
            CollectionAssert.AreEqual(expected3, result3, "The returned dictionary does not match the expected result.");
        }
        public void WordCountABCTest()
        {
            string[] words = { "a", "b", "a" };

            Dictionary <string, int> result = wc.GetCount(words);

            Dictionary <string, int> expectedResult = new Dictionary <string, int> {
                { "a", 2 }, { "b", 1 }
            };

            CollectionAssert.AreEqual(expectedResult, result);
        }
Ejemplo n.º 6
0
        public void WordCountTestBlackSheep()
        {
            string[] parameter = { "ba", "ba", "black", "sheep" };
            Dictionary <string, int> result   = thisWordCount.GetCount(parameter);
            Dictionary <string, int> expected = new Dictionary <string, int>
            {
                { "ba", 2 },
                { "black", 1 },
                { "sheep", 1 }
            };

            CollectionAssert.AreEqual(expected, result);
        }
Ejemplo n.º 7
0
        public void GetCountTest()
        {
            var exercise = new WordCount();

            //GetCount(["ba", "ba", "black", "sheep"]) → { "ba" : 2, "black": 1, "sheep": 1 }
            CollectionAssert.AreEquivalent(
                new Dictionary <string, int>
            {
                { "ba", 2 },
                { "black", 1 },
                { "sheep", 1 }
            }, exercise.GetCount(
                    new string[]
                    { "ba", "ba", "black", "sheep" }
                    )
                );
            //GetCount(["a", "b", "a", "c", "b"]) → { "b": 2, "c": 1, "a": 2}
            CollectionAssert.AreEquivalent(
                new Dictionary <string, int>
            {
                { "b", 2 },
                { "c", 1 },
                { "a", 2 }
            }, exercise.GetCount(
                    new string[]
                    { "a", "b", "a", "c", "b" }
                    )
                );
            //GetCount([]) → { }
            CollectionAssert.AreEquivalent(
                new Dictionary <string, int>
            {
            }, exercise.GetCount(
                    new string[]
                    { }
                    )
                );
            //GetCount(["c", "b", "a"]) → { "b": 1, "c": 1, "a": 1}
            CollectionAssert.AreEquivalent(
                new Dictionary <string, int>
            {
                { "b", 1 },
                { "c", 1 },
                { "a", 1 }
            }, exercise.GetCount(
                    new string[]
                    { "c", "b", "a" }
                    )
                );
        }
Ejemplo n.º 8
0
        public void WrdCountTest()
        {
            WordCount Counter = new WordCount();

            Dictionary <string, int> expected = new Dictionary <string, int>()
            {
                { "ba", 2 },
                { "black", 1 },
                { "sheep", 1 }
            };
            Dictionary <string, int> actual = Counter.GetCount(new string[] { "ba", "ba", "black", "sheep" });

            AssertCollections(expected, actual);

            Counter = new WordCount();

            expected = new Dictionary <string, int>
            {
                { "for", 3 },
                { "nor", 2 },
                { "xor", 1 }
            };
            actual = Counter.GetCount(new string[] { "for", "nor", "for", "xor", "nor", "for" });
            AssertCollections(expected, actual);

            Counter = new WordCount();

            expected = new Dictionary <string, int> {
            };
            actual   = Counter.GetCount(new string[] { });
            AssertCollections(expected, actual);
        }
 public void WordCountTests()
 {
     CollectionAssert.AreEqual(new Dictionary <string, int>()
     {
         { "ba", 2 }, { "black", 1 }, { "sheep", 1 }
     }, wordCount.GetCount(new string[] { "ba", "ba", "black", "sheep" }), "Bloop");
     CollectionAssert.AreEqual(new Dictionary <string, int>()
     {
         { "a", 2 }, { "b", 2 }, { "c", 1 }
     }, wordCount.GetCount(new string[] { "a", "b", "a", "c", "b" }), "Boop");
     CollectionAssert.AreEqual(new Dictionary <string, int>(), wordCount.GetCount(new string[] { }), "Ploop");
     CollectionAssert.AreEqual(new Dictionary <string, int>()
     {
         { "c", 1 }, { "b", 1 }, { "a", 1 }
     }, wordCount.GetCount(new string[] { "c", "b", "a" }), "Oop");
 }
Ejemplo n.º 10
0
        public void WordCount()//rename to GetCountTest
        {
            WordCount myWordCount = new WordCount();

            //Test1
            Dictionary <string, int> expected = new Dictionary <string, int>()
            {
                { "ba", 2 }, { "black", 1 }, { "sheep", 1 }
            };
            Dictionary <string, int> actual = myWordCount.GetCount(new string[]
            {
                "ba", "ba", "black", "sheep"
            });

            CollectionAssert.AreEqual(expected, actual);

            //Test2
            expected = new Dictionary <string, int>()
            {
                { "b", 2 }, { "c", 1 }, { "a", 2 }
            };
            actual = myWordCount.GetCount(new string[]
            {
                "a", "b", "a", "c", "b"
            });
            CollectionAssert.AreEquivalent(expected, actual);

            //Test3
            expected = new Dictionary <string, int>()
            {
            };
            actual = myWordCount.GetCount(new string[]
            {
            });
            CollectionAssert.AreEqual(expected, actual);

            //Test4
            expected = new Dictionary <string, int>()
            {
                { "b", 1 }, { "c", 1 }, { "a", 1 }
            };
            actual = myWordCount.GetCount(new string[]
            {
                "c", "b", "a"
            });
            CollectionAssert.AreEquivalent(expected, actual);
        }
Ejemplo n.º 11
0
        public void EmptySetTest_ExpectEmptySet()
        {
            //Arrange
            WordCount exercises = new WordCount();

            //Assert
            CollectionAssert.AreEqual(new Dictionary <string, int>(), exercises.GetCount(new string[] { }));
        }
Ejemplo n.º 12
0
        public void appearsThrice()
        {
            WordCount count        = new WordCount("Law", "There is no law except the law that there is no law.");
            int       correctCount = 3;
            int       returnCount  = count.GetCount();

            Assert.AreEqual(correctCount, returnCount);
        }
Ejemplo n.º 13
0
        public void stringValues3()
        {
            WordCount stringKeys3            = new WordCount();
            Dictionary <string, int> result3 = stringKeys3.GetCount(new string[] { });

            CollectionAssert.AreEquivalent(new Dictionary <string, int> {
            }, result3);
        }
Ejemplo n.º 14
0
        public void WordCountTests()
        {
            WordCount wordCount             = new WordCount();
            Dictionary <string, int> result = wordCount.GetCount(new string[] { "ba", "ba", "black", "sheep" });

            CollectionAssert.AreEquivalent(new Dictionary <string, int> {
                { "ba", 2 }, { "black", 1 }, { "sheep", 1 }
            }, result);

            result = wordCount.GetCount(new string[] { "marco", "polo", "marco", "polo" });
            CollectionAssert.AreEquivalent(new Dictionary <string, int> {
                { "marco", 2 }, { "polo", 2 }
            }, result);

            result = wordCount.GetCount(new string[] { });
            CollectionAssert.AreEquivalent(new Dictionary <string, int> {
            }, result);
        }
Ejemplo n.º 15
0
        public void stringValues4()
        {
            WordCount stringKeys4            = new WordCount();
            Dictionary <string, int> result4 = stringKeys4.GetCount(new string[] { "c", "b", "a" });

            CollectionAssert.AreEquivalent(new Dictionary <string, int> {
                { "b", 1 }, { "c", 1 }, { "a", 1 }
            }, result4);
        }
Ejemplo n.º 16
0
        public void stringValues2()
        {
            WordCount stringKeys2            = new WordCount();
            Dictionary <string, int> result2 = stringKeys2.GetCount(new string[] { "a", "b", "a", "c", "b" });

            CollectionAssert.AreEquivalent(new Dictionary <string, int> {
                { "b", 2 }, { "c", 1 }, { "a", 2 }
            }, result2);
        }
Ejemplo n.º 17
0
        public void TestWordCountGivenNulls()
        {
            WordCount testWordCount            = new WordCount();
            Dictionary <string, int> emptyDict = new Dictionary <string, int>();

            string[] emptyArray = null;

            CollectionAssert.AreEqual(emptyDict, testWordCount.GetCount(emptyArray));
        }
Ejemplo n.º 18
0
        public void stringValues()
        {
            WordCount stringKeys            = new WordCount();
            Dictionary <string, int> result = stringKeys.GetCount(new string[] { "ba", "ba", "black", "sheep" });

            CollectionAssert.AreEquivalent(new Dictionary <string, int> {
                { "ba", 2 }, { "black", 1 }, { "sheep", 1 }
            }, result);
        }
Ejemplo n.º 19
0
        public void CountThreeTest()
        {
            WordCount output = new WordCount();
            Dictionary <string, int> expected = new Dictionary <string, int>()
            {
                { "sheep", 3 },
            };

            CollectionAssert.AreEqual(expected, output.GetCount(new string[] { "sheep", "sheep", "sheep" }));
        }
Ejemplo n.º 20
0
        public void TestWordCount()
        {
            string[] array1 = new string[] { "ba", "ba", "black", "sheep" };
            string[] array2 = new string[] { "a", "b", "a", "c", "b" };
            string[] array3 = new string[] { };
            string[] array4 = new string[] { "c", "b", "a" };

            Dictionary <string, int> dictionary1 = new Dictionary <string, int>();

            dictionary1.Add("a", 2);
            dictionary1.Add("b", 2);
            dictionary1.Add("c", 1);


            Dictionary <string, int> dictionary2 = new Dictionary <string, int>();

            dictionary2.Add("c", 1);
            dictionary2.Add("b", 1);
            dictionary2.Add("a", 1);

            Dictionary <string, int> dictionary3 = new Dictionary <string, int>();

            Dictionary <string, int> dictionary4 = new Dictionary <string, int>();

            dictionary4.Add("ba", 2);
            dictionary4.Add("black", 1);
            dictionary4.Add("sheep", 1);

            Dictionary <string, int> actual  = wordCount.GetCount(array1);
            Dictionary <string, int> actual2 = wordCount.GetCount(array2);
            Dictionary <string, int> actual3 = wordCount.GetCount(array3);
            Dictionary <string, int> actual4 = wordCount.GetCount(array4);

            //*GetCount(["ba", "ba", "black", "sheep"]) → { "ba" : 2, "black": 1, "sheep": 1 }
            //*GetCount(["a", "b", "a", "c", "b"]) → { "a": 2, "b": 2, "c": 1}
            //*GetCount([]) → { }
            //*GetCount(["c", "b", "a"]) → { "c": 1, "b": 1, "a": 1}

            CollectionAssert.AreEqual(dictionary4, actual);
            CollectionAssert.AreEqual(dictionary1, actual2);
            CollectionAssert.AreEqual(dictionary3, actual3);
            CollectionAssert.AreEqual(dictionary2, actual4);
        }
Ejemplo n.º 21
0
        public void GetCount()
        {
            // Arrange
            WordCount ex = new WordCount();

            // Act
            Dictionary <string, int> actualResult = ex.GetCount(new string[] {});

            // Assert
            CollectionAssert.AreEqual(new string[] {}, actualResult);
        }
Ejemplo n.º 22
0
        public void CountTwoOneOne()
        {
            WordCount output = new WordCount();
            Dictionary <string, int> expected = new Dictionary <string, int>()
            {
                { "ba", 2 },
                { "black", 1 },
                { "sheep", 1 }
            };

            CollectionAssert.AreEqual(expected, output.GetCount(new string[] { "ba", "ba", "black", "sheep" }));
        }
Ejemplo n.º 23
0
        public void RepeatingTest()
        {
            //Arrange
            WordCount exercises = new WordCount();
            Dictionary <string, int> expected = new Dictionary <string, int>()
            {
                { "Josh", 4 },
            };

            //Assert
            CollectionAssert.AreEqual(expected, exercises.GetCount(new string[] { "Josh", "Josh", "Josh", "Josh" }));
        }
Ejemplo n.º 24
0
        public void WordNotProvidedTests()
        {
            //Arrange
            WordCount exercises = new WordCount();
            Dictionary <string, int> expected = new Dictionary <string, int>()
            {
                { "Josh", 4 },
            };

            //Assert
            CollectionAssert.AreNotEqual(expected, exercises.GetCount(new string[] { "Craig", "Craig", "Craig", "Craig" }));
        }
Ejemplo n.º 25
0
        public void GetCountTestcba()
        {
            WordCount wordCount = new WordCount();

            string[] input = { "c", "b", "a" };
            Dictionary <string, int> result   = wordCount.GetCount(input);
            Dictionary <string, int> expected = new Dictionary <string, int>
            {
                { "c", 1 }, { "b", 1 }, { "a", 1 }
            };

            CollectionAssert.AreEqual(expected, result);
        }
Ejemplo n.º 26
0
        public void CountMultiple()
        {
            WordCount output = new WordCount();
            Dictionary <string, int> expected = new Dictionary <string, int>()
            {
                { "a", 2 },
                { "b", 3 },
                { "c", 1 },
                { "d", 2 }
            };

            CollectionAssert.AreEqual(expected, output.GetCount(new string[] { "a", "b", "c", "d", "a", "b", "d", "b" }));
        }
Ejemplo n.º 27
0
        public void TestWordCountHappyPath()
        {
            WordCount testWordCount = new WordCount();
            Dictionary <string, int> blackSheepStrings = new Dictionary <string, int>
            {
                { "ba", 2 },
                { "black", 1 },
                { "sheep", 1 }
            };
            Dictionary <string, int> abcStrings = new Dictionary <string, int>
            {
                { "a", 2 },
                { "b", 2 },
                { "c", 1 }
            };

            string[] blackSheep = { "ba", "ba", "black", "sheep" };
            string[] abc        = { "a", "b", "a", "c", "b" };

            CollectionAssert.AreEqual(blackSheepStrings, testWordCount.GetCount(blackSheep));
            CollectionAssert.AreEqual(abcStrings, testWordCount.GetCount(abc));
        }
Ejemplo n.º 28
0
        public void HowManyBasInBaBaBlackSheep()
        {
            //Arrange
            WordCount marysLamb = new WordCount();

            string[] wool = { "Ba", "Ba", "Black", "Sheep" };
            //Act
            //string[] result = marysLamb.GetCount(Wool);
            Dictionary <string, int> result = marysLamb.GetCount(wool);

            //Assert
            Assert.AreEqual(2, result["Ba"]);
        }
Ejemplo n.º 29
0
        public void HowManyEisInEiAyEiAyOh()
        {
            //Arrange
            WordCount farmSong = new WordCount();

            string[] words = { "Ei", "Ay", "Ei", "Ay", "Oh" };
            //Act
            //string[] result = marysLamb.GetCount(Wool);
            Dictionary <string, int> result = farmSong.GetCount(words);

            //Assert
            Assert.AreEqual(2, result["Ei"]);
        }
Ejemplo n.º 30
0
        public void HowManywesInLittlePiggyWentHome()
        {
            //Arrange
            WordCount littlePiggy = new WordCount();

            string[] wentHome = { "we", "we", "we", "all", "the", "way", "home" };
            //Act
            //string[] result = marysLamb.GetCount(Wool);
            Dictionary <string, int> result = littlePiggy.GetCount(wentHome);

            //Assert
            Assert.AreEqual(3, result["we"]);
        }