Moq testing LINQ Where queries
问题 I'm using EF 4.1 to build a domain model. I have a Task class with a Validate(string userCode) method and in it I want to ensure the user code maps to a valid user in the database, so: public static bool Validate(string userCode) { IDbSet<User> users = db.Set<User>(); var results = from u in users where u.UserCode.Equals(userCode) select u; return results.FirstOrDefault() != null; } I can use Moq to mock IDbSet no problem. But ran into trouble with the Where call: User user = new User {