Пример #1
0
        private static void Main(string[] args)
        {
            var palindromeValidator = new PalindromeValidator();

            while (_continueProgram)
            {
                var output = "Neither";
                Console.Write("Please enter a string: ");
                var input = Console.ReadLine();

                if (!InputIsOk(input))
                {
                    Console.WriteLine("String must be all lowercase letters a-z with no spaces");
                    continue;
                }

                var isPalindromeOrAnagramOfPalindrome = palindromeValidator.IsPalindromeOrAnagramOfPalindrome(input);

                if (isPalindromeOrAnagramOfPalindrome)
                {
                    var isPalindrome = palindromeValidator.IsPalindrome(input);
                    output = isPalindrome ? "Palindrome": "Anagram of Palindrome";
                }

                Console.WriteLine(output);
                Console.Write("Press y to continue or n to exit ... ");
                _continueProgram = Console.ReadLine() == "y";
            }
        }
Пример #2
0
        public void WhenNotAPalindromeOrAnagramOfPalindrome_Check_ReturnsFalse(string input)
        {
            //Arrange
            var palindromValidator = new PalindromeValidator();

            //Act
            var result = palindromValidator.IsPalindromeOrAnagramOfPalindrome(input);

            //Assert
            Assert.IsFalse(result);
        }
Пример #3
0
        public void WhenIsAnagramOfPalindromeorNeither_IsPalindrome_ReturnsTure(string input)
        {
            //Arrange
            var palindromValidator = new PalindromeValidator();

            //Act
            var result = palindromValidator.IsPalindrome(input);

            //Assert
            Assert.IsFalse(result);
        }
Пример #4
0
        public void WhenIsPalindrome_IsPalindrome_ReturnsTure(string input)
        {
            //Arrange
            var palindromValidator = new PalindromeValidator();

            //Act
            var result = palindromValidator.IsPalindrome(input);

            //Assert
            Assert.IsTrue(result);
        }