I have following extension method written:
static public IQueryable<OutboundPattern> ByClientID(this IQueryable<OutboundPattern> qry, int clientID)
{
return from p in qry
where p.ClientID == clientID
select p;
}
I also have the following service layer method written:
public IList<OutboundPattern> OutboundPatterns(int ClientId)
{
return _outboundpatternRepository.OutboundPatterns().ByClientID(ClientId).ToList();
}
I would love to know how to mock with Rhino mocks? I know that static methods and Rhino mocks are no good together? It can not mock statics methods.
Daniel Cazzulino has a couple of blog posts that describe an approach to mocking static extension methods.
The basic idea is that you take all the static extension methods... and move them to an interface, which can be easily mocked, and make the static class use a factory to construct instances of that interface. This factory can be replaced by a friend test assembly for mocking purposes.
This might be more work/change than you would like to make in this case, but it's the only way to do it that I've seen (besides buying TypeMock).
Here are his posts: