-
Notifications
You must be signed in to change notification settings - Fork 703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should().Throw and Should().NotThrow throw for Func<T> #951
Should().Throw and Should().NotThrow throw for Func<T> #951
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
AndWhichConstraint
fromNotThrow
which allows continued assertions like this:All the commented code and tests are part of the WIP.