Exemple #1
0
        public void TestInitialize()
        {
            _mockFinder = new Mock <IPalindromeFinder <string, StringPalindrome> >();

            _mockFinder.Setup(x => x.Find(It.IsAny <string>())).Returns(PALINDROMES);

            _service = new UniqueStringPalindromeService(_mockFinder.Object);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            PrintHeader();

            PrintInstructions();

            string text;

            while ((text = Console.ReadLine()).ToUpper() != "EXIT")
            {
                if (string.IsNullOrEmpty(text))
                {
                    text = DEFAULT_TEXT;
                }

                var service = new UniqueStringPalindromeService();

                var palindromes = service.GetPalindromes(text, top: 3);

                if (palindromes.Any())
                {
                    var iterations = 0;

                    foreach (var palindrome in palindromes)
                    {
                        if (iterations > 0)
                        {
                            Console.Write(Environment.NewLine);
                        }
                        Console.WriteLine($"Text: {palindrome.Value}, Index: {palindrome.Index}, Length: {palindrome.Length}");
                    }
                }
                else
                {
                    Console.WriteLine("No palindromes :(");
                }

                PrintInstructions();
            }
        }