// test to see if the program can grab the target word input from the user successfully public void RepeatCounterConstructor_GetSetTargetWord_TargetWord() { // Arrange string newLongString = "This is a string"; string newTargetWord = "string"; RepeatCounter newRepeatCounter = new RepeatCounter(newLongString); // Act newRepeatCounter.SetTargetWord(newTargetWord); // Assert Assert.Equal(newTargetWord, newRepeatCounter.GetTargetWord()); }
// test if the program can return the number of times a word appears in a string public void FindWord_CountInstances_Count() { // Arrange string newLongString = "This is a string"; string newTargetWord = "string"; RepeatCounter newRepeatCounter = new RepeatCounter(newLongString); newRepeatCounter.SetTargetWord(newTargetWord); newRepeatCounter.StringSplitter(); // Act newRepeatCounter.FindWord(); // Assert Assert.Equal(1, newRepeatCounter.GetWordCount()); }
// test if the program can find the target word in a large number of words public void FindWord_AllCheck_Bool() { // Arrange string newLongString = "This is a string"; string newTargetWord = "string"; RepeatCounter newRepeatCounter = new RepeatCounter(newLongString); newRepeatCounter.SetTargetWord(newTargetWord); newRepeatCounter.StringSplitter(); // Act bool testResult = newRepeatCounter.FindWord(); // Assert Assert.Equal(true, testResult); }
// test if the program can check target word against others, for true result public void CheckWord_SingleCheck_True() { // Arrange string newLongString = "This is a string"; string newTargetWord = "string"; RepeatCounter newRepeatCounter = new RepeatCounter(newLongString); newRepeatCounter.SetTargetWord(newTargetWord); newRepeatCounter.StringSplitter(); // Act bool testResult = newRepeatCounter.CheckWord(newRepeatCounter.GetArrayOfWords()[3]); // Assert Assert.Equal(true, testResult); }