Created
March 28, 2013 22:45
-
-
Save royosherove/5267460 to your computer and use it in GitHub Desktop.
Using TransactionScope to rollback database changes in tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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