I recently ran into a problem: How to test some code that was not readily testable without carrying along a database.

It was my own fault, really. I had quickly written a data access layer that was directly dependent on Entity Framework, and was also doing some minor business logic. Because I had a direct dependency on Entity Framework, and had not used dependency injection, I had a problem… How do I write unit tests against those methods that contain business logic that also make direct calls to stored procedures through Entity Framework?

Read More…