public static void Main()
        {
            RepeatCounters MyCounter = new RepeatCounters();

            Console.WriteLine("I can take a word and a sentence and see how many times that word is contained in a sentence. Please enter the Word you want counted");
            string Word = Console.ReadLine();

            Console.WriteLine("Now please enter your sentence");
            string Sentence = Console.ReadLine();

            MyCounter.DoesItContain(Word, Sentence);
            Console.WriteLine($"You entered {Word}, {MyCounter.GrandTotal} Times");
        }
示例#2
0
        public void DoesItContain_ChecksIfWordIsContained_WordIsThereUpdated()
        {
            // Arrange
            string Word     = "cat";
            string Sentence = "My cat lives in Petcat village with other cats that look like cat";

            // Act
            RepeatCounters MyRepeatCounter = new RepeatCounters();

            MyRepeatCounter.DoesItContain(Word, Sentence);

            // Assert
            Assert.AreEqual(1, MyRepeatCounter.WordIsThere);
        }
示例#3
0
        public void DoesItContain_ChecksIfWordIsContained_ExpectingZero()
        {
            // Arrange
            string Word     = "cat";
            string Sentence = "It is a dog sentence and reverse of tac is not here";

            // Act
            RepeatCounters MyRepeatCounter = new RepeatCounters();

            MyRepeatCounter.DoesItContain(Word, Sentence);

            // Assert
            Assert.AreEqual(0, MyRepeatCounter.WordIsThere);
        }
示例#4
0
        public void NumberOfTimes_ChecksWhetherCountedWordCorrect_GrandTotalEqualsZero()
        {
            // Arrange
            string Word     = "cat";
            string Sentence = "My cats live in Petcat village with other cats that look more like a dog";


            // Act
            RepeatCounters MyRepeatCounter = new RepeatCounters();

            MyRepeatCounter.NumberOfTimes(Word, Sentence);

            // Assert
            Assert.AreEqual(0, MyRepeatCounter.GrandTotal);
        }
示例#5
0
        public void NumberOfTimes_ChecksWhetherCountedWordCorrect_GrandTotalIsUpdated()
        {
            // Arrange
            string Word     = "cat";
            string Sentence = "My Cat lives in Petcat village with other cats that look like Cat";


            // Act
            RepeatCounters MyRepeatCounter = new RepeatCounters();

            MyRepeatCounter.NumberOfTimes(Word, Sentence);

            // Assert
            Assert.AreEqual(2, MyRepeatCounter.GrandTotal);
        }