public static IAssert <TSubject, TResult, TVars, TSequence> ItThrows <TSubject, TResult, TVars, TSequence> ( this IAssert <TSubject, TResult, TVars, TSequence> assert, Type exceptionType, [CanBeNull] Func <TVars, string> messageProvider = null, [CanBeNull] Func <TVars, Exception> innerExceptionProvider = null) { var controller = assert.GetTestController(); controller.AddAssertion( "Throws " + exceptionType.Name, x => { AssertionHelper.AssertInstanceOfType("Exception", exceptionType, x.Exception); if (messageProvider != null) { AssertionHelper.AssertExceptionMessage(messageProvider(x.Vars), x.Exception); } if (innerExceptionProvider != null) { AssertionHelper.AssertObjectEquals("InnerException", innerExceptionProvider(x.Vars), x.Exception.AssertNotNull().InnerException); } }, c_expectException); return(assert); }