private static void ShowStory3(Content content) { var detectWords = new NegativeWordsDetector(new NegativeWordRepository(), new SearchAndFilterText()); detectWords.Detect(content); Console.WriteLine("\r\n"); Console.WriteLine("Filtered text:\r\n"); Console.WriteLine(content.Text); }
private static void ShowStory2(Content content) { var detectWords = new NegativeWordsDetector(new NegativeWordRepository(),new SearchText()); detectWords.Detect(content); Console.WriteLine("Total Number of negative words: " + content.NegativeWordCount); Console.WriteLine("\r\n"); Console.WriteLine("Scanned the text:\r\n"); Console.WriteLine(content.Text); }
private static void ShowStory1( Content content) { var bannedWords = new[] { "swine", "bad", "nasty", "horrible" }; var wordDetector = new NegativeWordsDetector(bannedWords,new SearchText()); wordDetector.Detect(content); Console.WriteLine("Total Number of negative words: " + content.NegativeWordCount); Console.WriteLine("\r\n"); Console.WriteLine("Scanned the text:\r\n"); Console.WriteLine(content.Text); }
public void ShouldDetectNegativeWordFromArray(string contentText,string negativeWordsStr,string expectedCount) { var content = new Content { Text = contentText }; var negativeWords = negativeWordsStr.Split(','); var sut= new NegativeWordsDetector(negativeWords, new SearchText()); sut.Detect(content); var expectedResult = int.Parse(expectedCount); Assert.That(content.NegativeWordCount, Is.EqualTo(expectedResult)); }
public void ShouldDetectNegativeWordsFromRepository(string contentText, string negativeWordsStr, string expectedCount) { var negativeWords = negativeWordsStr.Split(','); var content = new Content { Text = contentText }; _fakeNegativeWordRepository.Setup(x => x.GetAll()).Returns(negativeWords); var sut = new NegativeWordsDetector(_fakeNegativeWordRepository.Object, new SearchText()); sut.Detect(content); var expectedResult = int.Parse(expectedCount); Assert.That(content.NegativeWordCount, Is.EqualTo(expectedResult)); }
public void ShouldFilterContent(string contentText, string negativeWordsStr, string expectedContent) { var negativeWords = negativeWordsStr.Split(','); var content = new Content { Text = contentText }; var sut = new NegativeWordsDetector(negativeWords,new SearchAndFilterText()); sut.Detect(content); Assert.That(content.Text, Is.EqualTo(expectedContent)); }
public void ShouldThrowExceptionIfNegativeWordsListEmpty() { var negativeWords = new List<string>(); var sut = new NegativeWordsDetector(negativeWords, new SearchText()); sut.Detect(new Content()); }
public void ShouldThrowExceptionIfContentIsNull() { var negativeWords = new[] { "bad" }; var sut = new NegativeWordsDetector(negativeWords, new SearchText()); sut.Detect(null); }