Esempio n. 1
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());
        }
        public void WordCount_ReturnTwo()
        {
            //Arrange
            string        newWord     = "GaMe";
            string        newSentence = "Let's play a GAME, called monopoly game.";
            RepeatCounter newCheck    = new RepeatCounter(newWord, newSentence);
            int           result      = 2;
            //Act
            int expectedResult = newCheck.GetWordCount();

            //Assert
            Assert.AreEqual(result, expectedResult);
        }
Esempio n. 3
0
        public void CheckSplitPhrase_ReturnNumberOfMatches_Int()
        {
            //Arrange
            string        testWord    = "The";
            string        testPhrase  = "The Cat walked down THe street to THE store.";
            RepeatCounter testCounter = new RepeatCounter();

            //Act
            int result = testCounter.CheckSplitPhrase(testWord, testPhrase);

            //Assert
            Assert.AreEqual(3, result);
        }
        public void WordCount_ReturnOne()
        {
            //Arrange
            string        newWord     = "GAME";
            string        newSentence = "Let's play a game.";
            RepeatCounter newCheck    = new RepeatCounter(newWord, newSentence);
            int           result      = 1;
            //Act
            int expectedResult = newCheck.GetWordCount();

            //Assert
            Assert.AreEqual(result, expectedResult);
        }
Esempio n. 5
0
        public void TestSplitChars_ReturnFinalResult_Int()
        {
            //Arrange
            string        testWord    = "the";
            string        testPhrase  = "The,!! #cat@()cat (the),.the?CAT!";
            RepeatCounter testCounter = new RepeatCounter();

            //Act
            int result = testCounter.RunCounter(testWord, testPhrase);

            //Assert
            Assert.AreEqual(3, result);
        }
Esempio n. 6
0
        public void RunRepeatCounter_ReturnFinalResult_Int()
        {
            //Arrange
            string        testWord    = "The";
            string        testPhrase  = "The Cat walked down THe street to THE store.";
            RepeatCounter testCounter = new RepeatCounter();

            //Act
            int result = testCounter.RunCounter(testWord, testPhrase);

            //Assert
            Assert.AreEqual(3, result);
        }
Esempio n. 7
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());
        }
Esempio n. 8
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());
        }
        public void SetWord_SetsWord_Void()
        {
            // Arrange
            string        word             = "basketball";
            RepeatCounter newRepeatCounter = new RepeatCounter(word, "");
            // Act
            string newWord = "basketball";

            newRepeatCounter.SetWord(newWord);
            string result = newRepeatCounter.GetWord();

            // Assert
            Assert.AreEqual(newWord, result);
        }
        public void GetIndexFromArray_ReturnIndex_String()
        {
            //Arrange
            RepeatCounter newRepeatCounter = new RepeatCounter("dog", "cat and dog");

            //Act
            string paragraph = newRepeatCounter.GetParaGraph();

            string[] result = newRepeatCounter.StringToArray();
            string[] blah   = paragraph.Split(' ');

            //Assert
            CollectionAssert.AreEqual(blah, result);
        }
Esempio n. 11
0
        public void GetMessage_FetchTheMessage_String()
        {
            //arrange
            string        controlMessage = "Please enter one word per Word Box! Click 'Add another word' to count more words";
            RepeatCounter newCounter     = new RepeatCounter("cat cat", "There is a cat over there.");

            newCounter.IsValid();

            //act
            string result = newCounter.GetMessage();

            //assert
            Assert.AreEqual(result, controlMessage);
        }
Esempio n. 12
0
        public void CountWords_FindMultiMatches_2()
        {
            // Arrange
            string        word     = "is";
            string        sentence = "This is a test sentence. It is just for testing.";
            int           count    = 2;
            RepeatCounter counter  = new RepeatCounter(word, sentence);

            // Act
            int result = counter.CountWords();

            // Assert
            Assert.AreEqual(count, result);
        }
Esempio n. 13
0
        public void CountWords_CatchPluralWordWithApostrophe_1()
        {
            // Arrange
            string        word     = "Jason";
            string        sentence = "This is a Jason's final test.";
            int           count    = 1;
            RepeatCounter counter  = new RepeatCounter(word, sentence);

            // Act
            int result = counter.CountWords();

            // Assert
            Assert.AreEqual(count, result);
        }
