tpierrain/NFluent

How to assert that two collections are equivalent

Closed this issue · 5 comments

Is there a way to check that 2 collections are equivalent (have the same items but not necessarily in the same order)?

Thanks

Thank you for taking the time to create that issue!

Well, I realize there is no fully satisfying way to achieve that. I will open an issue to have a new check (IsEquivalent).
If you are sure the the enumeration does not contain any duplicate entries, you can use IsOnlyMadeOf

 var integers = new[] { 1, 2, 3 };
 Check.That(integers).IsOnlyMadeOf(3, 2, 1);

To be fixed by #249

Thanks. I ended up chaining IsOnlyMAdeOf with has Size to achieve the desired check.

Another thing I needed but didn't find is a check that a collection only contains unique elements.

The current beta offers ContainsNoDuplicateItem to achieve that result.

See #249