Method ThrowsAnyAsync
- Namespace
- Xunit
- Assembly
- xunit.v3.assert.dll
ThrowsAnyAsync<T>(Func<Task>)
Verifies that the exact exception or a derived exception type is thrown.
public static Task<T> ThrowsAnyAsync<T>(Func<Task> testCode) where T : Exception
Parameters
Returns
- Task<T>
The exception that was thrown, when successful
Type Parameters
TThe type of the exception expected to be thrown
ThrowsAnyAsync<T>(Func<Task>, Func<T, string?>)
Verifies that the exact exception or a derived exception type is thrown.
public static Task<T> ThrowsAnyAsync<T>(Func<Task> testCode, Func<T, string?> inspector) where T : Exception
Parameters
testCodeFunc<Task>A delegate to the task to be tested
inspectorFunc<T, string>A function which inspects the exception to determine if it's valid or not. Returns
nullif the exception is valid, or a message if it's not.
Returns
- Task<T>
The exception that was thrown, when successful
Type Parameters
TThe type of the exception expected to be thrown