@@ -16,26 +16,27 @@ namespace Xtensive.Orm.Tests.Storage
1616 public class NestedTransactionsTest : TransactionsTestBase
1717 {
1818 private StorageProviderInfo storageProviderInfo ;
19+ private Session globalSession ;
20+
1921 public override void TestFixtureSetUp ( )
2022 {
2123 base . TestFixtureSetUp ( ) ;
22- Domain . OpenSession ( ) ;
24+ globalSession = Domain . OpenSession ( ) ;
2325 storageProviderInfo = StorageProviderInfo . Instance ;
2426 }
2527
26- public override void TestFixtureTearDown ( )
27- {
28- Session . Current . DisposeSafely ( ) ;
29- }
28+ protected override void CheckRequirements ( )
29+ => Require . AllFeaturesSupported ( ProviderFeatures . Savepoints ) ;
30+
31+ public override void TestFixtureTearDown ( ) => globalSession . DisposeSafely ( ) ;
3032
3133 [ Test ]
3234 public void UnmodifiedStateIsValidInInnerTransactionTest ( )
3335 {
34- Require . AllFeaturesSupported ( ProviderFeatures . Savepoints ) ;
35- using ( var outerScope = Session . Demand ( ) . OpenTransaction ( ) ) {
36+ using ( var outerScope = globalSession . OpenTransaction ( ) ) {
3637 var outerTransaction = Transaction . Current ;
3738 var theHexagon = new Hexagon ( ) ;
38- using ( var innerScope = Session . Demand ( ) . OpenTransaction ( TransactionOpenMode . New ) ) {
39+ using ( var innerScope = globalSession . OpenTransaction ( TransactionOpenMode . New ) ) {
3940 AssertStateIsValid ( theHexagon ) ;
4041 Assert . AreEqual ( theHexagon . Kwanza , 0 ) ;
4142 AssertStateIsValid ( theHexagon ) ;
@@ -47,11 +48,10 @@ public void UnmodifiedStateIsValidInInnerTransactionTest()
4748 [ Test ]
4849 public void ModifiedStateIsValidInInnerTransactionTest ( )
4950 {
50- Require . AllFeaturesSupported ( ProviderFeatures . Savepoints ) ;
51- using ( var outerScope = Session . Demand ( ) . OpenTransaction ( ) ) {
51+ using ( var outerScope = globalSession . OpenTransaction ( ) ) {
5252 var outerTransaction = Transaction . Current ;
5353 var theHexagon = new Hexagon ( ) ;
54- using ( var innerScope = Session . Demand ( ) . OpenTransaction ( TransactionOpenMode . New ) ) {
54+ using ( var innerScope = globalSession . OpenTransaction ( TransactionOpenMode . New ) ) {
5555 theHexagon . IncreaseKwanza ( ) ;
5656 AssertStateIsValid ( theHexagon ) ;
5757 Assert . AreEqual ( theHexagon . Kwanza , 1 ) ;
@@ -63,11 +63,10 @@ public void ModifiedStateIsValidInInnerTransactionTest()
6363 [ Test ]
6464 public void UnmodifiedStateIsValidInOuterTransactionAfterInnerTransactionRolledBackTest ( )
6565 {
66- Require . AllFeaturesSupported ( ProviderFeatures . Savepoints ) ;
67- using ( var outerScope = Session . Demand ( ) . OpenTransaction ( ) ) {
66+ using ( var outerScope = globalSession . OpenTransaction ( ) ) {
6867 var outerTransaction = Transaction . Current ;
6968 var theHexagon = new Hexagon ( ) ;
70- using ( var innerScope = Session . Demand ( ) . OpenTransaction ( TransactionOpenMode . New ) ) {
69+ using ( var innerScope = globalSession . OpenTransaction ( TransactionOpenMode . New ) ) {
7170 // rollback
7271 }
7372 AssertStateIsValid ( theHexagon ) ;
@@ -78,11 +77,10 @@ public void UnmodifiedStateIsValidInOuterTransactionAfterInnerTransactionRolledB
7877 [ Test ]
7978 public void ModifiedStateIsInvalidInOuterTransactionAfterInnerTransactionRolledBackTest ( )
8079 {
81- Require . AllFeaturesSupported ( ProviderFeatures . Savepoints ) ;
82- using ( var outerScope = Session . Demand ( ) . OpenTransaction ( ) ) {
80+ using ( var outerScope = globalSession . OpenTransaction ( ) ) {
8381 var outerTransaction = Transaction . Current ;
8482 var theHexagon = new Hexagon ( ) ;
85- using ( var innerScope = Session . Demand ( ) . OpenTransaction ( TransactionOpenMode . New ) ) {
83+ using ( var innerScope = globalSession . OpenTransaction ( TransactionOpenMode . New ) ) {
8684 theHexagon . IncreaseKwanza ( ) ;
8785 // rollback
8886 }
@@ -94,11 +92,10 @@ public void ModifiedStateIsInvalidInOuterTransactionAfterInnerTransactionRolledB
9492 [ Test ]
9593 public void UnmodifiedStateIsValidInOuterTransactionAfterInnerTransactionCommitedTest ( )
9694 {
97- Require . AllFeaturesSupported ( ProviderFeatures . Savepoints ) ;
98- using ( var outerScope = Session . Demand ( ) . OpenTransaction ( ) ) {
95+ using ( var outerScope = globalSession . OpenTransaction ( ) ) {
9996 var outerTransaction = Transaction . Current ;
10097 var theHexagon = new Hexagon ( ) ;
101- using ( var innerScope = Session . Demand ( ) . OpenTransaction ( TransactionOpenMode . New ) ) {
98+ using ( var innerScope = globalSession . OpenTransaction ( TransactionOpenMode . New ) ) {
10299 innerScope . Complete ( ) ;
103100 }
104101 AssertStateIsValid ( theHexagon ) ;
@@ -109,11 +106,10 @@ public void UnmodifiedStateIsValidInOuterTransactionAfterInnerTransactionCommite
109106 [ Test ]
110107 public void ModifiedStateIsValidInOuterTransactionAfterInnerTransactionCommitedTest ( )
111108 {
112- Require . AllFeaturesSupported ( ProviderFeatures . Savepoints ) ;
113- using ( var outerScope = Session . Demand ( ) . OpenTransaction ( ) ) {
109+ using ( var outerScope = globalSession . OpenTransaction ( ) ) {
114110 var outerTransaction = Transaction . Current ;
115111 var theHexagon = new Hexagon ( ) ;
116- using ( var innerScope = Session . Demand ( ) . OpenTransaction ( TransactionOpenMode . New ) ) {
112+ using ( var innerScope = globalSession . OpenTransaction ( TransactionOpenMode . New ) ) {
117113 theHexagon . IncreaseKwanza ( ) ;
118114 innerScope . Complete ( ) ;
119115 }
@@ -125,9 +121,8 @@ public void ModifiedStateIsValidInOuterTransactionAfterInnerTransactionCommitedT
125121 [ Test ]
126122 public void WrongNestedTransactionUsageTest ( )
127123 {
128- Require . AllFeaturesSupported ( ProviderFeatures . Savepoints ) ;
129- using ( var outerScope = Session . Demand ( ) . OpenTransaction ( ) )
130- using ( var innerScope = Session . Demand ( ) . OpenTransaction ( TransactionOpenMode . New ) ) {
124+ using ( var outerScope = globalSession . OpenTransaction ( ) )
125+ using ( var innerScope = globalSession . OpenTransaction ( TransactionOpenMode . New ) ) {
131126 outerScope . Complete ( ) ;
132127 AssertEx . ThrowsInvalidOperationException ( outerScope . Dispose ) ;
133128 }
0 commit comments