public void Execute(IEnumerable <string> messages, string expectation, string reason, params object[] reasonArgs) { using (new AssertionScope()) { var results = new AssertionResultSet(); foreach (string message in messages) { using (var scope = new AssertionScope()) { scope.AddNonReportable("context", Context); message.Should().MatchEquivalentOf(string.Format(Pattern, expectation), reason, reasonArgs); results.AddSet(message, scope.Discard()); } if (results.ContainsSuccessfulSet) { break; } } foreach (string failure in results.SelectClosestMatchFor()) { AssertionScope.Current.FailWith(failure); } } }
public void Execute(IEnumerable <string> messages, string expectation, string because, params object[] becauseArgs) { using (new AssertionScope()) { var results = new AssertionResultSet(); foreach (string message in messages) { using (var scope = new AssertionScope()) { scope.Context = Context; message.Should().MatchEquivalentOf(expectation, because, becauseArgs); results.AddSet(message, scope.Discard()); } if (results.ContainsSuccessfulSet()) { break; } } foreach (string failure in results.SelectClosestMatchFor()) { AssertionScope.Current.FailWith(failure.Replace("{", "{{").Replace("}", "}}")); } } }
public void Execute(IEnumerable <string> messages, string expectation, string because, params object[] becauseArgs) { using var _ = new AssertionScope(); var results = new AssertionResultSet(); foreach (string message in messages) { using (var scope = new AssertionScope()) { scope.Context = new Lazy <string>(() => Context); message.Should().MatchEquivalentOf(expectation, because, becauseArgs); results.AddSet(message, scope.Discard()); } if (results.ContainsSuccessfulSet()) { break; } } foreach (string failure in results.SelectClosestMatchFor()) { string replacedCurlyBraces = failure.EscapePlaceholders(); AssertionScope.Current.FailWith(replacedCurlyBraces); } }