Forked from royosherove/TransactionScopeRollbackDemo.cs
Created
April 25, 2018 01:05
-
-
Save hisetu/ab7570aa78347c65aff6ab2b5e4b8d02 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