In some of my tests, I would like to check if a collection contains the correct items. I therefore create another collection but I don't know the correct order of the items when I write the test. Unfortunately the current Assert.Equal(IEnumerable) implementation checks the order of the items.
Thus I would like to have an overload that could look like
Assert.Equal(expectedCollection, actualCollection, Compare.IgnoringItemSequence);
where the additional parameter can be used to specifiy the compare strategy. The exception that could be thrown by this method should include the items that are in expectedCollection and not in actualCollection (and vice versa). This would really help with defect localization as one does not have to debug the test to find out which items are missing (or abundant).
I read that you have thought about this before (https://xunit.codeplex.com/workitem/9870 and probably https://github.com/xunit/xunit/issues/26) but what do you think about this? I would try to contribute this functionality to xunit.
When we discussed this, we decided that the correct behavior when you don't know the order of results is to put them into a predictable order (using LINQ's OrderBy method).
Ok, I will add the corresponding method to my own framework and close this issue. Thank you.
Most helpful comment
When we discussed this, we decided that the correct behavior when you don't know the order of results is to put them into a predictable order (using LINQ's
OrderBymethod).