public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/results"] = _ => { return(View["results.cshtml"]); }; Get["/new"] = _ => { return(View["index.cshtml"]); }; Post["/results"] = _ => { Dictionary <string, string> newDictionary = new Dictionary <string, string>(); string userSentence = Request.Form["sentence"]; string userWord = Request.Form["word"]; RepeatCounter newCounter = new RepeatCounter(userSentence, userWord); int result = newCounter.CountRepeats(userSentence, userWord); newDictionary.Add("count", result.ToString()); newDictionary.Add("sentence", newCounter.GetSentence()); newDictionary.Add("word", newCounter.GetWord()); // int result = newCounter.CountRepeats(userSentence, userWord); return(View["results.cshtml", newDictionary]); }; }
public HomeModule() { Get["/"] = _ => View["index.cshtml"]; Post["/answer"] = _ => { RepeatCounter newCounter = new RepeatCounter(); int answer = newCounter.CountRepeats(Request.Form["look-word"], Request.Form["sentence"]); return(View["answer.cshtml", answer]); }; }
public void CountRepeats_wordMatchWithOtherWords_True() { //arrange RepeatCounter testObject = new RepeatCounter(); //act int answer = testObject.CountRepeats("zoo", "zoo was a very cool zoo"); //assert Assert.Equal(answer, 2); }
public void CountRepeats_wordMatch_True() { //arrange RepeatCounter testObject = new RepeatCounter(); //act int answer = testObject.CountRepeats("zoo", "zoo"); //assert Assert.Equal(answer, 1); }
public void CountRepeats_lettersDontMatch_True() { //arrange RepeatCounter testObject = new RepeatCounter(); //act int answer = testObject.CountRepeats("z", "y"); //assert Assert.Equal(answer, 0); }
public void CountRepeats_ReturnNumberOfTimesWordAppears_Int() { //arrange int expectedOutput = 1; string givenWord = "the"; string givenString = "Here rests the old oak tree"; //act RepeatCounter testCounter = new RepeatCounter(givenWord, givenString); //assert Assert.Equal(expectedOutput, testCounter.CountRepeats()); }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Post["/counted-words"] = _ => { RepeatCounter wordCount = new RepeatCounter(Request.Form["word"], Request.Form["text"]); int countedWords = wordCount.CountRepeats(); return(View["index.cshtml", countedWords]); }; }
public void CountRepeats_FindMatchesRegardlessOfPunctuation_Int() { //arrange int expectedOutput = 1; string givenWord = "man"; string givenString = "When the baby grows up to be an old man, they bury his body in the ground."; //act RepeatCounter testCounter = new RepeatCounter(givenWord, givenString); //assert Assert.Equal(expectedOutput, testCounter.CountRepeats()); }
public void CountRepeats_FindMatchesRegardlessOfExtraSpacesInWord_Int() { //arrange int expectedOutput = 1; string givenWord = "this "; string givenString = "This house is haunted"; //act RepeatCounter testCounter = new RepeatCounter(givenWord, givenString); //assert Assert.Equal(expectedOutput, testCounter.CountRepeats()); }
public void Test_CountLikeWordsInText_8() { //Arrange string inputWord = "buffalo"; string inputText = "The buffalo is large. Buffalo is my name. The buffalo is large. Buffalo is my name. The buffalo is large. Buffalo is my name. The buffalo is large. Buffalo is my name. Buffalo's Rock!"; //Act RepeatCounter testInput = new RepeatCounter(inputWord, inputText); int testResult = testInput.CountRepeats(); //Assert Assert.Equal(8, testResult); }
public void CountRepeats_MultiWordsMultiCount_two() { //Arrange string sentInput = "monkeys like to eat bananas for breakfast and bananas for dinner"; string wordInput = "bananas"; RepeatCounter newCounter = new RepeatCounter(sentInput, wordInput); //Act int result = newCounter.CountRepeats(sentInput, wordInput); //Assert Assert.Equal(2, result); }
public void CountRepeats_SingleWord_one() { //Arrange string sentInput = "bananas"; string wordInput = "bananas"; RepeatCounter newCounter = new RepeatCounter(sentInput, wordInput); //Act int result = newCounter.CountRepeats(sentInput, wordInput); //Assert Assert.Equal(1, result); }
public void CountRepeats_Punctuation_one() { //Arrange string sentInput = "monkeys like to eat bananas."; string wordInput = "Bananas"; RepeatCounter newCounter = new RepeatCounter(sentInput, wordInput); //Act int result = newCounter.CountRepeats(sentInput, wordInput); //Assert Assert.Equal(1, result); }
public void CountRepeats_MultiWordsCaseInsensitive_one() { //Arrange string sentInput = "monkeys like to eat bananas"; string wordInput = "Bananas"; RepeatCounter newCounter = new RepeatCounter(sentInput, wordInput); //Act int result = newCounter.CountRepeats(sentInput, wordInput); //Assert Assert.Equal(1, result); }
public void Test_StringEqual_1() { //Arrange string inputWord = "A"; string inputText = "A"; //ACT RepeatCounter testInput = new RepeatCounter(inputWord, inputText); int testResult = testInput.CountRepeats(); //Assert Assert.Equal(testResult, 1); }
public void CountRepeats_MultiWordsCloseMatchError_zero() { //Arrange string sentInput = "monkeys like to eat bananas"; string wordInput = "banana"; RepeatCounter newCounter = new RepeatCounter(sentInput, wordInput); //Act int result = newCounter.CountRepeats(sentInput, wordInput); //Assert Assert.Equal(0, result); }
public void Test_StringCompareEqualCaseless_1() { //Arrange string inputWord = "buffalo"; string inputText = "BuFFalO"; //Act RepeatCounter testInput = new RepeatCounter(inputWord, inputText); int testResult = testInput.CountRepeats(); //Assert Assert.Equal(testResult, 1); }