It’s ridiculously easy to do integration testing against Entity Framework and a real database when you are using SpecsFor. I use SpecsFor to do all my integration testing. But it occurred to me that I’ve never publicly documented one of the common tricks I use: viewing data in the test database while the specs are running.
[more]
One of the tricks I show in my course is how to leverage behaviors to make it easy to spin up and tear down a transaction around your SpecsFor specs. But, if you set a break point and debug your spec, then try to query the test database to see what’s actually in your database while the spec is running, you’ll probably encounter a query that never completes, at least not until you stop the debugger. That’s because there’s an active transaction!
To get around it, just run this simple command in your SQL query window: SET TRAN ISOLATION LEVEL READ UNCOMMITTED
Now you can query your SQL database when you hit a breakpoint to see what’s really in there!