Ejemplo 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);
        }
Ejemplo 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());
        }
Ejemplo n.º 3
0
        GetNumberOfMatches_ChecksWordAgainstSentenceContainingOneMatchThatIsSurroundedByWhiteSpaceReturnsOne_1()
        {
            string word     = "cat";
            string sentence = "Only a cat in this sentence.";

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

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

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

            Assert.AreEqual(1, matchCount);
        }
Ejemplo n.º 5
0
        GetNumberOfMatches_ChecksWordAgainstSentenceContainingOneMatchWithPunctuationFollowingTheWord_1()
        {
            string word     = "cat";
            string sentence = "A cat.";

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

            Assert.AreEqual(1, matchCount);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        GetNumberOfMatches_ChecksWordAgainstSentenceContainingNoMatchesReturnsZero_0()
        {
            string word     = "cat";
            string sentence = "Only a dog in this sentence.";

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

            Assert.AreEqual(0, matchCount);
        }
Ejemplo 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());
        }
Ejemplo 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());
        }
Ejemplo 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());
        }
Ejemplo 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());
        }
Ejemplo 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());
        }
Ejemplo 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());
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo n.º 22
0
        public void DoesClassInstantiate_InstantitionSuccessful_NewObj()
        {
            WordCount testCounter = new WordCount();

            Assert.AreEqual(typeof(WordCount), testCounter.GetType());
        }
Ejemplo 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);
        }
Ejemplo n.º 25
0
        public void IsWordCounter_HowManyThe_PleaseReEnter()
        {
            WordCount newCombination = new WordCount();

            Assert.AreEqual(2, newCombination.RepeatCounter("the", "The fox and the hound"));
        }
Ejemplo 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());
        }
Ejemplo 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());
        }
Ejemplo 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?"));
        }
Ejemplo n.º 30
0
        public void IsWordCounter_HowManyKitten_PleaseReEnter()
        {
            WordCount newCombination = new WordCount();

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