public void GetWords_WithStringParameter_ReturnsWordsThatStartWithStringParameter()
        {
            _wordsRepository.GetWords().Returns(new List <Word>
            {
                new Word {
                    Id = 1, Text = "Labas"
                },
                new Word {
                    Id = 2, Text = "Laibas"
                },
                new Word {
                    Id = 3, Text = "Lalala"
                },
                new Word {
                    Id = 4, Text = "Albas"
                },
            });

            var matchingWordsResult = _wordsService.GetWords("la");

            _wordsRepository.Received().GetWords();
            _wordsRepository.ReceivedCalls().ToList().Count.ShouldBe(1);
            matchingWordsResult.ShouldNotBeEmpty();
            matchingWordsResult.First().Text.ShouldBe("Labas");
            matchingWordsResult.Last().Text.ShouldBe("Lalala");
        }
        public void Should_Call_Words_Repo_With_Correct_Arguments(int pageNumber, int pageSize)
        {
            _wordsRepository.GetPageOfWords(pageSize, pageNumber).Returns(new List <WordResponseModel> {
            });

            _dictionaryController.Index(pageNumber);
            _wordsRepository.Received().GetPageOfWords(_dictionaryConfiguration.Value.pageSize, pageNumber);
            var res = _dictionaryController.Index(pageNumber);
        }
Beispiel #3
0
        public void Should_Use_Anagram_Solver_And_Return_At_Least_One_Anagram(string word, string userIp)
        {
            _cacheRepository.GetCachedAnagrams(word).Returns(new List <WordModel>());
            _wordsRepository.GetWords().Returns(_dummyWordsRepository.GetWords());
            _anagramSolver.GetAnagrams(word, _wordsRepository.GetWords()).Returns(new List <WordModel>()
            {
                new WordModel(word)
            });

            Assert.IsTrue(_anagramsService.GetAnagrams(word, userIp).Count >= 1);

            _cacheRepository.Received().GetCachedAnagrams(word);
            _wordsRepository.Received().GetWords();
            _anagramSolver.Received().GetAnagrams(word, _wordsRepository.GetWords());
        }