예제 #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];
        };
    }
예제 #2
0
        public void RepeatCounter_Test2_SplitInput2Sentence_returnArrayLength()
        {
            RepeatCounter newCountRepeats = new RepeatCounter("I", "I am who I am");

            //Assert
            Assert.Equal(2, newCountRepeats.CountRepeats());
        }
예제 #3
0
        public void Test6_RegognizeWordInSentence_true()
        {
            RepeatCounter checkNewWord = new RepeatCounter("the", "the blue jays rock");

              int result = checkNewWord.CountRepeats();

              Assert.Equal(1, result);
        }
예제 #4
0
        public void Test5_recognizesWordNotPresent_true()
        {
            RepeatCounter checkNewWord = new RepeatCounter("the", "blue jays rock");

              int result = checkNewWord.CountRepeats();

              Assert.Equal(0, result);
        }
예제 #5
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Post["/score"] = _ => {
         int Count = RepeatCounter.CountRepeats(Request.Form["word"], Request.Form["sentence"]);
         return(View["results.cshtml", Count]);
     };
 }
예제 #6
0
        public void Test2_LetterDontMatch_true()
        {
            //arrange
              RepeatCounter checkNewWord = new RepeatCounter("a", "b");
              //act
              int result = checkNewWord.CountRepeats();

              //Assert
              Assert.Equal(0, result);
        }
예제 #7
0
        public void Test1_RepeatCounterGetA_true()
        {
            //arrange
              RepeatCounter checkNewWord = new RepeatCounter("a", "a");
              //act
              int result = checkNewWord.CountRepeats();

              //Assert
              Assert.Equal(1, result);
        }
예제 #8
0
        public void CountRepeats_ForWordInStringIgnorePunctuation_wordcount()
        {
            string        userInputString   = "What's better than coding? Nothing is better than coding.";
            string        userInputWord     = "coding";
            RepeatCounter testRepeatCounter = new RepeatCounter(userInputString, userInputWord);
            int           result            = testRepeatCounter.CountRepeats();
            int           expectedResult    = 2;

            Assert.Equal(expectedResult, result);
        }
예제 #9
0
        public void CountRepeats_ForWordInStringCapitalized_wordcount()
        {
            string        userInputString   = "What's Better than coding? Nothing is BETTER than coding.";
            string        userInputWord     = "better";
            RepeatCounter testRepeatCounter = new RepeatCounter(userInputString, userInputWord);
            int           result            = testRepeatCounter.CountRepeats();
            int           expectedResult    = 2;

            Assert.Equal(expectedResult, result);
        }
예제 #10
0
        public void CountRepeats_ForWordInStringOnce_1()
        {
            string        userInputString   = "I love to code";
            string        userInputWord     = "code";
            RepeatCounter testRepeatCounter = new RepeatCounter(userInputString, userInputWord);
            int           result            = testRepeatCounter.CountRepeats();
            int           expectedResult    = 1;

            Assert.Equal(expectedResult, result);
        }
예제 #11
0
        public void CountRepeats_ForWordIsString_1()
        {
            string        userInputString   = "bananas";
            string        userInputWord     = "bananas";
            RepeatCounter testRepeatCounter = new RepeatCounter(userInputString, userInputWord);
            int           result            = testRepeatCounter.CountRepeats();
            int           expectedResult    = 1;

            Assert.Equal(expectedResult, result);
        }
예제 #12
0
        public void CountRepeats_ForWordNotInString_0()
        {
            string        userInputString   = "I love to code";
            string        userInputWord     = "program";
            RepeatCounter testRepeatCounter = new RepeatCounter(userInputString, userInputWord);
            int           result            = testRepeatCounter.CountRepeats();
            int           expectedResult    = 0;

            Assert.Equal(expectedResult, result);
        }
예제 #13
0
        public void Test4_TwoWordsReturnOne_true()
        {
            //arrange
              RepeatCounter checkNewWord = new RepeatCounter("and", "and");

              //act
              int result = checkNewWord.CountRepeats();

              //Assert
              Assert.Equal(1, result);
        }