Esempio n. 14
0
        public void CountWords_FindNoMatches_0()
        {
            // Arrange
            string        word     = "I";
            string        sentence = "This is a test sentence.";
            int           count    = 0;
            RepeatCounter counter  = new RepeatCounter(word, sentence);

            // Act
            int result = counter.CountWords();

            // Assert
            Assert.AreEqual(count, result);
        }
        public void RepeatCounter_WordSymbolRemoverPeriod_Hello()
        {
            // Arrange
            RepeatCounter newRepeatCounter = new RepeatCounter();

            // Act
            newRepeatCounter.SetWordAndSentence("Hello.", "Hello World");
            newRepeatCounter.WordSymbolRemover();
            newRepeatCounter.FindMatch();
            int result = newRepeatCounter.Count;

            // Assert
            Assert.AreEqual(result, 1);
        }
        public void WordInSentence_WordInSentence_1()
        {
            //Arrange
            WordSentence  newWordSentence  = new WordSentence("coffee", "I like coffee");
            string        wordInput        = newWordSentence.GetWord();
            string        sentenceInput    = newWordSentence.GetSentence();
            RepeatCounter newRepeatCounter = new RepeatCounter(wordInput, sentenceInput);

            //Act
            int result = newRepeatCounter.WordInSentence();

            //Assert
            Assert.AreEqual(1, result);
        }
Esempio n. 17
0
        public void RemovePunctuation_RemovePunctuation_StringList()
        {
            //arrange
            RepeatCounter newRepeatCounter = new RepeatCounter("food", "The girl, likes the food.");
            //action
            List <string> result           = newRepeatCounter.RemovePunctuation();
            List <string> comparisonResult = new List <string>()
            {
                "The", "girl", "likes", "the", "food"
            };

            //assert
            CollectionAssert.AreEqual(comparisonResult, result);
        }
        public void RepeatCounter_AllSymbolRemover_HelloWorld()
        {
            // Arrange
            RepeatCounter newRepeatCounter = new RepeatCounter();

            // Act
            newRepeatCounter.SetWordAndSentence("World,", "Hello World.");
            newRepeatCounter.AllSymbolRemover();
            newRepeatCounter.FindMatch();
            int result = newRepeatCounter.Count;

            // Assert
            Assert.AreEqual(result, 1);
        }
Esempio n. 19
0
        public void CountWords_CatchPluralWord_1()
        {
            // Arrange
            string        word     = "test";
            string        sentence = "This is a test sentence, it tests sentences.";
            int           count    = 2;
            RepeatCounter counter  = new RepeatCounter(word, sentence);

            // Act
            int result = counter.CountWords();

            // Assert
            Assert.AreEqual(count, result);
        }
        public void RepeatCounter_SetWordAndSentence_HelloHelloWorld()
        {
            // Arrange
            RepeatCounter newRepeatCounter = new RepeatCounter();

            // Act
            newRepeatCounter.SetWordAndSentence("Hello", "Hello World");
            string resultWord     = newRepeatCounter.Word;
            string resultSentence = newRepeatCounter.Sentence;

            // Assert
            Assert.AreEqual(resultWord, "hello");
            Assert.AreEqual(resultSentence, "hello world");
        }
Esempio n. 21
0
        public void CountWords_FindMultiCharacterWord_1()
        {
            // Arrange
            string        word     = "test";
            string        sentence = "This is a test sentence.";
            int           count    = 1;
            RepeatCounter counter  = new RepeatCounter(word, sentence);

            // Act
            int result = counter.CountWords();

            // Assert
            Assert.AreEqual(count, result);
        }
        public void RepeatCounter_SetWordAndSentence_NonLetterChars()
        {
            // Arrange
            RepeatCounter newRepeatCounter = new RepeatCounter();

            // Act
            newRepeatCounter.SetWordAndSentence("!@#$", "!@#$ %^&*");
            string resultWord     = newRepeatCounter.Word;
            string resultSentence = newRepeatCounter.Sentence;

            // Assert
            Assert.AreEqual(resultWord, "!@#$");
            Assert.AreEqual(resultSentence, "!@#$ %^&*");
        }
