/// <summary>
 /// Button event to validate the input string is Palindrome
 /// </summary>
 /// <param name="sender">sender</param>
 /// <param name="e">route event</param>
 private void btnValidate_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Console.WriteLine("Validate button was clicked.");
         // Read string from input file.
         string inputString = txtPelend.Text;
         // Validate string is empty of null
         if (!string.IsNullOrEmpty(inputString))
         {
             // Get status of Input string is valid Palindrome
             bool status = PalindromeValidator.PalindromeDeterminer(inputString);
             if (status)
             {
                 lblMesage.Content = "True- Input string is Palindrome";
             }
             else
             {
                 lblMesage.Content = "False - Input is not a Palindrome";
             }
         }
         else
         {
             MessageBox.Show("Please provide inputs. ");
         }
     }
     catch (Exception ex)
     {
         LogHelper.LogMessage(TraceEventType.Error, "The Palindrome Validation failed. The exception has been logged in another message.");
         LogHelper.LogException(string.Empty, ex);
         Environment.Exit(1);
     }
 }
        public void PalindromeDeterminerTest6()
        {
            // Created test data and store it into string array
            string[] array =
            {
                "rotor",
                "sagas",
                "deleveled",
                "solos",
                "sexes",
                "devoved",
                "stats",
                "tenet",
                "Perls",
                "A",
                "Palindrome",
            };

            // Foreach string method will check whether it is Pelindrome or not.
            foreach (string value in array)
            {
                // check status whether strinng (value) is pelindrome.
                bool isPalindrome = PalindromeValidator.PalindromeDeterminer(value);
                Console.WriteLine("{0} = {1}", value, isPalindrome);
            }
        }
        public void PalindromeDeterminerTest2()
        {
            // Created test data and store it into string
            string strPalindrom = "This is Palindrome String";

            // check status whether strinng (value) is pelindrome.
            bool isPalindrome = PalindromeValidator.PalindromeDeterminer(strPalindrom);

            Assert.AreEqual(isPalindrome, false);
        }
        public void PalindromeDeterminerTest1()
        {
            // Created test data and store it into string
            string strPalindrom = "Able was I ere I saw Elba";

            // check status whether strinng (value) is pelindrome.
            bool isPalindrome = PalindromeValidator.PalindromeDeterminer(strPalindrom);

            Assert.AreEqual(isPalindrome, true);
        }
Example #5
0
        public IActionResult Palindrome(string palindrome = "")
        {
            var responseCookies = Request.Cookies;

            if (!_authenticationService.AuthenticateUser(responseCookies["userName"], responseCookies["token"]))
            {
                return(RedirectToActionPermanent("Login", "Home"));
            }

            var isPalindrome        = PalindromeValidator.IsStringPalindrome(palindrome);
            var palindromeValidator = new PalindromeState()
            {
                PalindromeSting = palindrome, IsValidPalindrome = isPalindrome
            };

            return(View(palindromeValidator));
        }
        public void PalindromeDeterminerTest3()
        {
            // Created test data and store it into string array
            string[] array =
            {
                "Ford",
                "Airlines",
                "dewed",
                "Hannah",
                "kayak",
            };

            // Foreach string method will check whether it is Pelindrome or not.
            foreach (string value in array)
            {
                // check status whether strinng (value) is pelindrome.
                bool isPalindrome = PalindromeValidator.PalindromeDeterminer(value);
                Console.WriteLine("{0} = {1}", value, isPalindrome);
            }
        }
        public void PalindromeDeterminerTest4()
        {
            // Created test data and store it into string array
            string[] array =
            {
                "Honda",
                "level",
                "madam",
                "racecar",
                "radar",
                "civic",
            };

            // Foreach string method will check whether it is Pelindrome or not.
            foreach (string value in array)
            {
                // check status whether strinng (value) is pelindrome.
                bool isPalindrome = PalindromeValidator.PalindromeDeterminer(value);
                Console.WriteLine("{0} = {1}", value, isPalindrome);
            }
        }
        public void PalindromeDeterminerTest5()
        {
            // Created test data and store it into string array
            string[] array =
            {
                "string",
                "redder",
                "refer",
                "repaper",
                "reviver",
                "rotator",
                "array",
            };

            // Foreach string method will check whether it is Pelindrome or not.
            foreach (string value in array)
            {
                // check status whether strinng (value) is pelindrome.
                bool isPalindrome = PalindromeValidator.PalindromeDeterminer(value);
                Console.WriteLine("{0} = {1}", value, isPalindrome);
            }
        }
Example #9
0
        private void RunValidation(IPalindromeStrategy strategy)
        {
            PalindromeValidator validator = new PalindromeValidator(strategy);

            Stopwatch sw = new Stopwatch();

            sw.Start();

            int timesToRun = Convert.ToInt32(numTimesToRun.Value);

            bool result = false;

            for (int i = 0; i <= timesToRun; i++)
            {
                result = validator.IsValid(txtWord.Text);
            }

            sw.Stop();

            lblResult.Text = string.Format("{0}. Took {1} ms",
                                           result ? "Palindrome word" : "Just another word",
                                           sw.ElapsedMilliseconds);
        }
Example #10
0
        public void ValidateTest(string target, bool expected)
        {
            var actual = PalindromeValidator.Validate(target);

            Assert.AreEqual(expected, actual);
        }
 private void SetUp()
 {
     testValidator = new PalindromeValidator();
 }
Example #12
0
        public void PalindromeInvalidString(string value)
        {
            var isPalindrome = PalindromeValidator.IsStringPalindrome(value);

            Assert.IsFalse(isPalindrome);
        }