예제 #14
0
        public HomeModule()
        {
            Get["/"]        = _ => View ["index.cshtml"];
            Post["/output"] = _ => {
                string input1 = Request.Form["user_input_form_1"];
                string input2 = Request.Form["user_input_form_2"];

                RepeatCounter newResult = new RepeatCounter(input1, input2);
                int           result    = newResult.CountRepeats();
                return(View["output.cshtml", result]);
            };
        }
예제 #15
0
        public void RepeatCounter_userInputIgnoreUppercase_CountOne()
        {
            //Arrange
            string wordToFind       = "cat";
            string sentenceToSearch = "Cats are so cute. I love my cat.";
            string expectedResult   = "1";
            //Act
            RepeatCounter testRepeatCounter = new RepeatCounter();
            string        result            = testRepeatCounter.CountRepeats(wordToFind, sentenceToSearch);

            //Assert
            Assert.Equal(expectedResult, result);
        }
예제 #16
0
        public void RepeatCounter_userInputIgnorePunctuation_CountTwo()
        {
            //Arrange
            string wordToFind       = "cat";
            string sentenceToSearch = "Cats are so cute. I love cat, and I have a brown cat.";
            string expectedResult   = "2";
            //Act
            RepeatCounter testRepeatCounter = new RepeatCounter();
            string        result            = testRepeatCounter.CountRepeats(wordToFind, sentenceToSearch);

            //Assert
            Assert.Equal(expectedResult, result);
        }
예제 #17
0
        public void RepeatCounter_userInputNoMatch_CountZero()
        {
            //Arrange
            string wordToFind       = "universe";
            string sentenceToSearch = "Hello world";
            string expectedResult   = "0";
            //Act
            RepeatCounter testRepeatCounter = new RepeatCounter();
            string        result            = testRepeatCounter.CountRepeats(wordToFind, sentenceToSearch);

            //Assert
            Assert.Equal(expectedResult, result);
        }
예제 #18
0
        public void RepeatCounter_userInputMultipleInstances_CountFive()
        {
            //Arrange
            string wordToFind       = "cats";
            string sentenceToSearch = "Red cats orange cats brown cats blue cats purple cats";
            string expectedResult   = "5";
            //Act
            RepeatCounter testRepeatCounter = new RepeatCounter();
            string        result            = testRepeatCounter.CountRepeats(wordToFind, sentenceToSearch);

            //Assert
            Assert.Equal(expectedResult, result);
        }
예제 #19
0
        public void RepeatCounter_userInputOneInstance_CountOne()
        {
            //Arrange
            string wordToFind       = "world";
            string sentenceToSearch = "Travel the world";
            string expectedResult   = "1";
            //Act
            RepeatCounter testRepeatCounter = new RepeatCounter();
            string        result            = testRepeatCounter.CountRepeats(wordToFind, sentenceToSearch);

            //Assert
            Assert.Equal(expectedResult, result);
        }
예제 #20
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Post["/results"] = _ => {
         string        userWord         = Request.Form["word"];
         string        userPhrase       = Request.Form["phrase"];
         RepeatCounter newRepeatCounter = new RepeatCounter(userWord, userPhrase);
         int           userOutput       = newRepeatCounter.CountRepeats();
         return(View["results.cshtml", userOutput]);
     };
 }
예제 #21
0
        public void RepeatCounter_userInputFullMatch_CountOne()
        {
            //Arrange
            string wordToFind       = "cat";
            string sentenceToSearch = "I walked my cat to the cathedral.";
            string expectedResult   = "1";
            //Act
            RepeatCounter testRepeatCounter = new RepeatCounter();
            string        result            = testRepeatCounter.CountRepeats(wordToFind, sentenceToSearch);

            //Assert
            Assert.Equal(expectedResult, result);
        }
예제 #22
0
 public void CountRepeats_CountsWordReptitionInStringOfMultipleWords_ReturnsCountOfRepeats()
 {
     // Arrange
       string testWord = "antelope";
       string testString = "An antelope is like a gazelle in a way but it begins with an A actually.";
       int testCount = 1;
       RepeatCounter testRepeatCounter = new RepeatCounter(testWord, testString);
       // Act
       int resultCount = testRepeatCounter.CountRepeats(testWord, testString);
       // Assert
       Console.WriteLine("Spec 5 expected: " + testCount + " Spec 5 actual: " + resultCount);
       Assert.Equal(testCount, resultCount);
 }
