I know how to check that a collection is ordered by some property:
Assert.That(actual, Is.Ordered.By("Foo"));
How can I assert that actual contains the elements (1,2,5,3,4) in this specific order (without writing a custom comparer).
Use
CollectionAssert.AreEqual(expectedIEnumerable, actualIEnumerable);
This checks that the items are equal and are in the same order.
I'm fairly sure that when you use Assert.That on a collection, you get collection assert functionality. So you can say stuff like
Assert.That(collection, Is.EqualTo(expectedCollection)); // Same order
or
Assert.That(collection, Is.EquivalentTo(expectedCollection)); // Same item count
as well as stuff like
Assert.That(collection, Has.Count.EqualTo(expectedSize));
The Has keyword opens you up to the stuff that was specific to collection asserts, and is really useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With