Esempio n. 1
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);
        }
Esempio n. 2
0
        public void IsCapturingWordAndSentance_CapturedAsData_String()
        {
            WordCount testCounter  = new WordCount("Cathedral", "Hey, there's a good looking Cathedral");
            string    testWord     = "Cathedral";
            string    testSentance = "Hey, there's a good looking Cathedral";

            Assert.AreEqual(testWord, testCounter.GetWord());
            Assert.AreEqual(testSentance, testCounter.GetSentance());
        }
        GetNumberOfMatches_ChecksWordAgainstSentenceContainingOneMatchThatIsSurroundedByWhiteSpaceReturnsOne_1()
        {
            string word     = "cat";
            string sentence = "Only a cat in this sentence.";

            int matchCount = WordCount.GetNumberOfMatches(word, sentence);

            Assert.AreEqual(1, matchCount);
        }
        GetNumberOfMatches_ChecksWordAgainstSentenceContainingOneMatchWithDifferentCasing_1()
        {
            string word     = "cat";
            string sentence = "Only a Cat in this sentence.";

            int matchCount = WordCount.GetNumberOfMatches(word, sentence);

            Assert.AreEqual(1, matchCount);
        }
        GetNumberOfMatches_ChecksWordAgainstSentenceContainingOneMatchWithPunctuationFollowingTheWord_1()
        {
            string word     = "cat";
            string sentence = "A cat.";

            int matchCount = WordCount.GetNumberOfMatches(word, sentence);

            Assert.AreEqual(1, matchCount);
        }
        GetNumberOfMatches_ChecksWordAgainstSentenceContainingTwoMatchesAndReturnsTwo_2()
        {
            string word     = "cat";
            string sentence = "A cat was friends with another cat named dog.";

            int matchCount = WordCount.GetNumberOfMatches(word, sentence);

            Assert.AreEqual(2, matchCount);
        }
        GetNumberOfMatches_ChecksWordAgainstSentenceContainingNoMatchesReturnsZero_0()
        {
            string word     = "cat";
            string sentence = "Only a dog in this sentence.";

            int matchCount = WordCount.GetNumberOfMatches(word, sentence);

            Assert.AreEqual(0, matchCount);
        }
Esempio n. 8
0
        public void wordOneCharSmallerThanWhatsBeingChecked_NoWordCountAdded_String()
        {
            string    word        = "rat";
            string    sentance    = "rate";
            WordCount testCounter = new WordCount(word, sentance);

            string testAnswer = "Your word " + word.ToLower() + " was found " + 0 + " times in the sentance '" + sentance + "'";

            Assert.AreEqual(testAnswer, testCounter.wordCount());
        }
Esempio n. 9
0
        public void AccountForPunctuationInSentance_IncludeWordsThatMayHavePunctuation_String()
        {
            string    word        = "Cool";
            string    sentance    = "Cool! This is so cool, don't you think it's cool?";
            WordCount testCounter = new WordCount(word, sentance);

            string testAnswer = "Your word " + word.ToLower() + " was found " + 3 + " times in the sentance '" + sentance + "'";

            Assert.AreEqual(testAnswer, testCounter.wordCount());
        }
Esempio n. 10
0
        public void SmallerWordwithinAword_ExcludeSmallerWordsWithinWords_String()
        {
            string    word        = "cat";
            string    sentance    = "cathedral";
            WordCount testCounter = new WordCount(word, sentance);

            string testAnswer = "Your word " + word.ToLower() + " was found " + 0 + " times in the sentance '" + sentance + "'";

            Assert.AreEqual(testAnswer, testCounter.wordCount());
        }
Esempio n. 11
0
        public void AccountForPunctuationSingleWord_IncludeWordsThatMayHavePunctuation_String()
        {
            string    word        = "Cool";
            string    sentance    = "Cool!";
            WordCount testCounter = new WordCount(word, sentance);

            string testAnswer = "Your word " + word.ToLower() + " was found " + 1 + " times in the sentance '" + sentance + "'";

            Assert.AreEqual(testAnswer, testCounter.wordCount());
        }
Esempio n. 12
0
        public void FindOneWordInSentance_FindASingleWordMultipleTimes_String()
        {
            string    word        = "I";
            string    sentance    = "Hello, I am cool, I think so at least.";
            WordCount testCounter = new WordCount(word, sentance);

            string testAnswer = "Your word " + word.ToLower() + " was found " + 2 + " times in the sentance '" + sentance + "'";

            Assert.AreEqual(testAnswer, testCounter.wordCount());
        }
Esempio n. 13
0
        public void FindOneSingleLetter_FindASingleLetter_String()
        {
            string    word        = "i";
            string    sentance    = "i";
            WordCount testCounter = new WordCount(word, sentance);

            string testAnswer = "Your word " + word.ToLower() + " was found " + 1 + " times in the sentance '" + sentance + "'";

            Assert.AreEqual(testAnswer, testCounter.wordCount());
        }
