Skip to content

Commit

Permalink
Fix utility HaveStdErrContainingOnce (#46893)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjonescz authored Feb 19, 2025
1 parent c6746cd commit b58d481
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ public AndConstraint<CommandResultAssertions> HaveStdErrContainingOnce(string pa
{
var lines = _commandResult.StdErr?.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
var matchingLines = lines?.Where(line => line.Contains(pattern)).Count();
Execute.Assertion.ForCondition(matchingLines == 0)
Execute.Assertion.ForCondition(matchingLines != 0)
.FailWith(AppendDiagnosticsTo($"The command error output did not contain expected result: {pattern}{Environment.NewLine}"));
Execute.Assertion.ForCondition(matchingLines != 1)
Execute.Assertion.ForCondition(matchingLines == 1)
.FailWith(AppendDiagnosticsTo($"The command error output was expected to contain the pattern '{pattern}' once, but found it {matchingLines} times.{Environment.NewLine}"));
return new AndConstraint<CommandResultAssertions>(this);
}
Expand Down
2 changes: 1 addition & 1 deletion test/dotnet-run.Tests/GivenDotnetRunThrowsAParseError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void ItFailsWithAnAppropriateErrorMessage()
.WithWorkingDirectory(Path.GetTempPath())
.Execute("--", "1")
.Should().Fail()
.And.HaveStdErrContainingOnce(LocalizableStrings.RunCommandExceptionNoProjects);
.And.HaveStdErrContainingOnce("Couldn't find a project to run.");
}
}
}

0 comments on commit b58d481

Please sign in to comment.