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];
        };
    }
        public void Test1_RepeatCounterGetA_true()
        {
            //arrange
            string word = "a";
            RepeatCounter checkNewWord = new RepeatCounter(word,"");

            //act.....
            string checkWord = checkNewWord.GetWord();

            //Assert
            Assert.Equal(word, checkWord);

            // Test2_RepeatCounterGetThe_true()
              //
        }
Esempio n. 3
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);
 }