Should().Throw and Should().NotThrow throw for Func<T>#951
Should().Throw and Should().NotThrow throw for Func<T>#951dennisdoomen merged 14 commits intofluentassertions:masterfrom
Conversation
jnyrup
left a comment
There was a problem hiding this comment.
To align with Action assertions we should add
public AndWhichConstraint<FunctionAssertions<T>, T> NotThrow<TException>
public ExceptionAssertions<TException> ThrowExactly<TException>
|
Ready for the merge with squash.
|
jnyrup
left a comment
There was a problem hiding this comment.
Looks good 👍
I didn't thought about the difficulty of the return type for NotThrow<TException>().
For now I agree with returning void.
At some later point I would like if we could come up with a nice way to represent the three possible outcomes:
- didn't throw any exception => success and pass on result for chaining further assertions.
- threw an exception but it was not the unexpected => success but no resulting value.
- threw an exception and it was the unexpected one => fail.
|
@jnyrup tests you requested are added, it was a good idea. Additionally, Ready for a merge with squash. |
Closes #422.
This is still work in progress but if you would like to do an early review I would appreciate.
Implemented according to @jnyrup idea of returning
AndWhichConstraintfromNotThrowwhich allows continued assertions like this:All the commented code and tests are part of the WIP.