static void Main() { Console.WriteLine("Type a Word. eg: 'Hello' "); string inputWord = Console.ReadLine(); Console.WriteLine("Type a Sentence eg: 'Hello World' "); string inputSentence = Console.ReadLine(); RepeatWord newWord = new RepeatWord(inputWord, inputSentence); Regex regex = new Regex(@"^[0-9]+$"); Match wordMatch = regex.Match(inputWord); Match sentenceMatch = regex.Match(inputSentence); int repeats = newWord.CountRepetedWord(); if (wordMatch.Success || sentenceMatch.Success) { Console.WriteLine("Invalid Input. Please type a Word or Sentence"); Main(); } else if (inputWord.Contains(" ")) { Console.WriteLine("You can only search for One Word"); Main(); } else { Console.WriteLine("Number of match availabe " + repeats); } }
public void RepearWord_AppearsWithCaps() { RepeatWord newWord = new RepeatWord("A", "A A c aa Aa A"); int expected = 3; int actual = newWord.WordCount(); Assert.AreEqual(expected, actual); }
public void RepearWord_AppearsTwice() { RepeatWord newWord = new RepeatWord("a", "a a c"); int expected = 2; int actual = newWord.WordCount(); Assert.AreEqual(expected, actual); }
public void RepeatWord_AppearsOneTime() { RepeatWord newWord = new RepeatWord("a", "a b"); int expected = 1; int actual = newWord.WordCount(); Assert.AreEqual(expected, actual); }
public void RepeatWord_DoesntAppear_0() { RepeatWord newWord = new RepeatWord("a", "c"); int expected = 0; int actual = newWord.WordCount(); Assert.AreEqual(expected, actual); }
public void MatchingWords_Words_String() { string input = "hello World"; RepeatWord newWord = new RepeatWord(); newWord.GetWordInput(input); string output = newWord.FindWordAndSetIt(); Assert.AreEqual(output, input); }
public void InputtedSentence_Senetence_String() { string input = "hello World"; RepeatWord newWord = new RepeatWord(); newWord.SearchingForSentence(input); string output = newWord.GetUserSentence(); Assert.AreEqual(output, input); }
public void CountNoRepeatedWord_DecreaseCount_Int() { string word = "hello"; string sentence = "World is beautiful"; RepeatWord newWord = new RepeatWord(); newWord.GetWordInput(word); newWord.SearchingForSentence(sentence); newWord.GetUserSentence(); int result = newWord.CountRepetedWord(); Assert.AreEqual(result, 0); }
public ActionResult Results() { RepeatWord newWord = new RepeatWord(Request.Form["inputWord"], Request.Form["inputSentence"]); string Word = newWord.GetWord(); string Sentence = newWord.GetSentence(); int repeats = newWord.WordCount(); string Repeats = repeats.ToString(); Dictionary <string, string> WordCount = new Dictionary <string, string> () { { "Word", Word }, { "Sentence", Sentence }, { "Repeats", Repeats } }; return(View(newWord)); }
public IActionResult RepeatWordResult(RepeatWord repeatWord) { return(View(repeatWord)); }
public void FirstRepeat_returns_first_repeated_word(string expected, string val) { var words = new RepeatWord(val); Assert.Equal(expected, words.FirstWord()); }