public void Test_01_verify_that_provided_sample_string_returns_provided_output() { // Arrange IPalindromeLibrary library = new PalindromeLibrary(); var sampleString = "sqrrqabccbatudefggfedvwhijkllkjihxymnnmzpop"; const int longest3 = 3; // Act var longest3Palindromes = library.FindNthLongestPalindromes(sampleString, longest3).ToList(); foreach (var palinDrome in longest3Palindromes) { Console.WriteLine(palinDrome); } // Assert Assert.AreEqual(3, longest3Palindromes.Count); Assert.AreEqual("hijkllkjih", longest3Palindromes[0].Text); Assert.AreEqual(23, longest3Palindromes[0].Index); Assert.AreEqual(10, longest3Palindromes[0].Length); Assert.AreEqual("defggfed", longest3Palindromes[1].Text); Assert.AreEqual(13, longest3Palindromes[1].Index); Assert.AreEqual(8, longest3Palindromes[1].Length); Assert.AreEqual("abccba", longest3Palindromes[2].Text); Assert.AreEqual(5, longest3Palindromes[2].Index); Assert.AreEqual(6, longest3Palindromes[2].Length); }
private static void Main() { var sampleString = "sqrrqabccbatudefggfedvwhijkllkjihxymnnmzpop"; Console.WriteLine($"Sample String: {sampleString}"); IPalindromeLibrary library = new PalindromeLibrary(); var longest = library.FindNthLongestPalindromes(sampleString, 3); Console.WriteLine("\n\n"); foreach (var palinDrome in longest) { Console.WriteLine(palinDrome); } Console.WriteLine("\n\nPress Enter to EXIT"); Console.ReadLine(); }
public void Test_03_verify_that_spaces_string_Returns_one_palindrome() { // Arrange IPalindromeLibrary library = new PalindromeLibrary(); var sampleString = " "; const int longest3 = 1; // Act var longest3Palindromes = library.FindNthLongestPalindromes(sampleString, longest3).ToList(); foreach (var palinDrome in longest3Palindromes) { Console.WriteLine(palinDrome); } // Assert Assert.AreEqual(1, longest3Palindromes.Count); }
/// <summary> /// FindTheThreeLongestPalinDromes_ButtonClick /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FindTheThreeLongestPalinDromes_ButtonClick(object sender, RoutedEventArgs e) { ResetUI(); try { IPalindromeLibrary library = new PalindromeLibrary(); const int numberOfLongestPalindromes = 3; var listOfLongestPalindromes = library.FindNthLongestPalindromes(InputStringTextBox.Text, numberOfLongestPalindromes).ToList(); PalindromeDataGrid.ItemsSource = listOfLongestPalindromes; CountLabel.Content = $"{listOfLongestPalindromes.Count} unique Palindrome(s) returned."; } catch (Exception exception) { CountLabel.Content = $"Error: {exception.Message} "; Console.WriteLine(exception); } }
public void Test_01_verify_that_tattarrattat_Returns_tattarrattat() { // Arrange IPalindromeLibrary library = new PalindromeLibrary(); var sampleString = "tattarrattat"; const int longest3 = 1; // Act var longest3Palindromes = library.FindNthLongestPalindromes(sampleString, longest3).ToList(); foreach (var palinDrome in longest3Palindromes) { Console.WriteLine(palinDrome); } // Assert Assert.AreEqual(1, longest3Palindromes.Count); Assert.AreEqual("tattarrattat", longest3Palindromes[0].Text); Assert.AreEqual(0, longest3Palindromes[0].Index); Assert.AreEqual(12, longest3Palindromes[0].Length); }