Method ThrowsAsync
- Namespace
- Xunit
- Assembly
- xunit.v3.assert.dll
ThrowsAsync(Type, Func<Task>)
Verifies that the exact exception is thrown (and not a derived exception type).
public static Task<Exception> ThrowsAsync(Type exceptionType, Func<Task> testCode)
Parameters
exceptionTypeTypeThe type of the exception expected to be thrown
testCodeFunc<Task>A delegate to the task to be tested
Returns
ThrowsAsync<T>(Func<Task>)
Verifies that the exact exception is thrown (and not a derived exception type).
public static Task<T> ThrowsAsync<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
ThrowsAsync<T>(string?, Func<Task>)
Verifies that the exact exception is thrown (and not a derived exception type), where the exception derives from ArgumentException and has the given parameter name.
public static Task<T> ThrowsAsync<T>(string? paramName, Func<Task> testCode) where T : ArgumentException
Parameters
paramNamestringThe parameter name that is expected to be in the exception
testCodeFunc<Task>A delegate to the task to be tested
Returns
- Task<T>
The exception that was thrown, when successful
Type Parameters
T