예제 #1
0
        public ActionResult Result()
        {
            string phraseVal = Request.Form["phrase"];
            string checkVal  = Request.Form["check"];
            RepeatCounterCreator newRepeatCounterCreator = new RepeatCounterCreator(phraseVal, checkVal);
            int    target = RepeatCounterCreator.CountTool.CountStringOccurences(phraseVal, checkVal);
            string model  = target.ToString() + " is the number of times " + "'" + checkVal + "'" + " appears in the phrase " + "'" + phraseVal + "'" + ".";

            return(View("Index", model));
        }
예제 #2
0
        public void CountStringOccurences_TestMethod_Int()
        {
            //Arrange
            string testPhrase = "This phrase is an input phrase from the user.";
            string testCheck  = "phrase";
            RepeatCounterCreator newRepeatCounterCreator = new RepeatCounterCreator("This phrase is an input phrase from the user.", "phrase");

            //Act
            int model = RepeatCounterCreator.CountTool.CountStringOccurences(testPhrase, testCheck);

            //Assert
            Assert.AreEqual(model, 2);
        }
예제 #3
0
        public void GetStrings_TestInput_String()
        {
            //arrange
            string testPhrase = "This phrase is an input phrase from the user.";
            string testCheck  = "phrase";
            RepeatCounterCreator newRepeatCounterCreator = new RepeatCounterCreator("This phrase is an input phrase from the user.", "phrase");

            //act
            string targetPhrase = newRepeatCounterCreator.GetPhrase();
            string targetCheck  = newRepeatCounterCreator.GetCheck();

            //assert
            Assert.AreEqual(testPhrase, targetPhrase);
            Assert.AreEqual(testCheck, targetCheck);
        }