Esempio n. 1
0
    public HomeModule()
    {
        Get["/"] = _ =>
        {
          return View["index.html"];
        };

        Post["/result"] = _ =>
        {
          RepeatCounter formRepeatCounter = new RepeatCounter(Request.Form["input-word"], Request.Form["input-list"]);
          string firstString = formRepeatCounter.GetStringOfWords();
          string cleanString = formRepeatCounter.RemovePunctuation(firstString);
          string findWord = formRepeatCounter.GetWord();
          int countWords = formRepeatCounter.CountRepeats(findWord, cleanString);
          return View["result.cshtml", formRepeatCounter];
        };

        Post["/warandpeace"] = _ =>
        {
          RepeatCounter wapRepeatCounter = new RepeatCounter(Request.Form["input-word"], Request.Form["input-word"]);
          string readWarAndPeace = wapRepeatCounter.ReadAFile();
          wapRepeatCounter.SetStringOfWords(readWarAndPeace);
          string firstString = wapRepeatCounter.GetStringOfWords();
          string cleanString = wapRepeatCounter.RemovePunctuation(firstString);
          string findWord = wapRepeatCounter.GetWord();
          int countWords = wapRepeatCounter.CountRepeats(findWord, cleanString);
          return View["warandpeace.cshtml", wapRepeatCounter];
        };
    }
Esempio n. 2
0
 public void RepeatCounter_CreatesARepeatCounterObjectWithTwoStrings_ReturnsValueOfTwoStrings()
 {
     // Arrange
       string testWord = "antelope";
       string testString = "An antelope is like a gazelle in a way but it begins with an A actually.";
       // Act
       RepeatCounter testRepeatCounter = new RepeatCounter(testWord, testString);
       string resultWord = testRepeatCounter.GetWord();
       string resultString = testRepeatCounter.GetStringOfWords();
       // Assert
       Console.WriteLine("Spec 1 expected: " + testWord + " Spec 1 actual: " + resultWord);
       Console.WriteLine("Spec 2 expected: " + testString + " Spec 2 actual: " + resultString);
       Assert.Equal(testWord, resultWord);
       Assert.Equal(testString, resultString);
 }