/// <summary> /// Asserts the specified verification on the provided exception. /// </summary> /// <typeparam name="TException">The <see cref="Type">type</see> of <see cref="Exception">exception</see> to verify.</typeparam> /// <param name="assert">The <see cref="ExceptionAsserter{T}">asserted exception</see> to verify.</param> /// <param name="verification">The verification <see cref="Func{T1,TResult}">function</see>.</param> /// <param name="message">A message to display if the assertion fails. This message can be seen in the unit test results.</param> /// <param name="parameters">An array of parameters to use when formatting <paramref name="message" />.</param> /// <returns>The <see cref="ExceptionAsserter{T}">asserted exception</see>.</returns> /// <remarks>This method can be used to verify post exception results and behaviors such as exception properties.</remarks> /// <include file="examples.xml" path="Types/Type[@name='ExceptionExtensions']/Member[@name='Verify`1']/example[2]" /> public static ExceptionAsserter <TException> Verify <TException>(this ExceptionAsserter <TException> assert, Func <TException, bool> verification, string message, params object[] parameters) where TException : Exception { Arg.NotNull(assert, nameof(assert)); Contract.Ensures(Contract.Result <ExceptionAsserter <TException> >() != null); assert.AssertParameterIsNotNull(verification, nameof(verification)); assert.IsTrue(verification(assert.Exception), message, parameters); return(assert); }
/// <summary> /// Asserts the specified verification on the provided exception. /// </summary> /// <typeparam name="TException">The <see cref="Type">type</see> of <see cref="Exception">exception</see> to verify.</typeparam> /// <param name="assert">The <see cref="ExceptionAsserter{T}">asserted exception</see> to verify.</param> /// <param name="verification">The verification <see cref="Func{T1,TResult}">function</see>.</param> /// <returns>The <see cref="ExceptionAsserter{T}">asserted exception</see>.</returns> /// <remarks>This method can be used to verify post exception results and behaviors such as exception properties.</remarks> /// <include file="examples.xml" path="Types/Type[@name='ExceptionExtensions']/Member[@name='Verify`1']/example[1]" /> public static ExceptionAsserter <TException> Verify <TException>(this ExceptionAsserter <TException> assert, Func <TException, bool> verification) where TException : Exception => assert.Verify(verification, default(string));