Exemple #1
0
        public HomeModule()
        {
            // home view - show two text inputs, one for the main word and one for a word list separated by spaces
              Get["/"] = _ => {
            return View["index.cshtml"];
              };
              Post["/anagram"] = _ => {
            Anagram newWords = new Anagram(Request.Form["MainWord"]);
            string NewWordList = (Request.Form["WordList"]);
            List<string> TestWords = new List<string>(NewWordList.Split(' '));
            Dictionary<string, bool> AnagramList = newWords.IsListAnagram(TestWords);
            newWords.StoreOutput(AnagramList);
            return View["view-anagram.cshtml", newWords];
              };

              // post check anagram - lists the words you input and shows weather or not they match the initial word
              // the main word
        }
        public void IsListAnagram_ForList_ADictionary_true()
        {
            // TODO for chris, follow this closely!

              // instantiate anagram object named bread with main word "bread"
              Anagram bread = new Anagram("bread");
              // instantiate a list of strings called testList to include the words "beard", "berad", "debra", "googl"
              List<string> testList = new List<string>(){"beard", "berad", "debra", "googl"};
              // instantiate a dictionary of string, bool called anagramOutput and set it equal to anagrams output of IsListAnagram
              Dictionary <string, bool> anagramOutput = bread.IsListAnagram(testList);
              // instantiate a dictionary of string, bool called expectedOutput that contains the words in the list and a true or false if they are annagrams
              Dictionary <string, bool> expectedOutput = new Dictionary<string, bool>();
              expectedOutput.Add("beard", true);
              expectedOutput.Add("berad", true);
              expectedOutput.Add("debra", true);
              expectedOutput.Add("googl", false);
              // assert that both the dictionaries are equal
              Assert.Equal(expectedOutput, anagramOutput);
        }