SQL Server integration testing using xUnit
Recently I wanted to verify that my data access layer could properly read and write to a SQL Server database, and I wanted to have these tests automated. I wanted to answer these questions:
- Can my
DbContext
roundtrip entities to the database and back? - Does the schema in my migration scripts match the expected schema in my code? (follows from 1)
- Can my migration scripts be applied to the database correctly?
Since I was using SQL Server I could utilize SQL Server LocalDB that comes with Visual Studio. To keep performance acceptable I do not want to create and destroy a database for each test, so I need a way to reset the database after a test has run.
…