@@ -275,9 +275,6 @@ public AndConstraint<ReactiveAssertions<TPayload>> PushMatch(
275275 if ( predicate == null ) throw new ArgumentNullException ( nameof ( predicate ) ) ;
276276
277277 IList < TPayload > notifications = new List < TPayload > ( ) ;
278- AssertionScope assertion = Execute . Assertion
279- . WithExpectation ( "Expected {context:observable} {0} to push an item matching {1}{reason}" , Subject , predicate . Body )
280- . BecauseOf ( because , becauseArgs ) ;
281278
282279 try
283280 {
@@ -297,12 +294,15 @@ public AndConstraint<ReactiveAssertions<TPayload>> PushMatch(
297294 {
298295 if ( e is AggregateException aggregateException )
299296 e = aggregateException . InnerException ;
300- assertion . FailWith ( ", but it failed with a {0}." , e ) ;
297+ Execute . Assertion
298+ . BecauseOf ( because , becauseArgs )
299+ . FailWith ( "Expected {context:observable} to push an item matching {0}{reason}, but it failed with a {1}." , predicate . Body , e ) ;
301300 }
302-
303- assertion
301+
302+ Execute . Assertion
303+ . BecauseOf ( because , becauseArgs )
304304 . ForCondition ( notifications . Any ( ) )
305- . FailWith ( " within {0}." , timeout ) ;
305+ . FailWith ( "Expected {context:observable} to push an item matching {0}{reason} within {1}." , predicate . Body , timeout ) ;
306306
307307 return new AndConstraint < ReactiveAssertions < TPayload > > ( this ) ;
308308 }
@@ -339,9 +339,6 @@ public async Task<AndConstraint<ReactiveAssertions<TPayload>>> PushMatchAsync(
339339 throw new ArgumentNullException ( nameof ( predicate ) ) ;
340340
341341 IList < TPayload > notifications = new List < TPayload > ( ) ;
342- AssertionScope assertion = Execute . Assertion
343- . WithExpectation ( "Expected {context:observable} {0} to push an item matching {1}{reason}" , Subject , predicate . Body )
344- . BecauseOf ( because , becauseArgs ) ;
345342
346343 try
347344 {
@@ -360,12 +357,15 @@ public async Task<AndConstraint<ReactiveAssertions<TPayload>>> PushMatchAsync(
360357 {
361358 if ( e is AggregateException aggregateException )
362359 e = aggregateException . InnerException ;
363- assertion . FailWith ( ", but it failed with a {0}." , e ) ;
360+ Execute . Assertion
361+ . BecauseOf ( because , becauseArgs )
362+ . FailWith ( "Expected {context:observable} to push an item matching {0}{reason}, but it failed with a {1}." , predicate . Body , e ) ;
364363 }
365364
366- assertion
365+ Execute . Assertion
366+ . BecauseOf ( because , becauseArgs )
367367 . ForCondition ( notifications . Any ( ) )
368- . FailWith ( " within {0}." , timeout ) ;
368+ . FailWith ( "Expected {context:observable} to push an item matching {0}{reason} within {1}." , predicate . Body , timeout ) ;
369369
370370 return new AndWhichConstraint < ReactiveAssertions < TPayload > , IEnumerable < TPayload > > ( this , notifications ) ;
371371 }
0 commit comments