2

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.

AJ.
  • 16,368
  • 20
  • 95
  • 150
  • @nawfal, is it a duplicate if this question was asked before the proposed duplicate? – AJ. Jun 16 '14 at 13:39
  • @AJ.Yes, [that is the policy](http://meta.stackexchange.com/search?q=closing+older+question+with+newer+duplicate), though quite unfortunate. In fact there is a better option of *merging*. I will flag for moderator attention. Thanks! – nawfal Jun 16 '14 at 14:22

0 Answers0