tags:

views:

94

answers:

2

I'm looking for a project/tool that will insert data into a database before a test and roll it back after a test has run.

I know that ruby on rails has yaml fixtures, so I was hoping there is a project out there for .net projects.

A: 

I use Sql Server Compact Edition and regenerate a new copy of the database each time (simply copying an initial database is fine) and if used in read only mode multiple tests can share the same database file.

There are a few gotchas, and programmability is not supported but it works well for the basics that I needed it for. It is also surprisingly fast.

ShuggyCoUk
I've done something similar to that in the past, but the database for this project is probably too large to detach and attach a new copy each time.
Eric Neunaber
well if the tests are read only on the db you only need to do it once. you'll serialize all your unit tests that depend on the db otherwise (unless you fancy multiple unit test environments) not to mention dealing with multiple users.
ShuggyCoUk
But it might just be that you can't really unit test the database layer, this happens, it's not the end of the world but is a shame
ShuggyCoUk
A: 

I've implemented a basic example of Rails-like fixtures for .NET on my blog.

http://www.davidmuto.com/Blog.muto/View/rails-like-fixtures-for-net

Any good?