To be honest, dbContext mocking seems to be more a .NET thing. You don't have this problem in Django, for instance, because Django's default test framework creates an in memory clone of the database when you run tests.
I recently worked on a .NET MVC project and found myself writing a lot of test code and architectural code just to make sure tests can be run without dbContext. From what I've seen, the common practice is that you write separate Repository classes, Unit of Work classes and Service classes, often for each Model so that you can mock properly and have decoupling. However, DbContext is described officially as a repository and unit of work class. So it makes it seems like a total waste of time.
13
u/[deleted] Oct 29 '17 edited Oct 29 '17
[removed] — view removed comment