Q:

C# A question about the lambda expression as a method parameter

At the page code.google.com/p/fakeiteasy/ I've noticed the line:
A.CallTo(() => shop.GetTopSellingCandy()).Returns(lollipop);

so the question is - how to pass a lambda expression as a method parameter ?

A:

This function takes a parameter of type Func<T> (A normal delegate with a generic parameter), or, more likely, Expression<Func<T>> (an expression tree).
The function itself probably has a generic parameter which is inferred from the method passed.
By taking an expression tree, the function is able to inspect the code inside the expression and see what it does.

