Skip to content
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

Enable ".Which" extension for value-containing assertions #3

Merged
merged 1 commit into from
Aug 28, 2022

Conversation

sparerd
Copy link
Contributor

@sparerd sparerd commented Aug 26, 2022

This PR enables the FluentAsserts .Which sub-assertion helper when asserting on a value-containing state of a monad (BeSome, BeLeft, etc).

One odd thing that I found when implementing this is that LanguageExtTryAssertions.BeFail returns an Exception type when converted to an Either in order to grab the failure message. However, LanguageExtTryAsyncAssertions.BeFail returns an Error type. I've left this difference as is, but it may be confusing for an end user. I'm not exactly sure why LanguageExt is returning a different type in this case. We can either leave it, make both use Exception, or make both use Error. Not sure what the best choice is, so it is up to you.

Resolves #2

Copy link
Owner

@jmojiwat jmojiwat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this, @sparerd. This is really useful.

@jmojiwat jmojiwat merged commit 8609aab into jmojiwat:master Aug 28, 2022
@jmojiwat
Copy link
Owner

@sparerd thanks for filling in the tests for LanguageExtMonoidValidationAssertionsTest too.

I'm not sure why the return types are different either. I lean towards leaving it as it is, and just sync with LanguageExt if it decides to change its return type in the future.

Maybe we can revisit this if end users keep tripping up here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow fluent assertion chaining with AndWhichConstraint
2 participants