Skip to content

Conversation

@b0wter
Copy link
Contributor

@b0wter b0wter commented Sep 27, 2019

I've added code to allow the user the check the case of a union (see #16). Example:

type MyUnion
    = One
    | Two
    | Three

First |> should be (ofCase<@ First @>) // this will succeed
Second |> should be (ofCase<@ First @>) // this will fail

Currently, this only works in Xunit. If you like the idea I'll try to add support for other frameworks.

Added a CustomMatcher that takes a quotation and will then check if a
value is of the same case.
Also added the feature to the operators matrix.
Enables the ofCase-CustomMatcher to retrieve the names of all union
cases if multiple are supplied using a tuple.
The private union type used for testing has been made public since that
is required for the tests to run properly.
@b0wter b0wter changed the title Adds Xunit CustomMatcher to test case of union Added Xunit CustomMatcher to test case of union Sep 27, 2019
Also added better samples and added more unit tests.
@sergey-tihon
Copy link
Member

Hi, thank you for the PR!

Can you please add tests for other frameworks?

  • MbUnit out of scope
  • MSTest should be relatively easy (reusing the same code from CustomMatchers)
  • NUnit (if we can do it without NHamcrest dependency)

@b0wter
Copy link
Contributor Author

b0wter commented Sep 30, 2019

Is there a good place to store common code?
For Xunit I simply wrapped a CustomMatcher around the two necessary methods. I guess it can be trivially done for Nunit and MSTest and I'd like to write the actual logic only once.

@b0wter
Copy link
Contributor Author

b0wter commented Sep 30, 2019

I've updated my PR to include an implementation of ofCase for MSTest and NUnit. I've also added tests for them and updated the docs.
Since I didn't see a common code repository I've added the logic for ofCase twice (Xunit -> CustomMatchers and NUnit -> CustomConstraints).

@sergey-tihon sergey-tihon merged commit f222b3f into fsprojects:master Oct 2, 2019
@sergey-tihon
Copy link
Member

Thank you for PR @b0wter !
Merged and released as v3.5.0

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.

2 participants