In C#'s NUnit framework there is Is.EquivalentTo
constraint which can be very useful for asserting that two arrays are equivalent in the "permutation" way, (i.e. order of the elements does not matter, only the content.)
E.g. the following test will pass
[Test]
public void Test()
{
Assert.That(new[] { 1, 2, 3 }, Is.EquivalentTo(new[] { 2, 3, 1 }));
}
I have been thinking, is there any way to apply the same constraints for jagged arrays? I would like to do the following
[Test]
public void Test2D()
{
// expected true, but fails
Assert.That(new[] { new[] { 1 }, new[] { 2, 3 } }, Is.EquivalentTo(new[] { new[] { 3, 2 }, new[] { 1 } }));
}