Mocking Entity Framework
August 31, 2016
I found a good article at https://www.rhyous.com/2015/04/10/how-to-mock-an-entity-framework-dbcontext-and-its-dbset-properties/ about a simple way to mock access to the database in C#
Code
Write your code as normal, and pass the DbContext subclass into the module constructor.
MyDatabaseContext lMyDatabaseContext = new MyDatabaseContext(); MyModule lModule = new MyModule(lMyDatabaseContext); lModule. …