Skip to content

Instantly share code, notes, and snippets.

@royosherove
Created March 28, 2013 22:45
Show Gist options
  • Save royosherove/5267460 to your computer and use it in GitHub Desktop.
Save royosherove/5267460 to your computer and use it in GitHub Desktop.
Using TransactionScope to rollback database changes in tests
[TestFixture]
public class TrannsactionScopeTests
{
private TransactionScope trans = null;
[SetUp]
public void SetUp()
{
trans = new TransactionScope(TransactionScopeOption.Required);
}
[TearDown]
public void TearDown()
{
trans.Dispose();
}
[Test]
public void TestServicedSameTransaction()
{
MySimpleClass c = new MySimpleClass();
long id = c.InsertCategoryStandard("whatever");
long id2 = c.InsertCategoryStandard("whatever");
Console.WriteLine("Got id of " + id);
Console.WriteLine("Got id of " + id2);
Assert.AreNotEqual(id, id2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment