views:

36

answers:

1

I'm using MVP with ASP.NET Web Forms. Being a good TDDer, I want to test all the important behaviors in my Presenter, including the default sort it applies to the result set retrieved from the service layer. The Presenter will be applying a nested sort via LINQ to Objects of the style:

public IEnumerable<ViewModel> MyModel{
   get
      {
          return _myService.GetResults().OrderBy(r=>r.PropertyA).ThenBy(r1=>r1.PropertyB);
      }
}

I've looked at the IsOrderedBy extension method described in this SO question, but I'm not sure how to extend it to work with the nested sort I describe above. Ditto for the code posted by Jon Skeet in this SO question.

+1  A: 

When unit testing I use to be as explicit as possible. Let your mock service return a list with some items with different values for PropertyA and PropertyB. Then manually sort that list into a "right answer list". Finally compare with .SequenceEqual<>.

Albin Sunnanbo