public void RemoveUselessWords_Success() { var configuration = new Moq.Mock <IConfiguration>(); Dictionary <string, IConfigurationSection> sections = new Dictionary <string, IConfigurationSection>(); var exceptionSection = new Moq.Mock <IConfigurationSection>(); exceptionSection.SetupGet(p => p.Value).Returns("para"); sections.Add("exceptions", exceptionSection.Object); configuration .Setup(c => c.GetSection(Moq.It.IsAny <string>())) .Returns <string>((sectionName) => sections[sectionName]); var removeUselessWord = new RemoveUselessWords(configuration.Object); IEnumerable <Word> wordsToCheck = null; removeUselessWord.OnExecuteFinished += (restWord) => wordsToCheck = restWord; var defaultWord = new Word("asdasd"); defaultWord.Type = WordType.Default; var prepositionWord = new Word("asdasd"); prepositionWord.Type = WordType.Preposition; var articleWord = new Word("asdasd"); articleWord.Type = WordType.Article; var verbWord = new Word("asdasd"); verbWord.Type = WordType.Verb; List <Word> words = new List <Word>() { defaultWord, prepositionWord, articleWord, verbWord }; removeUselessWord.Execute(words); Assert.NotNull(wordsToCheck); Assert.Single(wordsToCheck); }
static void Main(string[] args) { IConfiguration config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", true, true) .Build(); var webFeedReader = new WebFeedReader("http://www.minutoseguros.com.br/blog/feed/"); var wordCounter = new WordCounter(); var removeUselessWords = new RemoveUselessWords(config); var textAnalizer = new TextAnalizer(config); var feed = new FeedCountImportantWords(textAnalizer, wordCounter); removeUselessWords.OnExecuteFinished += wordCounter.Execute; textAnalizer.OnExecuteFinished += removeUselessWords.Execute; var feedAnalizer = new FeedAnalizer <Dictionary <string, int> >(webFeedReader, feed); feedAnalizer.OnArticleFinish += PrintReport; feedAnalizer.AnalizeFeed(); }
public void RemoveUselessWords_Success_RemovingNumber() { var configuration = new Moq.Mock <IConfiguration>(); Dictionary <string, IConfigurationSection> sections = new Dictionary <string, IConfigurationSection>(); var exceptionSection = new Moq.Mock <IConfigurationSection>(); exceptionSection.SetupGet(p => p.Value).Returns("r\\$,&.*,\\d"); sections.Add("exceptions", exceptionSection.Object); configuration .Setup(c => c.GetSection(Moq.It.IsAny <string>())) .Returns <string>((sectionName) => sections[sectionName]); var removeUselessWord = new RemoveUselessWords(configuration.Object); IEnumerable <Word> wordsToCheck = null; removeUselessWord.OnExecuteFinished += (restWord) => wordsToCheck = restWord; var defaultWord = new Word("00"); defaultWord.Type = WordType.Default; var defaultWord2 = new Word("asdads"); defaultWord.Type = WordType.Default; List <Word> words = new List <Word>() { defaultWord, defaultWord2 }; removeUselessWord.Execute(words); Assert.NotNull(wordsToCheck); Assert.Single(wordsToCheck); }