public void LoadWordsChainAndDictionaryShouldReturnNullIfNoFileIsFound() { _wordsLoader = new WordsLoader(CommonMocks.GetILogManagerMock().Object, CommonMocks.GetIWordsAdjacencyGraphNodeFactoryMock().Object, CommonMocks.GetIFileWrapperMock(false, null).Object); Assert.Null(_wordsLoader.LoadWordsChainAndDictionary("nonExistingPath")); }
public TextPad() { InitializeComponent(); _wordsLoader = App.DepedencyResolver.Get <WordsLoader>(); _runGenerationService = new RunsGenerator(); _paragraph = new Paragraph(); this.Loaded += HandleLoaded; }
public void CheckIfExceptionIsThrownWhenNoWordsSourceIsSpecified() { // create words loader WordsLoader loader = new WordsLoader(); // skip SetSource... // load the words using the WordsLoader string[] loadedWords = (string[])loader.LoadWords(); }
public void LoadWordsChainAndDictionaryShouldReturnNullIfTooLittleDataIsRead() { _wordsLoader = new WordsLoader(CommonMocks.GetILogManagerMock().Object, CommonMocks.GetIWordsAdjacencyGraphNodeFactoryMock().Object, CommonMocks.GetIFileWrapperMock(true, new List <string>() { "word" }).Object); Assert.Null(_wordsLoader.LoadWordsChainAndDictionary("nonExistingPath")); }
private Engine() { this.renderer = new ConsoleRenderer(); this.wordsLoader = new WordsLoader(); this.wordsLoader.SetSource(new ListSource()); words = this.wordsLoader.LoadWords(); var greetinMsg = Message.GetMessage("greeting"); this.renderer.WriteMessage(greetinMsg); this.InitGame(); this.commandExecuter = new GameCommandInvoker(); FileStorage storage = new FileStorage(MaxPlayersNumber, this.resultsFileName); this.scoreBoard = new ScoreBoard(storage); }
public void LoadWordsChainAndDictionaryShouldReturnValidData() { _wordsLoader = new WordsLoader(CommonMocks.GetILogManagerMock().Object, CommonMocks.GetIWordsAdjacencyGraphNodeFactoryMock().Object, CommonMocks.GetIFileWrapperMock(true, new List <string>() { "git", "cog", "fye", "dog", "ceg" }).Object); var returnedTouple = _wordsLoader.LoadWordsChainAndDictionary("nonExistingPath"); Assert.Equal(returnedTouple.Item1, "git"); Assert.Equal(returnedTouple.Item2, "cog"); Assert.IsType <Dictionary <string, IWordsAdjacencyGraphNode> >(returnedTouple.Item3); Assert.Equal(5, returnedTouple.Item3.Count); }
public static string[] LoadWordsToFind(string basePath, string wordsFilePath) { try { var wordsLoader = new WordsLoader(); wordsLoader.FilePath = Path.Combine(basePath, "Input", wordsFilePath); wordsLoader.Load(); return(wordsLoader.Words); } catch (Exception) { FindOrAddError("Err2", "Loading Words file failed."); } return(null); }
public void LoadWordsChainAndDictionaryShouldLowercaseWords() { _wordsLoader = new WordsLoader(CommonMocks.GetILogManagerMock().Object, CommonMocks.GetIWordsAdjacencyGraphNodeFactoryMock().Object, CommonMocks.GetIFileWrapperMock(true, new List <string>() { "gIt", "Cog", "fyE", "DOG", "CeG" }).Object); var returnedTouple = _wordsLoader.LoadWordsChainAndDictionary("nonExistingPath"); Assert.Equal(returnedTouple.Item1, "git"); Assert.Equal(returnedTouple.Item2, "cog"); Assert.IsType <Dictionary <string, IWordsAdjacencyGraphNode> >(returnedTouple.Item3); Assert.Equal(5, returnedTouple.Item3.Count); foreach (var graphNodeKey in returnedTouple.Item3.Keys) { Assert.Equal(graphNodeKey.ToLowerInvariant(), graphNodeKey); } }
public void CheckLoadedWordsLengthWhenUsingListSource() { // create words loader WordsLoader loader = new WordsLoader(); // create list words source ListSource listSource = new ListSource(); int listLength = 4; listSource.Words = this.CreateWordsList(listLength); // set loader source loader.SetSource(listSource); // load the words using the WordsLoader string[] loadedWords = (string[])loader.LoadWords(); // do test Assert.AreEqual(listLength, loadedWords.Length); }
private void MenuItemGenerate_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(inputFileName)) { MenuItemOpenFile_Click(null, null); if (string.IsNullOrWhiteSpace(inputFileName)) { return; } } var wordsLoader = new WordsLoader(knownParsers); var words = wordsLoader.LoadWords(inputFileName); var selectedFilters = filtersOptions.Where(fo => fo.IsActive).OrderBy(fo => fo.Priority).Select(fo => fo.Filter).ToArray(); var wordsFilterer = new WordsFilterer(selectedFilters); var filteredWords = wordsFilterer.FilterWords(words); tagsCloud = new TagsCloudGenerator(selectedLayouter, selectedRenderer); tagsCloud.GenerateCloud(filteredWords); UpdateImageControl(); }
public void CheckLoadedWordsWhenUsingListSource() { // create words loader WordsLoader loader = new WordsLoader(); // create list words source ListSource listSource = new ListSource(); int listLength = 4; listSource.Words = this.CreateWordsList(listLength); // set loader source loader.SetSource(listSource); // load the words using the WordsLoader string[] loadedWords = (string[])loader.LoadWords(); // do test for (int i = 0; i < loadedWords.Length; i++) { Assert.AreEqual(loadedWords[i], WordLoadingTests.WORD); } }
public WordsLoaderTest() { _loader = new WordsLoader(); }