Background and motivation
In some cases, I don't care about the specific exception type that should be thrown. I just want to verify that an exception was thrown.
API Proposal
public class DelegateAssertions<TDelegate, TAssertions>
{
public ExceptionAssertions<Exception> Throw([StringSyntax("CompositeFormat")] string because = "", params object[] becauseArgs)
}
public class AsyncFunctionAssertions<TTask, TAssertions>
{
public async Task<ExceptionAssertions<Exception>> ThrowAsync(
[StringSyntax("CompositeFormat")] string because = "", params object[] becauseArgs)
}
API Usage
var act = () => Foo();
act.Should().Throw().WithMessage("*SomeMessage*");
var act = () => FooAsync();
await act.Should().ThrowAsync().WithMessage("*SomeMessage*");