예제 #1
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            };
            Post["/anagram"] = _ => {
                string       primaryWord = Request.Form["primary-word"];
                AnagramCheck newAnagram  = new AnagramCheck(primaryWord, "");
                newAnagram.AddAnagramCheck();
                return(View["primary_confirmation.cshtml", newAnagram]);
            };
            Get["/anagram/add_word"] = _ => {
                AnagramCheck selectedAnagram = AnagramCheck.GetAnagramCheck();
                return(View["add_word.cshtml", selectedAnagram]);
            };
            Post["/anagram/add_word"] = _ => {
                string       secondaryWord   = Request.Form["secondary-word"];
                AnagramCheck selectedAnagram = AnagramCheck.GetAnagramCheck();
                selectedAnagram.AddWord(secondaryWord);
                return(View["add_word.cshtml", selectedAnagram]);
            };
            Post["/anagram/check"] = _ => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                AnagramCheck  selectedAnagram     = AnagramCheck.GetAnagramCheck();
                string        primaryWord         = selectedAnagram.GetPrimary();
                List <string> results             = selectedAnagram.AnagramLister();

                model.Add("primary", primaryWord);
                model.Add("results", results);
                return(View["checked_anagrams.cshtml", model]);
            };
        }
예제 #2
0
        public void IsAnagram_ListOfWordsWithWeirdCaps_ReturnListOfAnagrams()
        {
            string        mainWord    = "bread";
            List <string> listOfWords = new List <string> {
                "BeARd", "bEARs", "DRabe", "DEaRb", "DEAR", "pEAr", "brADe"
            };

            AnagramCheck newAnagram = new AnagramCheck(mainWord, "");

            foreach (string word in listOfWords)
            {
                newAnagram.AddWord(word);
            }

            List <string> correctLists = new List <string> {
                "BeARd", "DEaRb", "DRabe", "brADe"
            };
            List <string> results = newAnagram.AnagramLister();

            correctLists.Sort();
            results.Sort();

            Assert.Equal(true, correctLists.SequenceEqual(results));
        }
예제 #3
0
        public void IsAnagram_ListOfWords_ReturnListOfAnagrams()
        {
            string        mainWord    = "bread";
            List <string> listOfWords = new List <string> {
                "beard", "bears", "drabe", "dearb", "dear", "pear", "brade"
            };

            AnagramCheck newAnagram = new AnagramCheck(mainWord, "");

            foreach (string word in listOfWords)
            {
                newAnagram.AddWord(word);
            }

            List <string> correctLists = new List <string> {
                "beard", "dearb", "drabe", "brade"
            };
            List <string> results = newAnagram.AnagramLister();

            correctLists.Sort();
            results.Sort();

            Assert.Equal(true, correctLists.SequenceEqual(results));
        }