For example, I have the following code in my unit test.
Action act = () => subject.Foo2("Hello");
act.Should().Throw<InvalidOperationException>()
After the assertion, I want to run a couple more steps of processing on the thrown exception and assert on the outcome of processing. for example:
new ExceptionToHttpResponseMapper()
.Map(thrownException)
.HttpStatusCode.Should().Be(Http.Forbidden);
I can write a try-catch like,
var thrownException;
try
{
subject.Foo2("Hello");
}
catch(Exception e)
{
thrownException = e;
}
// Assert
but I was wondering if there is a better way.