As one of the most important rules for a test is that it can’t rely on state, I’ve always found automated data access testing hard. As I view it there are three approaches to accomplish reliable testing of such a layer:  

A local database that is restored for each and every test.
Using transactions that can rollback the database after […]