I'm working on a DAL method that uses an ORDER BY clause in a SELECT. The return value from the method is an IEnumerable<T>
, where T is a class that encapsulates a domain entity, and the sort order would be based on one of the properties of this class, namely, "Priority." It's important that this ORDER BY works, of course, so I want to write a sort verification into the unit test for this method. Does anyone have a quick and simple algorithm for testing the order of an IEnumerable<T>
based on one of the properties of T? Is there something LINQ-y that I can use?
var items = repository.GetItems(true); //true tells it to use the ORDER BY
items.ToList().ForEach(i => Assert.IsTrue(??What happens here??));
Thanks in advance.