File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -371,6 +371,32 @@ MyWebApi
371371 .AndAlso () // AndAlso() is not necessary
372372 .WithMessage (" Some exception message" );
373373
374+ // tests whether the action throws AggregateException
375+ MyWebApi
376+ .Controller <WebApiController >()
377+ .Calling (c => c .SomeAction ())
378+ .ShouldThrow ()
379+ .AggregateException ();
380+
381+ // tests whether the action throws AggregateException
382+ // with specific total number of inner exceptions
383+ MyWebApi
384+ .Controller <WebApiController >()
385+ .Calling (c => c .SomeAction ())
386+ .ShouldThrow ()
387+ .AggregateException (withNumberOfInnerExceptions : 2 );
388+
389+ // tests whether the action throws AggregateException
390+ // containing specific inner exceptions
391+ MyWebApi
392+ .Controller <WebApiController >()
393+ .Calling (c => c .SomeAction ())
394+ .ShouldThrow ()
395+ .AggregateException ()
396+ .ContainingInnerExceptionOfType <NullReferenceException >()
397+ .AndAlso () // AndAlso is not necessary
398+ .ContainingInnerExceptionOfType <InvalidOperationException >();
399+
374400// tests whether the action throws HttpResponseException
375401MyWebApi
376402 .Controller <WebApiController >()
You can’t perform that action at this time.
0 commit comments