public void Can_Get_Palindromes_Successfully() { // act var result = _service.GetPalindromes(string.Empty); // assert Assert.IsNotNull(result); Assert.AreEqual(4, result.Count()); // "cccc" has the longest length, so should be on top Assert.AreEqual(3, result.First().Index); // "a" has the shortest length, so should be at the bottom Assert.AreEqual(1, result.Last().Index); }
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(); } }