Example #1
0
        public static void Run(string text, IConsole console)
        {
            // Execute
            var result = ReverseText.Run(text);

            // Display result
            console.Out.WriteLine($"Result: { result }");
        }
        /// <summary>
        /// Checks if <paramref name="text"/> is a palindrome
        /// </summary>
        /// <param name="text">Text to check</param>
        /// <returns>true if <paramref name="text"/> is a palindrome, false otherwise</returns>
        /// <remarks>
        /// Where n is length of the text
        /// BEST CASE- TIME: Ω(n), MEMORY: Ω(n)
        /// AVERAGE CASE- TIME: Θ(n), MEMORY: Θ(n)
        /// WORST CASE- TIME: O(n), MEMORY: O(n)
        /// </remarks>
        public static bool IsPalindrome(string text)
        {
            if (text == null)
            {
                return(false);
            }

            var reversedText = ReverseText.Run(text);

            if (reversedText.Equals(text))
            {
                return(true);
            }

            return(false);
        }
        public void Run_WhenCalled_ReturnsValidResult(string text, string expected)
        {
            var actual = ReverseText.Run(text);

            Assert.Equal(expected, actual);
        }