Esempio n. 14
0
        public void Should_Filter_WordList_With_Supplied_Stopwords(ICollection <string> words, ICollection <string> stopwords, ICollection <string> expectedResult)
        {
            // Arrange
            WordCount wordCount = CreateWordCount();

            // Act
            ICollection <string> result = wordCount.Filter(words, stopwords);

            // Assert
            result.Should().BeEquivalentTo(expectedResult);
        }
Esempio n. 15
0
        public void Should_Calculate_Average_Word_Length_Of_Supplied_Collection(ICollection <string> stringList, double expectedCount)
        {
            // Arrange
            WordCount wordCount = CreateWordCount();

            // Act
            double result = wordCount.CalculateAverageWordLength(
                stringList);

            // Assert
            result.Should().Be(expectedCount);
        }
Esempio n. 16
0
        public void Should_Sort_Supplied_Collection(ICollection <string> stringList, ICollection <string> expectedList)
        {
            // Arrange
            WordCount wordCount = CreateWordCount();

            // Act
            ICollection <string> result = wordCount.Sort(
                stringList);

            // Assert
            result.Should().BeEquivalentTo(expectedList);
        }
Esempio n. 17
0
        public void Should_Split_Text_Into_Words(string text, IList <string> expectedResult)
        {
            // Arrange
            WordCount wordSplitter = CreateWordCount();

            // Act
            ICollection <string> result = wordSplitter.SplitWords(
                text);

            // Assert
            result.Should().BeEquivalentTo(expectedResult);
        }
Esempio n. 18
0
        public void Should_Count_Words_Of_Supplied_Collection(ICollection <string> stringList, int expectedCount)
        {
            // Arrange
            WordCount wordCount = CreateWordCount();

            // Act
            int result = wordCount.CountWords(
                stringList);

            // Assert
            result.Should().Be(expectedCount);
        }
Esempio n. 19
0
        public void IsSameWord_True()
        {
            //Arrange
            WordCount sameWord = new WordCount("confirm", "confirm");

            //Act
            bool isSameWord = sameWord.IsSameWord();

            //Assert
            Assert.AreEqual(true, isSameWord);
            Console.WriteLine("Is word same? " + isSameWord);
        }
Esempio n. 20
0
        public void CorrectCountWithSpecialCharacters()
        {
            //Arrange
            WordCount count = new WordCount("confirm", "confirm, confirm! confirm");

            //Act
            int correctCount = 3;
            int returnCount  = count.GetCount();

            //Assert
            Assert.AreEqual(correctCount, returnCount);
            Console.WriteLine(returnCount);
        }
Esempio n. 21
0
        public void CorrectCountWithCaps()
        {
            //Arrange
            WordCount count = new WordCount("confirm", "Confirm confirm Confirm confirm");

            //Act
            int correctCount = 4;
            int returnCount  = count.GetCount();

            //Assert
            Assert.AreEqual(correctCount, returnCount);
            Console.WriteLine(returnCount);
        }
Esempio n. 22
0
        public void DoesClassInstantiate_InstantitionSuccessful_NewObj()
        {
            WordCount testCounter = new WordCount();

            Assert.AreEqual(typeof(WordCount), testCounter.GetType());
        }
Esempio n. 23
0
        public void IsWordCounter_HowManyAre_PleaseReEnter()
        {
            WordCount newCombination = new WordCount();

            Assert.AreEqual(1, newCombination.RepeatCounter("are", "how are you"));
        }
        public void WordCounting_OnlyCountCompleteWords_Number()
        {
            WordCount testWord = new WordCount("Jef", "My name Jeffrey but I go by Jef");

            Assert.AreEqual(testWord.WordCounting(), 1);
        }
Esempio n. 25
0
        public void IsWordCounter_HowManyThe_PleaseReEnter()
        {
            WordCount newCombination = new WordCount();

            Assert.AreEqual(2, newCombination.RepeatCounter("the", "The fox and the hound"));
        }
Esempio n. 26
0
        public void wordCountIsRunning_ExecutionOfMethod_String()
        {
            WordCount testCounter = new WordCount("Cathedral", "Hey, there's a good looking Cathedral");

            Assert.AreEqual("Your word cathedral was found 1 times in the sentance 'Hey, there's a good looking Cathedral'", testCounter.wordCount());
        }
Esempio n. 27
0
        public void IsWordCounter_SentenceBlank_PleaseReEnter()
        {
            WordCount newCombination = new WordCount();

            Assert.AreEqual("Please enter a word AND sentence", newCombination.FieldCheck("Hello", ""));
        }
        public void WordCount_AcceptInput_True()
        {
            WordCount testWord = new WordCount("Jef", "My name Jef");

            Assert.AreEqual(typeof(WordCount), testWord.GetType());
        }
Esempio n. 29
0
        public void IsWordCounter_WordBlank_PleaseReEnter()
        {
            WordCount newCombination = new WordCount();

            Assert.AreEqual("Please enter a word AND sentence", newCombination.FieldCheck("", "How was your day?"));
        }
Esempio n. 30
0
        public void IsWordCounter_HowManyKitten_PleaseReEnter()
        {
            WordCount newCombination = new WordCount();

            Assert.AreEqual(0, newCombination.RepeatCounter("kitten", "Puppies are very energetic and cute"));
        }