It seems that testing DALs is harder than I thought. One of the problems I have run into is how to preserve DB integrity. Some of the alternatives are:
- Create mock objects that replace the database.
- Have a separate DB for testing.
- Restore the DB on every test run.
- Run the test inside transactions and then rollback.
Unit Testing in .Net Proyects by Jay Flowers
Simplify Data Layer Unit Testing using Enterprise Services
Alternative Testing Frameworks
Mock Objects to the Rescue! Test your .NET code with NMock
Mocks Aren't Stubs by Martin Fowler
Testing sequences (useful for CRUD operations):
Advanced Unit Testing, Part III - Testing Processes by Marc Clifton