コード例 #1
0
        public void Should_Not_Return_Anagrams_Shorter_Then_Specified_By_Config(string userInput)
        {
            AnagramSolver    anagramSolver = new AnagramSolver(config);
            List <WordModel> anagrams      = anagramSolver.GetAnagrams(userInput, wordsRepository.GetWords());

            Assert.IsTrue(anagrams.All(anagram => anagram.word.Length > config.Value.minWordLength));
        }
コード例 #2
0
        static void Main(string[] args)
        {
            string userInputString = "";

            foreach (string word in args)
            {
                userInputString += word;
            }

            int minWordLength   = Int32.Parse(ConfigurationManager.AppSettings["minWordLength"]);
            int maxResultsLenth = Int32.Parse(ConfigurationManager.AppSettings["maxResultsLenth"]);

            AnagramConfiguration anagramConfiguration = new AnagramConfiguration(minWordLength, maxResultsLenth);

            IWordsRepository wordsRepository = new WordsRepository();

            IAnagramSolver anagramSolver = new AnagramSolver(wordsRepository, anagramConfiguration);

            List <string> anagrams = anagramSolver.GetAnagrams(userInputString);

            foreach (string anagram in anagrams)
            {
                Console.WriteLine(anagram);
            }

            Thread.Sleep(2000);
        }
コード例 #3
0
        public void Should_Return_Two_Anagrams(string userInput)
        {
            AnagramSolver    anagramSolver = new AnagramSolver(config);
            List <WordModel> anagrams      = anagramSolver.GetAnagrams(userInput, wordsRepository.GetWords());

            Assert.IsTrue(anagrams.Count() == 2);
        }
コード例 #4
0
        public void DoNotReturnTestWordAsAnagram()
        {
            AnagramSolver Solver = new AnagramSolver(Path);
            string        word   = Config["testWord3"];

            IList <string> anagrams = Solver.GetAnagrams(word);

            Assert.IsFalse(anagrams.Contains(word));
        }
コード例 #5
0
        public void ReturnNullIfNoWordsWhereFound()
        {
            AnagramSolver Solver = new AnagramSolver(Path);
            string        word   = Config["testWord2"];

            IList <string> anagrams = Solver.GetAnagrams(word);

            Assert.IsNull(anagrams);
        }
コード例 #6
0
        public void ReturnListOfCorrectLength()
        {
            int           maxListLength = Int32.Parse(Config["maxListLength1"]);
            AnagramSolver Solver        = new AnagramSolver(maxListLength, Path);
            string        word          = Config["testWord1"];

            IList <string> anagrams = Solver.GetAnagrams(word);

            Assert.IsTrue(anagrams.Count == maxListLength);
        }
コード例 #7
0
        public void FindCorrectAnagramsForGivenWord()
        {
            AnagramSolver Solver = new AnagramSolver(Path);
            string        word   = Config["testWord1"];

            IList <string> anagrams = Solver.GetAnagrams(word);

            Assert.IsTrue(anagrams.Contains("dugnas"));
            Assert.IsTrue(anagrams.Contains("gandus"));
        }
コード例 #8
0
        public void GetAnagrams_WordLengthIsSmallerThanSmallestWordInAList_ResultCount0()
        {
            var testAnagrams = _anagramSolver2.GetAnagrams("a");

            Assert.IsEmpty(testAnagrams);
        }
コード例 #9
0
        public void GetAnagrams_WordContainsLithuanianChars_ResultCountIs0()
        {
            var testAnagrams = _anagramSolver1.GetAnagrams("Šilutė");

            Assert.IsEmpty(testAnagrams);
        }