public void PalindromeFinderTest()
        {
            var finder = new PalindromeCalculator();

            var request = new PalindromFinderRequest()
            {
                Word = "noon"
            };

            var result = finder.FindPalindrome(request);

            Assert.AreEqual(result.Word, "noon");
            Assert.AreEqual(result.ModifiedWord, "noon");
            Assert.AreEqual(result.IsPalindrome, true);
        }
Exemplo n.º 2
0
        public ActionResult PalindromeInput(PalidromeFinderModel request)
        {
            if (ModelState.IsValid)
            {
                var palinFind = new PalindromeCalculator();
                var palinData = new PalindromFinderRequest();
                palinData.Word = request.Word;


                var result = palinFind.FindPalindrome(palinData);
                return(View("PalindromeOutput", result));
            }
            else
            {
                return(View(request));
            }
        }
        public PalindromFinderResponse FindPalindrome(PalindromFinderRequest request)
        {
            var response = new PalindromFinderResponse();

            response.Word         = request.Word;
            response.ModifiedWord = "";


            for (int i = response.Word.Length - 1; i >= 0; i--)
            {
                response.ModifiedWord += response.Word[i];
            }

            if (response.ModifiedWord != request.Word)
            {
                response.IsPalindrome = false;
            }
            else
            {
                response.IsPalindrome = true;
            }

            return(response);
        }