diff --git a/Scalar.FunctionalTests/Tests/GitCommands/GitCommandsTests.cs b/Scalar.FunctionalTests/Tests/GitCommands/GitCommandsTests.cs index 9eb5abcc..8c5805a5 100644 --- a/Scalar.FunctionalTests/Tests/GitCommands/GitCommandsTests.cs +++ b/Scalar.FunctionalTests/Tests/GitCommands/GitCommandsTests.cs @@ -980,7 +980,7 @@ namespace Scalar.FunctionalTests.Tests.GitCommands string command = "checkout -b tests/functional/OpenFileThenCheckout_2"; ProcessResult expectedResult = GitProcess.InvokeProcess(controlRepoRoot, command); ProcessResult actualResult = GitHelpers.InvokeGitAgainstScalarRepo(scalarRepoRoot, command); - GitHelpers.ErrorsShouldMatch(command, expectedResult, actualResult); + GitHelpers.LinesShouldMatch(command, expectedResult.Errors, actualResult.Errors); actualResult.Errors.ShouldContain("Switched to a new branch"); this.ValidateGitCommand("status"); diff --git a/Scalar.FunctionalTests/Tests/GitCommands/GitRepoTests.cs b/Scalar.FunctionalTests/Tests/GitCommands/GitRepoTests.cs index aff27c48..aa49b8f7 100644 --- a/Scalar.FunctionalTests/Tests/GitCommands/GitRepoTests.cs +++ b/Scalar.FunctionalTests/Tests/GitCommands/GitRepoTests.cs @@ -261,7 +261,7 @@ namespace Scalar.FunctionalTests.Tests.GitCommands if (!ignoreErrors) { - GitHelpers.ErrorsShouldMatch(command, expectedResult, actualResult); + GitHelpers.LinesShouldMatch(command, expectedResult.Errors, actualResult.Errors); } if (command != "status" && checkStatus) diff --git a/Scalar.FunctionalTests/Tools/GitHelpers.cs b/Scalar.FunctionalTests/Tools/GitHelpers.cs index eed00841..90adc1aa 100644 --- a/Scalar.FunctionalTests/Tools/GitHelpers.cs +++ b/Scalar.FunctionalTests/Tools/GitHelpers.cs @@ -87,9 +87,8 @@ namespace Scalar.FunctionalTests.Tools ProcessResult expectedResult = GitProcess.InvokeProcess(controlRepoRoot, command, environmentVariables); ProcessResult actualResult = GitHelpers.InvokeGitAgainstScalarRepo(scalarRepoRoot, command, environmentVariables); - ErrorsShouldMatch(command, expectedResult, actualResult); - actualResult.Output.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries) - .ShouldMatchInOrder(expectedResult.Output.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries), LinesAreEqual, command + " Output Lines"); + LinesShouldMatch(command + " Errors Lines", actualResult.Errors, expectedResult.Errors); + LinesShouldMatch(command + " Output Lines", actualResult.Output, expectedResult.Output); if (command != "status") { @@ -97,10 +96,18 @@ namespace Scalar.FunctionalTests.Tools } } - public static void ErrorsShouldMatch(string command, ProcessResult expectedResult, ProcessResult actualResult) + public static void LinesShouldMatch(string message, string expected, string actual) { - actualResult.Errors.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries) - .ShouldMatchInOrder(expectedResult.Errors.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries), LinesAreEqual, command + " Errors Lines"); + IEnumerable actualLines = NonEmptyLines(actual); + IEnumerable expectedLines = NonEmptyLines(expected); + actualLines.ShouldMatchInOrder(expectedLines, LinesAreEqual, message); + } + + private static IEnumerable NonEmptyLines(string data) + { + return data + .Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries) + .Where(s => !string.IsNullOrWhiteSpace(s)); } private static bool LinesAreEqual(string actualLine, string expectedLine) diff --git a/Scalar.TestInfrastructure/Should/EnumerableShouldExtensions.cs b/Scalar.TestInfrastructure/Should/EnumerableShouldExtensions.cs index 9e32a9c5..561bbb75 100644 --- a/Scalar.TestInfrastructure/Should/EnumerableShouldExtensions.cs +++ b/Scalar.TestInfrastructure/Should/EnumerableShouldExtensions.cs @@ -136,12 +136,12 @@ namespace Scalar.Tests.Should foreach (T groupExtraItem in groupExtraItems) { - errorMessage.AppendLine(string.Format("Extra: {0}", groupExtraItem)); + errorMessage.AppendLine(string.Format("Extra: '{0}'", groupExtraItem)); } foreach (T groupMissingItem in groupMissingItems) { - errorMessage.AppendLine(string.Format("Missing: {0}", groupMissingItem)); + errorMessage.AppendLine(string.Format("Missing: '{0}'", groupMissingItem)); } if (shouldMatchInOrder) @@ -150,7 +150,7 @@ namespace Scalar.Tests.Should { if (!equals(groupList[i], expectedValuesList[i])) { - errorMessage.AppendLine($"Items ordered differently, found: {groupList[i]} expected: {expectedValuesList[i]}"); + errorMessage.AppendLine($"Items ordered differently, found: '{groupList[i]}' expected: '{expectedValuesList[i]}'"); } } }