예제 #23
0
        public HomeModule()
        {
            Get["/"] = _ =>
            {
                return(View["index.cshtml"]);
            };

            Post["/count"] = _ =>
            {
                RepeatCounter newRepeatCounter = new RepeatCounter(Request.Form["search-word"], Request.Form["search-string"]);
                newRepeatCounter.CountRepeats();
                return(View["word_count.cshtml", newRepeatCounter]);
            };
        }
예제 #24
0
 public void FindWord_FindsWordInStringOfMultipleWordsCapitalizedOrNot_ReturnsCountOfRepeatsRegardlessOfCase()
 {
     // Arrange
       string inputWord = "a";
       string testWord = inputWord.ToUpper();
       string testString = "An antelope is like a gazelle in a way but it begins with an A actually.";
       int testCount = 3;
       RepeatCounter testRepeatCounter = new RepeatCounter(testWord, testString);
       // Act
       int resultCount = testRepeatCounter.CountRepeats(testWord, testString);
       // Assert
       Console.WriteLine("Spec 6 expected: " + testCount + " Spec 6 actual: " + resultCount);
       Assert.Equal(testCount, resultCount);
 }
예제 #25
0
        public HomeModule()
        {
            //Routing to the HomePage
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            };

            //Routing to the Result Page

            Post["/result"] = _ => {
                RepeatCounter newRepeatCounter = new RepeatCounter();
                string        result           = newRepeatCounter.CountRepeats(Request.Form["inputWord"], Request.Form["inputSentence"]);
                string[]      countResultData  = { Request.Form["inputSentence"], Request.Form["inputWord"], result };
                return(View ["results.cshtml", countResultData]);
            };
        }
예제 #26
0
 public void FindWord_FindsWordInStringOfMultipleWordsWithPunchtuation_ReturnsCountOfRepeatsRegardlessOfPunctuation()
 {
     // Arrange
       string inputWord = "actually";
       string testWord = inputWord.ToUpper();
       string testString = "An antelope is like a gazelle in a way but it begins with an A actually.";
       int testCount = 1;
       int resultCount = 0;
       RepeatCounter testRepeatCounter = new RepeatCounter(testWord, testString);
       string testCleanString = testRepeatCounter.RemovePunctuation(testString);
       // Act
       Console.WriteLine("Spec 7 pre-method-call resultCount value: " + resultCount);
       resultCount = testRepeatCounter.CountRepeats(testWord, testCleanString);
       // Assert
       Console.WriteLine("Spec 7 expected: " + testCount + " Spec 7 actual: " + resultCount);
       Assert.Equal(testCount, resultCount);
 }
예제 #27
0
        public void RepeatCounterTest1_Identical_True()
        {
            RepeatCounter testRepeatCounter = new RepeatCounter("A", "A");

            Assert.Equal(1, testRepeatCounter.CountRepeats());
        }
예제 #28
0
        public void RepeatCounterTest_PartialMatches_False()
        {
            RepeatCounter testRepeatCounter = new RepeatCounter("ham", "I love ham on hamburgers");

            Assert.Equal(1, testRepeatCounter.CountRepeats());
        }
예제 #29
0
        public void RepeatCounterTest_Count_True()
        {
            RepeatCounter testRepeatCounter = new RepeatCounter("A", "A A A");

            Assert.Equal(3, testRepeatCounter.CountRepeats());
        }
예제 #30
0
        public void Test8_RecognizeMulitipleWordsInSentence_true()
        {
            RepeatCounter checkNewWord = new RepeatCounter("the", "the blue jays rock the theater the");

              int result = checkNewWord.CountRepeats();

              Assert.Equal(3, result);
        }
예제 #31
0
        public void RepeatCounter_Test3_SplitInput2Sentence_ReturnWordCount()
        {
            RepeatCounter newCountRepeats = new RepeatCounter("I", "I am who I say I am");

            Assert.Equal(3, newCountRepeats.CountRepeats());
        }