SyntaxFix
Write A Post
Hire A Developer
Questions
You can achieve this with a simple one-line.
If your operation foo.bar() is async:
foo.bar()
await Assert.ThrowsExceptionAsync<Exception>(() => foo.bar());
If foo.bar() is not async
Assert.ThrowsException<Exception>(() => foo.bar());