One of the challenging things with current version of Entity Framework, its leakage of testability. Which means when you build an application or module (e.g. Repositories) that depends on entity framework, it will be very hard to unit test your code isolated from Entity Framework. This might lead to conduct Integration Testing which will require a connection and interaction with underlying data store (database).
You might think of using Mocking to mock or fake Entity Framework data store dependent calls. But sadly Moq and Rhino Mock mocking frameworks do not support this. And you’ll end up hitting the wall. Both frameworks are great useful and I personally use Moq for a while now and very happy with it. But no one can deny limitations when exist.
And personally I was able to overcome the limitation of the testability of Entity Framework while I was working in KiGG Entity Framework based models and repositories. But done that through unnecessary code refactoring and wrappers around none mockable classes such as sealed class EntityCollection<T>.
Finding a solution with TypeMock Isolator
In fact there is a solution, that will save you lots of workarounds and unnecessary code refactoring. You just need a full isolation framework. TypeMock Isolator provides this capability. It allows to mock sealed classes and classes that have private constructors, static methods, and much more.
TypeMock isolator makes it easy to simulate and break the dependencies of any object in your existing code. In that way, it doesn’t force you to think about how your design might need to change. –The Art of Unit Testing book page 132-
So, TypeMock isolator is a perfect mate for testing code that has dependencies on Entity Framework as how I am going to show now.