I'm using NUnit 2.5.6.10205 in a .NET 3.5 C# app. I'm using NUnit's Collection Constraint to assert if an IEnumerable is sorted by a paramter.
It doesn't seem to be working for me, as I'm getting an exception indicating that my actual value isn't an IEnumreable. allEntities is a List<T>
which implements IEnumerable<T>
. I believe that NUnit is looking for an IEnumerable
, not an IEnumerable<T>
, but IEnumerable<T>
implements IEnumerable
. Is this an issue of co / contra variance?
Assert.That(allEntities, Is.All.Ordered.By("CreationDate"));
.
System.ArgumentException : The actual value must be an IEnumerable
Parameter name: actual
Also, is there some way I can express the sort property using a Lambda? Using a literal string for the property makes it brittle.
There is no need for the
All
, try: