Esempio n. 1
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Get["/anagram"] = _ => {
         Anagram newAnagram = new Anagram(Request.Query["word_input"], Request.Query["anagram_input"]);
         return(View["index.cshtml", newAnagram]);
     };
 }
Esempio n. 2
0
        public void AnagramTester(string input1, string input2, bool result)
        {
            // arrange
            var testingAnagram = new Anagram(input1, input2);
            // act
            var testOutput     = testingAnagram.getAnagram();
            var expectedOutput = result;

            // assert
            Assert.Equal(expectedOutput, testOutput);
        }
Esempio n. 3
0
 public void IsAnagram_ForBigWord_true()
 {
     Anagram testWord = new Anagram();
       List<string> testList= testWord.IsAnagram("beard", "bread beard egg butter");
       foreach(string i in testList)
       {
     Console.WriteLine(i);
     Console.WriteLine(testList.Count);
       }
       Assert.Equal(testList, testWord.IsAnagram("beard", "bread beard egg butter"));
 }
Esempio n. 4
0
        public HomeModule()
        {
            Get["/"] = _ => {
            return View["index.cshtml"];
              };
              Post["/results"] = _ => {
            Anagram newAnagram = new Anagram();
            string word1 = Request.Form["anagram-word"];
            string word2 = Request.Form["anagram-list"];
            List<string> anagramList = newAnagram.IsAnagram(word1, word2);
            Console.WriteLine(word2);
            foreach (string i in anagramList)
            {
              Console.WriteLine(i);
            }

            return View["results.cshtml", anagramList];
              };
        }
        static async Task <int> Main(string[] args)
        {
            if ((args.Length < 2 || args.Length > 3))
            {
                falseInput();
                return(1);
            }

            int totalArgs = args.Length;

            for (int i = 0; i < totalArgs; i++)
            {
                if (string.IsNullOrEmpty(args[i]))
                {
                    falseInput();
                    return(1);
                }

                args[i] = args[i].ToLower();
            }

            if (args[0].Equals("check") && totalArgs == 3)
            {
                if (Anagram.CheckAnagram(args[1], args[2]))
                {
                    Console.WriteLine("\"" + args[1] + "\" and \"" + args[2] + "\" are anagrams");
                }
                else
                {
                    Console.WriteLine("\"" + args[1] + "\" and \"" + args[2] + "\" are no anagrams");
                }

                return(0);
            }
            else if (args[0].Equals("getknown") && totalArgs == 2)
            {
                var anagFile    = "anagrams.txt";
                var anagramText = await System.IO.File.ReadAllLinesAsync(anagFile);

                int count = 0;

                foreach (var anag in anagramText)
                {
                    var words = anag.Split(' ');

                    if (words[0].Equals(args[1]))
                    {
                        Console.WriteLine(words[1]);
                        count++;
                    }
                    else if (words[1].Equals(args[1]))
                    {
                        Console.WriteLine(words[0]);
                        count++;
                    }
                }

                if (count == 0)
                {
                    Console.WriteLine("No known anagrams found");
                }

                return(0);
            }

            falseInput();
            return(1);
        }
Esempio n. 6
0
 public void IsAnagram_ForTwoLetters_true()
 {
     Anagram testWord = new Anagram();
       List<string> testList= testWord.IsAnagram("ab", "ba");
       Assert.Equal(testList, testWord.IsAnagram("ab", "ba"));
 }
Esempio n. 7
0
 public void IsAnagram_ForSingleLetter_true()
 {
     Anagram testWord = new Anagram();
       List<string> testList= testWord.IsAnagram("a", "a");
       Assert.Equal(testList, testWord.IsAnagram("a", "a"));
 }