I have an Entity Framework DbContext
, let's call it SomeEntities
. Another member of my team who is no longer here wrote an extension method for SomeEntities
that is now used all over our applications.
public static bool SaveWithAudit(this SomeEntities context, string activity, int userId)
{
context.SaveChanges();
logWhatHappened(userId); //there's more here, doing this for brevity
}
I am working on unit tests for our service layer which interacts with the data context and have learned the hard way that I can't test static members with Moq. I was using Microsoft Fakes, but have learned the hard way that unit tests using Fakes don't show up in dotCover results. In my research, I have seen a few cases where people have wrapped or created their own stubs to deal with these situations, but I haven't found a specific example that makes sense for my scenario. So my question is: Is there a way that I can stub and/or set up a wrapper that allows me to mock this extension method for unit testing?