示例#1
0
        public void AnagramCheckerTest_OneWord_True()
        {
            string         testWord              = "bread";
            string         testWordList          = "beard";
            AnagramChecker testAnagramChecker    = new AnagramChecker(testWord, testWordList);
            List <string>  results               = testAnagramChecker.Check();
            string         sortedTestWord        = AnagramChecker.SortWord(testWord);
            string         sortedPossibleAnagram = AnagramChecker.SortWord(results[0]);

            Assert.Equal(true, sortedPossibleAnagram == sortedTestWord);
        }
示例#2
0
 public HomeModule()
 {
     Get["/"] = _ => {
         //List<string> anagramList = new List<string>();
         return(View["index.cshtml"]);
     };
     Post["/anagram"] = _ => {
         AnagramChecker newAnagram  = new AnagramChecker(Request.Form["user-word"], Request.Form["user-anagrams"]);
         var            anagramList = newAnagram.Check();
         return(View["anagram.cshtml", anagramList]);
     };
 }
示例#3
0
        public void AnagramCheckerTest_WillReturnNonAnagrams_False()
        {
            bool           goodData           = true;
            string         testWord           = "bread";
            string         testWordList       = "beard,bared,kite,flyer";
            AnagramChecker testAnagramChecker = new AnagramChecker(testWord, testWordList);
            List <string>  results            = testAnagramChecker.Check();
            string         sortedTestWord     = AnagramChecker.SortWord(testWord);

            foreach (string possibleAnagram in results)
            {
                Console.WriteLine(possibleAnagram);
                string sortedPossibleAnagram = AnagramChecker.SortWord(possibleAnagram);
                if (sortedPossibleAnagram != sortedTestWord)
                {
                    goodData = false;
                }
            }
            Assert.Equal(true, goodData);
        }