I wanted a way to automate the integration testing of my repositories and stored procedures so I developed the solution described below using NUnit as the test framework and SQL Server LocalDB as the database to run my tests against.
I had the following requirements for my solution which NUnit has been able to satisfy:
Quick – tests should run quickly and not require massive amounts of set up / tear down
Independent – all tests should be independent from one another and responsible for their own set up / tear down
Simple – the test code should be simple to understand and easy to work with when writing new tests.
Work Everywhere – the tests should be able to work anywhere and not require huge dependencies like a full SQL Server instance, they should be able to work with SQL LocalDB
Read on for the solution.