As unit testing is not used in our firm, I\'m teaching myself to unit test my own code. I\'m using the standard .net test framework for some really basic unit testing.
A
There is a simple but not obvious way to do this with NUnit 3+ 'constraint' assertions:
Assert.That(result, Is.EqualTo(expected).AsCollection, "My failure message");
This will give you the same as the linq mentioned in other answers:
Assert.That(result.SequenceEqual(expected), "My failure message");
But the AsCollection
version will tell you where the first difference is, and if the lengths are different.
See https://docs.nunit.org/articles/nunit/writing-tests/constraints/EqualConstraint.html#comparing-arrays-collections-and-ienumerables