@@ -270,4 +270,40 @@ await Assert.That(names)
270270 . And . Contains ( "Bob" )
271271 . And . DoesNotContain ( "Dave" ) ;
272272 }
273+
274+ [ Test ]
275+ public async Task All_Predicate_Failure_Message_Contains_Index_And_Value ( )
276+ {
277+ var items = new [ ] { 2 , 4 , - 5 , 8 } ;
278+
279+ await Assert . That ( async ( ) =>
280+ await Assert . That ( items ) . All ( x => x > 0 )
281+ ) . Throws < AssertionException > ( )
282+ . WithMessageContaining ( "index 2" )
283+ . And . WithMessageContaining ( "[-5]" ) ;
284+ }
285+
286+ [ Test ]
287+ public async Task All_Predicate_Failure_Message_Contains_String_Value ( )
288+ {
289+ var names = new [ ] { "Alice" , "Bob" , "" } ;
290+
291+ await Assert . That ( async ( ) =>
292+ await Assert . That ( names ) . All ( x => ! string . IsNullOrEmpty ( x ) )
293+ ) . Throws < AssertionException > ( )
294+ . WithMessageContaining ( "index 2" )
295+ . And . WithMessageContaining ( "[]" ) ;
296+ }
297+
298+ [ Test ]
299+ public async Task All_Predicate_Failure_Message_Contains_First_Failing_Item ( )
300+ {
301+ var items = new [ ] { 1 , 2 , 3 , - 1 , - 2 , - 3 } ;
302+
303+ await Assert . That ( async ( ) =>
304+ await Assert . That ( items ) . All ( x => x > 0 )
305+ ) . Throws < AssertionException > ( )
306+ . WithMessageContaining ( "index 3" )
307+ . And . WithMessageContaining ( "[-1]" ) ;
308+ }
273309}
0 commit comments