@@ -275,9 +275,6 @@ public AndConstraint<ReactiveAssertions<TPayload>> PushMatch(
275
275
if ( predicate == null ) throw new ArgumentNullException ( nameof ( predicate ) ) ;
276
276
277
277
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 ) ;
281
278
282
279
try
283
280
{
@@ -297,12 +294,15 @@ public AndConstraint<ReactiveAssertions<TPayload>> PushMatch(
297
294
{
298
295
if ( e is AggregateException aggregateException )
299
296
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 ) ;
301
300
}
302
-
303
- assertion
301
+
302
+ Execute . Assertion
303
+ . BecauseOf ( because , becauseArgs )
304
304
. 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 ) ;
306
306
307
307
return new AndConstraint < ReactiveAssertions < TPayload > > ( this ) ;
308
308
}
@@ -339,9 +339,6 @@ public async Task<AndConstraint<ReactiveAssertions<TPayload>>> PushMatchAsync(
339
339
throw new ArgumentNullException ( nameof ( predicate ) ) ;
340
340
341
341
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 ) ;
345
342
346
343
try
347
344
{
@@ -360,12 +357,15 @@ public async Task<AndConstraint<ReactiveAssertions<TPayload>>> PushMatchAsync(
360
357
{
361
358
if ( e is AggregateException aggregateException )
362
359
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 ) ;
364
363
}
365
364
366
- assertion
365
+ Execute . Assertion
366
+ . BecauseOf ( because , becauseArgs )
367
367
. 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 ) ;
369
369
370
370
return new AndWhichConstraint < ReactiveAssertions < TPayload > , IEnumerable < TPayload > > ( this , notifications ) ;
371
371
}
0 commit comments