コード例 #1
0
        public IList <string> Find(string word)
        {
            IList <string> wordsToDesplay = new List <string>();


            // wordsToDesplay = _wordRepository.GetAll().Where(p => p.Word == word).Select(p => p.Word).ToList();
            // huge memory leak

            wordsToDesplay = _wordRepository.GetListByPartWord(word).Select(p => p.Word).ToList();

            return(wordsToDesplay);
        }
コード例 #2
0
        public void Find_ShouldReturnedFoundWords()
        {
            RequestedWord = "vilkas";

            IList <WordEntity> wordEntities = new List <WordEntity>()
            {
                new WordEntity()
                {
                    Id         = 1,
                    Word       = "vilkas",
                    SortedWord = "ailksv",
                },

                new WordEntity()
                {
                    Id         = 1,
                    Word       = "vaišvilkas",
                    SortedWord = "aaiilksšv",
                },
            };

            ExpectedList = new List <string>()
            {
                wordEntities[0].Word, wordEntities[1].Word
            };

            _wordRepository.GetListByPartWord(RequestedWord).Returns(wordEntities);

            //////////////////////////////////
            //////////////////////////////////

            var result = _requestService.Find(RequestedWord);

            result.ShouldNotBeNull();
            result.ShouldBe(ExpectedList);

            _wordRepository.Received().GetListByPartWord(RequestedWord);
        }