public void CountOfBannedWords_BannedWordContainedInAnotherWord_ReturnsZero()
        {
            // Arrange
            _mockBanWordsReader.Setup(reader => reader.GetBannedList()).Returns(SomeBannedWordsWithResult);
            var textViewer = new BannedWordsCounter(_mockBanWordsReader.Object, _wordRegexProvider);

            // Act
            var result = textViewer.CountOfBannedWords("something");

            // Assert
            Assert.AreEqual(0, result, "Should return 0 banned words");
        }
        public void CountOfBannedWords_TwoOfTheSameBannedWords_ReturnsTwo()
        {
            // Arrange
            _mockBanWordsReader.Setup(reader => reader.GetBannedList()).Returns(SomeBannedWordsWithResult);
            var textViewer = new BannedWordsCounter(_mockBanWordsReader.Object, _wordRegexProvider);

            // Act
            var result = textViewer.CountOfBannedWords("this this");

            // Assert
            Assert.AreEqual(2, result, "Should return 2 banned words");
        }
        public void CountOfBannedWords_NoBannedWords_ReturnZero()
        {
            // Arrange
            _mockBanWordsReader.Setup(reader => reader.GetBannedList()).Returns(SomeBannedWordsWithNoResult);
            var textViewer = new BannedWordsCounter(_mockBanWordsReader.Object, _wordRegexProvider);

            // Act
            var result = textViewer.CountOfBannedWords(_someText);

            // Assert
            Assert.AreEqual(0, result, "Should return 0 banned words");
        }
        public void CountOfBannedWords_TextStartsWithNumber_ReturnOne()
        {
            // Arrange
            _mockBanWordsReader.Setup(reader => reader.GetBannedList()).Returns(SomeBannedWordsWithResult);
            var textViewer = new BannedWordsCounter(_mockBanWordsReader.Object, _wordRegexProvider);

            // Act
            var result = textViewer.CountOfBannedWords("4let's do it");

            // Assert
            Assert.AreEqual(1, result, "Should return 1 banned word");
        }
        public void CountOfBannedWords_DuplicateBannedWords_ReturnOne()
        {
            // Arrange
            var fileMockBanWords = new BanWordsReader("../../Assets/10BannedWords.txt");
            var textViewer       = new BannedWordsCounter(fileMockBanWords, _wordRegexProvider);

            // Act
            var result = textViewer.CountOfBannedWords("some try");

            // Assert
            Assert.AreEqual(1, result, "Should return 1 banned word");
        }
Exemple #6
0
        private static int ShowBadWordsCount(IBanWordsReader fileReader, IWordRegexProvider wordRegexProvider, string content)
        {
            var bannedCounter = new BannedWordsCounter(fileReader, wordRegexProvider);

            return(bannedCounter.CountOfBannedWords(content));
        }