Rowan Miller shows how to replace a DbContext based data access layer with an in-memory fake for unit testing in this blog post. He builds an interface that represents the context and then builds an in-memory fake of that context for use in our unit tests. He uses an MVC controller but the same approach can be used with any component that needs to interact with an EF based context, including repositories. The key benefits of this approach are stable and robust tests that execute quickly and exercise a single component, making failures easy to isolate.