You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
Brad Wilson from xunit.net told here that one should use LINQ's OrderBy operator and afterward Assert.Equal to verify that two collections contain equal items without regarding their order.
Another option is to use something like FluentAssertions
I guess CollectionAssert.AreEqual case should be covered by equal operator due to structured equality
[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 CollectionAssert.AreEquivalent into equivalent operator. I am not sure about xUnit, we can leave it not implemented because it is not idiomatic for framework or reimplement logic from NUnit on our side
Sorry for "only" commenting to this issue and the changes that @lucasteles made.
I'm freshly new to F# and very unsteady to the development like this. 😄
@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.
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.
@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)
Activity
sergey-tihon commentedon Sep 30, 2019
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
lucasteles commentedon Oct 11, 2019
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?
Brad Wilson from xunit.net told here that one should use LINQ's OrderBy operator and afterward Assert.Equal to verify that two collections contain equal items without regarding their order.
Another option is to use something like FluentAssertions
What do you think?
sergey-tihon commentedon Oct 15, 2019
I guess
CollectionAssert.AreEqualcase should be covered byequaloperator due to structured equality(we may add such test-cases and check)
for NUnit and MSTest is make sense to wrap
CollectionAssert.AreEquivalentintoequivalentoperator. I am not sure about xUnit, we can leave it not implemented because it is not idiomatic for framework or reimplement logic from NUnit on our sidelucasteles commentedon Oct 21, 2019
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?
CaptnCodr commentedon Oct 21, 2019
Sorry for "only" commenting to this issue and the changes that @lucasteles made.
I'm freshly new to F# and very unsteady to the development like this. 😄
sergey-tihon commentedon Oct 21, 2019
I believe that we should implement as less as possible, so you may reuse
MSTestassertions where you can.Also feel free to open PR that replace existing custom implementation by native assertions provided by framework (where possible)
CaptnCodr commentedon Oct 24, 2019
Is it possible to implement the CollectionSubsetConstraint, too?
i.e.: I want to check if a sequence (
[1..10]) has the values[8;1;5]in it.Now, I have a function:
let containInCollection x = Is.SubsetOf(x)to check it like:
[1;8;5] |> should containInCollection [1..10]But this is not what FsUnit follows I think (from Syntax).
Is it possible to have an assert like:
[1..10] |> should contain [8;1;5]?CaptnCodr commentedon Oct 25, 2019
Ah, I got it. I use the CollectionSupersetConstraint to check this.
let contain (x: IEnumerable<_>) = Is.SupersetOf(x)and use it as follows:
[1..10] |> should contain [8;1;5]May I implement this @sergey-tihon?
sergey-tihon commentedon Oct 27, 2019
We already have contain operator
What to you think about
?
CaptnCodr commentedon Oct 27, 2019
Yea, sounds good. I'll try it and make a PR.
CaptnCodr commentedon Oct 27, 2019
I created a PR #141. I hope you like it.
CaptnCodr commentedon Oct 30, 2019
I would like to implement the
subsetOfoperator, too. To have the counterpart ofsupersetOf.Like:
[4;5] |> should be (subsetOf [1..10])Is this okay?
CaptnCodr commentedon Oct 31, 2019
Hey @sergey-tihon,
I created a PR #144 for you.
CaptnCodr commentedon Nov 2, 2019
@lucasteles What about your implementations?
@sergey-tihon Do we need more collection assertions?
sergey-tihon commentedon Nov 3, 2019
@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
CaptnCodr commentedon Nov 23, 2019
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. 😅
lucasteles commentedon Oct 2, 2020
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
CaptnCodr commentedon Oct 3, 2020
@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)