Ejemplo n.º 1
0
        public void TwoSameWords_ShouldReturnTwoOccurences()
        {
            var wordsCounter = new WordsCounter(CreateWordsLoaderStub(val => "word word"));

            var words = wordsCounter.Count();
            Assert.Equal(2, words["word"]);
        }
Ejemplo n.º 2
0
        public void TwoSameWords_ShouldReturnCount1()
        {
            var wordsCounter = new WordsCounter(CreateWordsLoaderStub(val => "one one"));

            var words = wordsCounter.Count();
            Assert.Equal(1, words.Count);
        }
Ejemplo n.º 3
0
        public void WordsWithPunctuation_ShouldNotTakePunctuationsIntoAccount()
        {
            var wordsCounter = new WordsCounter(CreateWordsLoaderStub(val => "a word, word a, (word."));

            var words = wordsCounter.Count();

            Assert.Equal(3, words["word"]);
        }
Ejemplo n.º 4
0
        public void EmptyArray_ShouldReturnZeroWords()
        {
            var wordsCounter = new WordsCounter(CreateWordsLoaderStub(val => ""));

            var words = wordsCounter.Count();

            Assert.Equal(0, words.Count);
        }
Ejemplo n.º 5
0
        public void DifferentWords_ShouldReturnOccurences()
        {
            var wordsCounter = new WordsCounter(CreateWordsLoaderStub(val => "word test word word test"));

            var words = wordsCounter.Count();
            Assert.Equal(3, words["word"]);
            Assert.Equal(2, words["test"]);
        }
Ejemplo n.º 6
0
        public void BlankSpaces_ShouldBe_Ignored()
        {
            var wordsCounter = new WordsCounter(CreateWordsLoaderStub(val => "a    b   a    "));

            var words = wordsCounter.Count();

            Assert.Equal(2, words.Count);
        }
        public void TestWordcountWithoutStopwords()
        {
            WordsCounter wordCounter = new WordsCounter(new string[0]);

            int result = wordCounter.Count(new[] { "a", "bc", "def" });

            Assert.AreEqual(3, result);
        }
        public void TestWordcountWithStopwordsNotFound()
        {
            WordsCounter wordCounter = new WordsCounter(new[] { "xy" });

            int result = wordCounter.Count(new[] { "a", "bc", "def" });

            Assert.AreEqual(3, result);
        }
Ejemplo n.º 9
0
        private static void RunPart1()
        {
            string fileLocation = GetFileLocation("part1fileinput.txt");

            var fileLoader = new FileWordsLoader(fileLocation);
            var wordsCounter = new WordsCounter(fileLoader);

            try
            {
                PrintPart1(wordsCounter.Count());
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("File was not found at location: {0}", fileLocation);
            }
        }
Ejemplo n.º 10
0
        public void Words_ShouldSortOccurences()
        {
            var wordsCounter = new WordsCounter(CreateWordsLoaderStub(val => "word test word word test apple"));

            var words = wordsCounter.Count();

            Assert.Equal("apple", words.Keys.ElementAt(0));
            Assert.Equal("test", words.Keys.ElementAt(1));
            Assert.Equal("word", words.Keys.ElementAt(2));
        }