예제 #1
0
        public void RepeatCounter_CalculatesZeroWhenNoMatch_Int()
        {
            string        sent        = "There is a rat over there";
            string        word        = "than";
            RepeatCounter testCounter = new RepeatCounter(sent, word);

            Assert.AreEqual(0, testCounter.GetCount());
        }
예제 #2
0
        public void RepeatCounter_DoesntCountPartialMatches_Int()
        {
            string        sent        = "There is a ratrat rat rat over there";
            string        word        = "rat";
            RepeatCounter testCounter = new RepeatCounter(sent, word);

            Assert.AreEqual(2, testCounter.GetCount());
        }
예제 #3
0
        public void RepeatCounter_PropertiesAreSet_StringStringInt()
        {
            string        sent        = "There is a rat over there";
            string        word        = "there";
            RepeatCounter testCounter = new RepeatCounter(sent, word);

            Assert.AreEqual(sent, testCounter.Sentence);
            Assert.AreEqual(word, testCounter.Word);
            Assert.AreEqual(2, testCounter.GetCount());
        }
예제 #4
0
        public void SetCount_HandlePunctuation_Void()
        {
            //arrange
            int           controlCount = 2;
            RepeatCounter newCounter   = new RepeatCounter("cat", "There is a Cat over there. It is a big cat.");

            //act
            newCounter.SetCount();

            //assert
            Assert.AreEqual(controlCount, newCounter.GetCount());
        }
예제 #5
0
        public void CountWord3()
        {
            //Arrange
            string        firstWord     = "Fish";
            string        enterSentence = "Fish Fish Fish in the sea Fishery";
            int           outPut        = 3;
            RepeatCounter wordCount     = new RepeatCounter(firstWord, enterSentence);

            //Act
            wordCount.CountWord();
            //Assert
            Assert.AreEqual(outPut, wordCount.GetCount());
        }
예제 #6
0
        public void CountWord2()
        {
            //Arrange
            string        firstWord     = "Pig";
            string        enterSentence = "Two little Pig Pig in the barn";
            int           outPut        = 2;
            RepeatCounter wordCount     = new RepeatCounter(firstWord, enterSentence);

            //Act
            wordCount.CountWord();
            //Assert
            Assert.AreEqual(outPut, wordCount.GetCount());
        }
예제 #7
0
        public void CountWord()
        {
            //Arrange
            string        firstWord     = "Salmon";
            string        enterSentence = "Salmon";
            int           outPut        = 1;
            RepeatCounter wordCount     = new RepeatCounter(firstWord, enterSentence);

            //Act
            wordCount.CountWord();
            //Assert
            Assert.AreEqual(outPut, wordCount.GetCount());
        }
예제 #8
0
        public void CountWordFrequency5_ReturnFrequencyOfWordInSentence()
        {
            // arrange
            string        word          = "chocolate";
            string        sentence      = "I love chocolate, chocolate ice cream, chocolate candy bar, and anything chocolate";
            int           count         = 4;
            RepeatCounter repeatCounter = new RepeatCounter(word, sentence);


            // act
            int expectedResult = repeatCounter.GetCount();

            // assert
            Assert.AreEqual(count, expectedResult);
        }
예제 #9
0
        public void CountWordFrequency4_ReturnFrequencyOfWordInSentence()
        {
            // arrange
            string        word          = "he";
            string        sentence      = "He is over there";
            int           count         = 1;
            RepeatCounter repeatCounter = new RepeatCounter(word, sentence);


            // act
            int expectedResult = repeatCounter.GetCount();

            // assert
            Assert.AreEqual(count, expectedResult);
        }
예제 #10
0
        public void CountWordFrequency3_ReturnFrequencyOfWordInSentence()
        {
            // arrange
            string        word          = "I";
            string        sentence      = "I am what i eat";
            int           count         = 2;
            RepeatCounter repeatCounter = new RepeatCounter(word, sentence);


            // act
            int expectedResult = repeatCounter.GetCount();

            // assert
            Assert.AreEqual(count, expectedResult);
        }
예제 #11
0
        public void SetValues_SetWordSentenceAndCount_Void()
        {
            //arrange
            string        newWord     = "small";
            string        newSentence = "There is a small cat over there.";
            int           newCount    = 1;
            RepeatCounter newCounter  = new RepeatCounter("cat", "There is a cat over there. It is a big cat that I will pet.");

            //act
            newCounter.SetWord(newWord);
            newCounter.SetSentence(newSentence);
            newCounter.SetCount();

            //assert
            Assert.AreEqual(newWord, newCounter.GetWord());
            Assert.AreEqual(newSentence, newCounter.GetSentence());
            Assert.AreEqual(newCount, newCounter.GetCount());
        }
예제 #12
0
        public void GetValues_FetchWordSentenceAndCount_String()
        {
            //arrange
            string        controlWord     = "cat";
            string        controlSentence = "There is a cat over there. It is a big cat that I will pet.";
            int           controlCount    = 2;
            RepeatCounter newCounter      = new RepeatCounter("cat", "There is a cat over there. It is a big cat that I will pet.");

            newCounter.SetCount();

            //act
            string wordResult     = newCounter.GetWord();
            string sentenceResult = newCounter.GetSentence();
            int    countResult    = newCounter.GetCount();

            //assert
            Assert.AreEqual(wordResult, controlWord);
            Assert.AreEqual(sentenceResult, controlSentence);
            Assert.AreEqual(countResult, controlCount);
        }