public HomeModule() { Get["/"] = _ =>{ return View["index.cshtml"]; }; Post["/results"] = _ =>{ RepeatCounter newRepeatCounter = new RepeatCounter(Request.Form["string-input"], Request.Form["word-input"]); return View["/result.cshtml", newRepeatCounter]; }; }
public void OccurrenceCounter_ResultIsCaseInsensitive_Int() { // Arrange string userWord = "cat"; string userPhrase = "My cat Cat is going to the cathedral"; RepeatCounter newCounter = new RepeatCounter(userWord, userPhrase); // Act int occurrences = newCounter.OccurrenceCounter(); // Assert Assert.AreEqual(2, occurrences); }
public void OccurrenceCounter_PartialMatchesArentCounted_Int() { // Arrange string userWord = "cat"; string userPhrase = "My cat is going to the cathedral."; RepeatCounter newCounter = new RepeatCounter(userWord, userPhrase); // Act int occurrences = newCounter.OccurrenceCounter(); // Assert Assert.AreEqual(1, occurrences); }
public void OccurrenceCounter_CountNumberOfWordOccurences_Int() { // Arrange string userWord = "world"; string userPhrase = "Hello world"; RepeatCounter newCounter = new RepeatCounter(userWord, userPhrase); // Act int occurrences = newCounter.OccurrenceCounter(); // Assert Assert.AreEqual(1, occurrences); }
public void InputChecker_ChecksForCorrectUserUnput_True() { // Arrange string userWord = "world"; string userPhrase = "Hello world"; RepeatCounter newCounter = new RepeatCounter(userWord, userPhrase); // Act bool correctInput = newCounter.InputChecker(); // Assert Assert.AreEqual(true, correctInput); }
public void InputText_ReturnText_True() { //Arrange string word = "hello"; string text = "hello world"; RepeatCounter newRepeatCounter = new RepeatCounter(word, text); //Act string compare = newRepeatCounter.GetText(); //Assert Assert.AreEqual(text, compare); }
public ActionResult Create(string wordInput, string sentenceInput) { if (wordInput != null && sentenceInput != null) { RepeatCounter newCounter = new RepeatCounter(wordInput, sentenceInput); List <RepeatCounter> allRepeatCounters = RepeatCounter.GetAll(); return(View("Index", allRepeatCounters)); } else { return(View("New")); } }
public void GetRepeatCount_ReturnNumberOfRepeats_True() { RepeatCounter.SetUserWord("cat"); RepeatCounter.SetUserSentence("The cat is larger than a caterpillar."); Assert.AreEqual(1, RepeatCounter.GetRepeatCount()); RepeatCounter.SetUserWord("a"); RepeatCounter.SetUserSentence(""); Assert.AreEqual(0, RepeatCounter.GetRepeatCount()); RepeatCounter.SetUserWord("an"); RepeatCounter.SetUserSentence("anna and annette the ant android are an awesome pair"); Assert.AreEqual(1, RepeatCounter.GetRepeatCount()); }
public void CreateSearchedStringList_ReturnCleanList_List() { //Arrange RepeatCounter newRepeatCounter = new RepeatCounter("Hello, hello!", "goodbye"); //Act newRepeatCounter.CreateSearchedStringList(); List <string> newList = new List <string> { "hello", "hello" }; //Assert CollectionAssert.AreEqual(newList, newRepeatCounter.GetWordsList()); }
public void CountRepeats_CountWordsDespiteCase_True() { //Arrange int expectedValue = 2; string originalString = "Cat toys include cat nip"; string originalWord = "cat"; RepeatCounter newCounter = new RepeatCounter(originalWord, originalString); //Act int actualValue = newCounter.CountRepeats(); //Assert Assert.AreEqual(expectedValue, actualValue); }
public void CountRepeats_CountMultipleInstancesOfWord_True() { //Arrange int expectedValue = 2; string originalString = "The cat that I like the most is Callie cat"; string originalWord = "cat"; RepeatCounter newCounter = new RepeatCounter(originalWord, originalString); //Act int actualValue = newCounter.CountRepeats(); //Assert Assert.AreEqual(expectedValue, actualValue); }
public void TestPass() { string testingOne = "Good"; string testingTwo = "Bye"; RepeatCounter newTest = new RepeatCounter(testingOne, testingTwo); string totalWord = newTest.GetWord(); string totalString = newTest.GetString(); int total = newTest.WordTotal(); Assert.AreEqual(testingOne, totalWord); Assert.AreEqual(testingTwo, totalString); Assert.AreEqual(0, total); }
public void CheckingGetW() { //Arrange string test_W = "Hello"; string test_S = "Epicodus"; RepeatCounter newTest = new RepeatCounter(test_W, test_S); //Act string total_W = newTest.GetWord(); string total_S = newTest.GetString(); //Assert Assert.AreEqual(test_W, total_W); Assert.AreEqual(test_S, total_S); }
public void ValidateInput_ValidateCatInputLength_List() { string inputString = "cat"; List <string> correctList = new List <string> { "cat" }; List <string> inputList = new List <string> { }; string[] inputArray = { "cat", "kitty" }; RepeatCounter.ValidateInput(inputArray, inputString); inputList = RepeatCounter.ListOfWordsToCompare; CollectionAssert.AreEqual(correctList, inputList); }
public void GetInputs_SetWordAndSentence_True() { //Arrange string word = "Pizza"; string sentence = "pizza, Pizza, PIZZA"; RepeatCounter testCounter = new RepeatCounter(word, sentence); //Act string testString = word + sentence; string result = testCounter.GetWord() + testCounter.GetSentence(); //Assert Assert.AreEqual(testString, result); }
public ActionResult Create(string word, string sentence) { RepeatCounter myCounter = new RepeatCounter(word, sentence); bool isValid = myCounter.IsEmpty(); if (isValid) { return(View("Index", myCounter)); } else { return(View()); } }
public void SeperateWordsFindsmultipleWordsWithCapitals_False() { //assign RepeatCounter newWord = new RepeatCounter("LiKE"); newWord.SetSentence("the girl was liKE , omg like thats crazy, LIKe crazy. Like omg"); //act string result = newWord.GetWord(); string number = newWord.SearchWord(); //Assert Assert.AreEqual(number, "3"); }
public void SplitCompareString_ReturnStringArray_String() { //Arrange string testPhrase = "The cat is walking"; RepeatCounter testCounter = new RepeatCounter(); //Act testCounter.SetSplitCompareString(testPhrase); string[] resultArray = testCounter.GetComparePhrase(); //Assert Assert.AreEqual(4, resultArray.Length); }
public void SetTargetWord_SetNewTargetWord_String() { //Arrange RepeatCounter testCounter = new RepeatCounter(); //Act string newTestTarget = "cat"; testCounter.SetTargetWord(newTestTarget); string result = testCounter.GetTargetWord(); //Assert Assert.AreEqual(newTestTarget, result); }
public void SeperateWordsActuallyWorks_True() { //assign RepeatCounter newWord = new RepeatCounter("buddy"); newWord.SetSentence("Hello buddy"); //act string result = newWord.GetWord(); string number = newWord.SearchWord(); //Assert Assert.AreEqual(number, "1"); }
public void SeperateWordsFindsmultipleWords_True() { //assign RepeatCounter newWord = new RepeatCounter("dude"); newWord.SetSentence("The dude walks like a dude"); //act string result = newWord.GetWord(); string number = newWord.SearchWord(); //Assert Assert.AreEqual(number, "2"); }
public void CountRepeats_countsRegardlessofCap_three() { //arrange string sentence = "this is a Sentence sentEnce is it a sentence"; string word = "senteNce"; int expectedResult = 3; RepeatCounter newCounter = new RepeatCounter(sentence, word); //act int result = newCounter.CountRepeats(); //assert Assert.Equal(expectedResult, result); }
public void CountRepeats_howManyTimesdoesSentenceHaveWord_three() { //arrange string sentence = "this is a sentence sentence is it a sentence"; string word = "sentence"; int expectedResult = 3; RepeatCounter newCounter = new RepeatCounter(sentence, word); //act int result = newCounter.CountRepeats(); //assert Assert.Equal(expectedResult, result); }
public void containsWord_doesSentenceHaveWord_true() { //arrange string sentence = "this is a sentence"; string word = "sentence"; bool expectedResult = true; RepeatCounter newCounter = new RepeatCounter(sentence, word); //act bool result = newCounter.ContainsWord(); //assert Assert.Equal(expectedResult, result); }
public void GetWord_returnUserWord_sameWord() { //arrange string sentence = "this is a sentence"; string word = "sentence"; string returnWord = "sentence"; RepeatCounter newCounter = new RepeatCounter(sentence, word); //act string result = newCounter.GetWord(); //assert Assert.Equal(returnWord, result); }
public void CreateStringArray_SplitsAtAllDesignatedCharacters_True() { //Assign RepeatCounter newCount = new RepeatCounter("hello", "q,w.e:r!t?y\"u'i;o-p_a/s\\d@f#g$h%j^k&l*z(x)c[v]b{n}m+q=w<e>r0t1y2u3i4o5p6a7s8d9f`g~h"); string[] expected = { "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "a", "s", "d", "f", "g", "h", "j", "k", "l", "z", "x", "c","v", "b", "n", "m", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "a", "s", "d", "f","g", "h" }; //Act string[] result = newCount.CreateStringArray(); bool evaluate = result.SequenceEqual(expected); //Assert Assert.AreEqual(true, evaluate); }
public void CheckSplitPhrase_ReturnNumberOfMatches_Int() { //Arrange string testWord = "The"; string testPhrase = "The Cat walked down THe street to THE store."; RepeatCounter testCounter = new RepeatCounter(); testCounter.SetTargetWord(testWord); testCounter.SetSplitCompareString(testPhrase); //Act int result = testCounter.CheckSplitPhrase(); //Assert Assert.AreEqual(3, result); }
public void SetTargetWord_SetNewTargetWordToLower_String() { //Arrange //string testTarget = "the"; RepeatCounter testCounter = new RepeatCounter(); //Act string newTestTarget = "CAT"; testCounter.SetTargetWord(newTestTarget); string result = testCounter.GetTargetWord(); //Assert Assert.AreEqual("cat", result); }
public void SavesGetsListOfWords_SavesReturnsListOfWords_List() { string test01 = "cat"; string test02 = "dog"; RepeatCounter save01 = new RepeatCounter(test01); RepeatCounter save02 = new RepeatCounter(test02); save01.Save(); save02.Save(); List <RepeatCounter> testList = new List <RepeatCounter> { save01, save02 }; CollectionAssert.AreEqual(testList, RepeatCounter.GetAll()); }
public ActionResult WordCounter() { RepeatCounter userInput = new RepeatCounter(Request.Form["wordInput"], Request.Form["sentenceInput"]); string Word = userInput.GetWord(); string Sentence = userInput.GetSentence(); int repeats = userInput.CountRepeats(); string Repeats = repeats.ToString(); Dictionary <string, string> WordCount = new Dictionary <string, string> () { { "Word", Word }, { "Sentence", Sentence }, { "Repeats", Repeats } }; return(View(WordCount)); }
private static string GetSentenceInput() { RepeatCounter tester = new RepeatCounter(); Console.WriteLine("Enter a sentence to search for matches."); string sentenceInput = Console.ReadLine(); if (tester.CheckIfEmpty(sentenceInput)) { Console.WriteLine("Empty sentence to search not valid. Please try again."); Console.WriteLine("-=x=-=x=-=x=-=x=-=x=-=x=-=x=-=x=-=x=-=x=-=x=-=x=-=x=-=x=-=x=-"); sentenceInput = GetSentenceInput(); } return(sentenceInput); }