-
Notifications
You must be signed in to change notification settings - Fork 78
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
Add collection constraints from NUnit #133
Comments
It should be possible to do, but we need to add support for all frameworks (as we do for other operators) - http://fsprojects.github.io/FsUnit/operators.html |
Hi, I want to work on this. In NUnit assertion, we have the CollectionAssert.AreEquivalent (which order don't matter) and CollectionAssert.AreEqual (which order matter), I think both should exist in FSUnit, We those 2 assertion functions in MSTest and NUnit, but not in XUnit, XUnit have only a function which compares considering the order. How do you think we can handle this? Another option is to use something like FluentAssertions What do you think? |
I guess [1;2;3] |> should equal [1;2;3] (we may add such test-cases and check) for NUnit and MSTest is make sense to wrap |
I opened a PR for NUnit in #139 Next step is to implement it for MSTest, I saw that we are not using MSTest lib for asserts, we reimplemented some of the assertions, Should we do the same for XUnit? makes sense? |
Sorry for "only" commenting to this issue and the changes that @lucasteles made. |
I believe that we should implement as less as possible, so you may reuse Also feel free to open PR that replace existing custom implementation by native assertions provided by framework (where possible) |
Is it possible to implement the CollectionSubsetConstraint, too? i.e.: I want to check if a sequence ( Now, I have a function: to check it like:
But this is not what FsUnit follows I think (from Syntax). |
Ah, I got it. I use the CollectionSupersetConstraint to check this.
and use it as follows:
May I implement this @sergey-tihon? |
We already have contain operator What to you think about [1..10] |> should be (supersetOf [8;1;5]) ? |
Yea, sounds good. I'll try it and make a PR. |
I created a PR #141. I hope you like it. |
I would like to implement the Like: Is this okay? |
Hey @sergey-tihon, |
@lucasteles What about your implementations? @sergey-tihon Do we need more collection assertions? |
@CaptnCodr There is no goal to add all possible operators, especially if you do not need them in our own code base. We can do on demand and only those that are really needed. If you have time you can help finish #139 PR |
Hey @sergey-tihon, I created #145 for you. I took the changes from @lucasteles' PR (#139) to implement the NUnit assertion and added the MsTest assertion to it. Xunit is a bit harder I think. So I did my best. 😅 |
Hello, nice to see that @CaptnCodr could use some of the my changes. This issue still open and it's not clear what is the next steps of constraints to do |
@lucasteles Yes, it's still open because discussions about coming constraints could be made here when they are necessary to implement as mentioned by Sergey above #133 (comment) |
Description
I just wrote some tests and wanted to test a collection that has the equivalent item than another.
Could you please implement the collection constraints from NUnit?
Repro steps
I have to use NUnit's function with like:
let areCollectionsEqual = CollectionAssert.AreEquivalent([1;2;3], [3;1;2])
It's not so "F#-ish".
Known workarounds
I "extended" FsUnit with an extra function:
So I can use this function like:
let areCollectionsEqual () = [1;2;3] |> should equalsToCollection [3;1;2]
Collection contraints implemented:
The text was updated successfully, but these errors were encountered: