コード例 #1
0
        public void LoadWordsChainAndDictionaryShouldReturnNullIfNoFileIsFound()
        {
            _wordsLoader = new WordsLoader(CommonMocks.GetILogManagerMock().Object,
                                           CommonMocks.GetIWordsAdjacencyGraphNodeFactoryMock().Object,
                                           CommonMocks.GetIFileWrapperMock(false, null).Object);

            Assert.Null(_wordsLoader.LoadWordsChainAndDictionary("nonExistingPath"));
        }
コード例 #2
0
        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"));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
            }
        }