Please help this Linq newbie!
I'm creating a list inside my class under test, and I would like to use Moq to check the results.
I can easily put together a Predicate which checks the results of the list. How do I then make that Predicate into an Expression?
var myList = new List<int> {1, 2, 3};
Predicate<List<int>> myPredicate = (list) =>
{
return list.Count == 3; // amongst other stuff
};
// ... do my stuff
myMock.Verify(m => m.DidStuffWith(It.Is<List<int>>( ??? )));
??? needs to be an Expression<Predicate<List<int>>>
if you can get your head round that many generics. I've found answers which do this the other way round and compile an Expression into a Predicate. They're not helping me understand Linq any better, though.
EDIT: I've got it working with methods; with expressions; I would just like to know if there's any way to do it with a lambda with a body - and if not, why not?