public void LoadWordsChainAndDictionaryShouldReturnNullIfNoFileIsFound() { _wordsLoader = new WordsLoader(CommonMocks.GetILogManagerMock().Object, CommonMocks.GetIWordsAdjacencyGraphNodeFactoryMock().Object, CommonMocks.GetIFileWrapperMock(false, null).Object); Assert.Null(_wordsLoader.LoadWordsChainAndDictionary("nonExistingPath")); }
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")); }
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 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 BreadthFirstSearchTests() { _breadthFirstSearch = new BreadthFirstSearch(CommonMocks.GetILogManagerMock().Object) { StartWord = "aaa", TargetWord = "abc", WordsAdjacencyGraph = new Dictionary <string, IWordsAdjacencyGraphNode>() { { "aaa", new WordsAdjacencyGraphNodeForTests { Word = "aaa", WasVisited = false, PreviousNode = string.Empty, AdjacentNodes = new HashSet <string>() { "aba", "baa" } } }, { "aba", new WordsAdjacencyGraphNodeForTests { Word = "aba", WasVisited = false, PreviousNode = string.Empty, AdjacentNodes = new HashSet <string>() { "aaa", "bba", "abc" } } }, { "baa", new WordsAdjacencyGraphNodeForTests { Word = "baa", WasVisited = false, PreviousNode = string.Empty, AdjacentNodes = new HashSet <string>() { "aaa" } } }, { "bba", new WordsAdjacencyGraphNodeForTests { Word = "bba", WasVisited = false, PreviousNode = string.Empty, AdjacentNodes = new HashSet <string>() { "baa", "aba" } } }, { "abc", new WordsAdjacencyGraphNodeForTests { Word = "abc", WasVisited = false, PreviousNode = string.Empty, AdjacentNodes = new HashSet <string>() { "aba" } } }, { "yyy", new WordsAdjacencyGraphNodeForTests { Word = "yyy", WasVisited = false, PreviousNode = string.Empty, AdjacentNodes = new HashSet <string>() } }, } }; }