<p>I was thinking it would be nice to create a base class for NUnit test fixtures that opens a TransactionScope during the SetUp phase, then rolls back the transaction during tear down.
Something like this:</p>

<pre><code>    public abstract class TestFixtureBase
{
    private TransactionScope _transaction;

    [TestFixtureSetUp]
    public void TestFixtureSetup()
    {
        _transaction = new TransactionScope();
    }

    [TestFixtureTearDown]
    public void TestFixtureTearDown()
    {
        if (_transaction != null)
        {
            _transaction.Dispose();
        }
    }
}
</code></pre>

<p>Do you think this is a good idea?</p>

<p>Obviously the database is just a test database, not a live database, but it would still be annoying if it filled up with junk data from the unit tests.</p>

<p>What do other people do when running unit tests that involve a lot of data access?</p>

You want to be careful here.  TransactionScope is going to promote the transaction to a distributed transaction if you open up more than one connection to the database.  I find that it is easier just to write some simple SQL that clears out the tables of interest to my test class before I start running the test.
EDIT:
Normally I would call any test that touches the database an integration test since it involves another system.  Typically, I will mock out the database when unit testing my code.
```
```
[TestSetup]
public void Setup()
{
   foreach (string table in new string[] { "table1", "table2" })
   {
        ClearTable( table );
   }
}

private void ClearTable( string table )
{
     ...standard stuff to set up connection...
     SqlCommand command = connection.CreateCommand() );
     command.CommandText = "delete from " + table;
     command.ExecuteNonQuery();
     ... stuff to clean up connection...
}
```
```