Пример #1
0
        public void FindCachedAnagramsString_ShouldGetCorrectAnagrams()
        {
            _cachedWordsRepository.GetCachedWordID("alus").Returns(1);
            _cachedWordsRepository.GetCachedAnagrams(1).Returns(new List <int> {
                1, 2
            });
            _wordRepository.FindWordByID(1).Returns("alus");
            _wordRepository.FindWordByID(2).Returns("sula");
            _wordRepository.FindWordByID(3).Returns("sulas");

            var result = _cachedWordsService.FindCachedAnagramsString("alus");

            result.ShouldBe(new List <string> {
                "alus", "sula"
            });
        }
Пример #2
0
        public List <string> FindCachedAnagramsString(string word)
        {
            List <int> cachedAnagrams = FindCachedAnagrams(word);

            if (cachedAnagrams != null)
            {
                List <string> anagramsString = new List <string>();
                string        anagramString;
                foreach (int anagram in cachedAnagrams)
                {
                    anagramString = WordsRepository.FindWordByID(anagram);
                    anagramsString.Add(anagramString);
                }
                return(anagramsString);
            }
            return(null);
        }