Esempio n. 23
0
        public void CountWords_IgnorePartialMatch_1()
        {
            // Arrange
            string        word     = "test";
            string        sentence = "This is a test sentence. It is just for testing.";
            int           count    = 1;
            RepeatCounter counter  = new RepeatCounter(word, sentence);

            // Act
            int result = counter.CountWords();

            // Assert
            Assert.AreEqual(count, result);
        }
        public void RepeatCounter_RepeatCounterConstructor_NewRepeatCounter()
        {
            // Arrange
            RepeatCounter newRepeatCounter = new RepeatCounter();
            // Act
            int    resultCount    = newRepeatCounter.Count;
            string resultWord     = newRepeatCounter.Word;
            string resultSentence = newRepeatCounter.Sentence;

            // Assert
            Assert.AreEqual(resultCount, 0);
            Assert.AreEqual(resultWord, "");
            Assert.AreEqual(resultSentence, "");
        }
Esempio n. 25
0
        public void ValidateTargetWord_RejectsSpaces_False()
        {
            //Arrange
            RepeatCounter newRepeatCounter = new RepeatCounter("can not");

            //Act
            bool   result = newRepeatCounter.ValidateTargetWord();
            string pos    = newRepeatCounter.GetTargetWord();

            Console.WriteLine(pos[3]);

            //Assert
            Assert.AreEqual(false, result);
        }
        public void WordInSentence_CountWordsInSentence_Int()
        {
            //Arrange
            WordSentence  newWordSentence  = new WordSentence("car", "My car is faster than your car");
            string        wordInput        = newWordSentence.GetWord();
            string        sentenceInput    = newWordSentence.GetSentence();
            RepeatCounter newRepeatCounter = new RepeatCounter(wordInput, sentenceInput);

            //Act
            int result = newRepeatCounter.WordInSentence();

            //Assert
            Assert.AreEqual(2, result);
        }
Esempio n. 27
0
        public void GetUserWordAndSentence_GetWordAndSentenceFromUser_String()
        {
            //Arrange
            string        word      = "car";
            string        sentence  = "I need to buy a new car.";
            RepeatCounter userInput = new RepeatCounter(word, sentence);
            //Act
            string userWord     = userInput.GetUserWord();
            string userSentence = userInput.GetUserSentence();

            //Assert
            Assert.AreEqual(word, userWord);
            Assert.AreEqual(sentence, userSentence);
        }
        public void WordInSentence_CountsWordsByPunctuation_Int()
        {
            //Arrange
            WordSentence  newWordSentence  = new WordSentence("hungry", "Are you Hungry??");
            string        wordInput        = newWordSentence.GetWord();
            string        sentenceInput    = newWordSentence.GetSentence();
            RepeatCounter newRepeatCounter = new RepeatCounter(wordInput, sentenceInput);

            //Act
            int result = newRepeatCounter.WordInSentence();

            //Assert
            Assert.AreEqual(1, result);
        }
        public void SetSentence_SetsSentence_Void()
        {
            // Arrange
            string        sentence         = "I like basketball.";
            RepeatCounter newRepeatCounter = new RepeatCounter("", sentence);
            // Act
            string newSentence = "I like to eat.";

            newRepeatCounter.SetSentence(newSentence);
            string result = newRepeatCounter.GetSentence();

            // Assert
            Assert.AreEqual(newSentence, result);
        }
        public void WordInSentence_DoNotCountWordsContainedInWords_Int()
        {
            //Arrange
            WordSentence  newWordSentence  = new WordSentence("read", "Are you ready??");
            string        wordInput        = newWordSentence.GetWord();
            string        sentenceInput    = newWordSentence.GetSentence();
            RepeatCounter newRepeatCounter = new RepeatCounter(wordInput, sentenceInput);

            //Act
            int result = newRepeatCounter.WordInSentence();

            //Assert
            Assert.AreEqual(0, result);
        }