I am trying to mock my Linq To SQL classes.
I have the following code:
IQueryable<User> vUser =
(from aUser in _ctx.Users
where aUser.UserName == userName
select aUser);
Clearly while doing a unit test _ctx.Users
is null. I can mock _ctx
(the data context), but Users
is a Table<T>
and is sealed. So this fails:
_ctx.Users = Table<User>();
Pex talks about being able to divert any method call via the use of Moles.
I see examples letting you override DateTime.Now(), but I can't see if this would help in my scenario.
Any one have experience with this?