Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
An async version of xUnit's Async.Throws. Use it like so: await ThrowsAsync<AuthenticationException>(async () => await obj.GetStuffAsync());
public async static Task<T> ThrowsAsync<T>(Func<Task> testCode) where T : Exception
await testCode();
Assert.Throws<T>(() => { }); // Use xUnit's default behavior.
catch (T exception)
return exception;
return null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.