public void SetUp() { words = Enumerable.Repeat("слов", 3); lexems = Enumerable.Repeat(new Lexem("cлово", PartOfSpeech.Noun), 3); lemmatizer = Mock.Create <IWordLemmatizer>(); Mock.Arrange(() => lemmatizer.LemmatizeWords(words)).Returns(lexems); filter1 = Mock.Create <IWordFilter>(); filter2 = Mock.Create <IWordFilter>(); Mock.Arrange(() => filter1.Filter(Arg.IsAny <Lexem>())).Returns(true); Mock.Arrange(() => filter2.Filter(Arg.IsAny <Lexem>())).Returns(false); statisticsMaker = new StatisticsMaker(lemmatizer, new[] { filter1 }); }
private static void TriggerContentCheck(IEnumerable <BadWord> badWords) { Console.WriteLine("Enter content to be checked for bad words:"); string content = Console.ReadLine(); var contentList = content.ToLower().Split(' ').ToList(); var filteredContent = contentList.Aggregate((x, y) => WordFilter.Filter(x, badWords) + " " + WordFilter.Filter(y, badWords)); var count = badWords.Select( word => contentList.Where(x => x.Contains(word.Value.ToLower()))) .Select(res => res.Count()) .Sum(); Console.WriteLine("Scanned the text:"); Console.WriteLine(filteredContent); Console.WriteLine("Total Number of negative words: " + count); Console.WriteLine("Press ANY key to exit."); }
public void CallFilter_ForEveryWord() { statisticsMaker.MakeStatistics(words); Mock.Assert(() => filter1.Filter(Arg.IsAny <Lexem>()), Occurs.Exactly(words.Count())); }
public string FilterNegativeWords() { return(_filter.Filter(Content, _dataStore.GetAll())); }