@@ -16,26 +16,27 @@ namespace Xtensive.Orm.Tests.Storage
16
16
public class NestedTransactionsTest : TransactionsTestBase
17
17
{
18
18
private StorageProviderInfo storageProviderInfo ;
19
+ private Session globalSession ;
20
+
19
21
public override void TestFixtureSetUp ( )
20
22
{
21
23
base . TestFixtureSetUp ( ) ;
22
- Domain . OpenSession ( ) ;
24
+ globalSession = Domain . OpenSession ( ) ;
23
25
storageProviderInfo = StorageProviderInfo . Instance ;
24
26
}
25
27
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 ( ) ;
30
32
31
33
[ Test ]
32
34
public void UnmodifiedStateIsValidInInnerTransactionTest ( )
33
35
{
34
- Require . AllFeaturesSupported ( ProviderFeatures . Savepoints ) ;
35
- using ( var outerScope = Session . Demand ( ) . OpenTransaction ( ) ) {
36
+ using ( var outerScope = globalSession . OpenTransaction ( ) ) {
36
37
var outerTransaction = Transaction . Current ;
37
38
var theHexagon = new Hexagon ( ) ;
38
- using ( var innerScope = Session . Demand ( ) . OpenTransaction ( TransactionOpenMode . New ) ) {
39
+ using ( var innerScope = globalSession . OpenTransaction ( TransactionOpenMode . New ) ) {
39
40
AssertStateIsValid ( theHexagon ) ;
40
41
Assert . AreEqual ( theHexagon . Kwanza , 0 ) ;
41
42
AssertStateIsValid ( theHexagon ) ;
@@ -47,11 +48,10 @@ public void UnmodifiedStateIsValidInInnerTransactionTest()
47
48
[ Test ]
48
49
public void ModifiedStateIsValidInInnerTransactionTest ( )
49
50
{
50
- Require . AllFeaturesSupported ( ProviderFeatures . Savepoints ) ;
51
- using ( var outerScope = Session . Demand ( ) . OpenTransaction ( ) ) {
51
+ using ( var outerScope = globalSession . OpenTransaction ( ) ) {
52
52
var outerTransaction = Transaction . Current ;
53
53
var theHexagon = new Hexagon ( ) ;
54
- using ( var innerScope = Session . Demand ( ) . OpenTransaction ( TransactionOpenMode . New ) ) {
54
+ using ( var innerScope = globalSession . OpenTransaction ( TransactionOpenMode . New ) ) {
55
55
theHexagon . IncreaseKwanza ( ) ;
56
56
AssertStateIsValid ( theHexagon ) ;
57
57
Assert . AreEqual ( theHexagon . Kwanza , 1 ) ;
@@ -63,11 +63,10 @@ public void ModifiedStateIsValidInInnerTransactionTest()
63
63
[ Test ]
64
64
public void UnmodifiedStateIsValidInOuterTransactionAfterInnerTransactionRolledBackTest ( )
65
65
{
66
- Require . AllFeaturesSupported ( ProviderFeatures . Savepoints ) ;
67
- using ( var outerScope = Session . Demand ( ) . OpenTransaction ( ) ) {
66
+ using ( var outerScope = globalSession . OpenTransaction ( ) ) {
68
67
var outerTransaction = Transaction . Current ;
69
68
var theHexagon = new Hexagon ( ) ;
70
- using ( var innerScope = Session . Demand ( ) . OpenTransaction ( TransactionOpenMode . New ) ) {
69
+ using ( var innerScope = globalSession . OpenTransaction ( TransactionOpenMode . New ) ) {
71
70
// rollback
72
71
}
73
72
AssertStateIsValid ( theHexagon ) ;
@@ -78,11 +77,10 @@ public void UnmodifiedStateIsValidInOuterTransactionAfterInnerTransactionRolledB
78
77
[ Test ]
79
78
public void ModifiedStateIsInvalidInOuterTransactionAfterInnerTransactionRolledBackTest ( )
80
79
{
81
- Require . AllFeaturesSupported ( ProviderFeatures . Savepoints ) ;
82
- using ( var outerScope = Session . Demand ( ) . OpenTransaction ( ) ) {
80
+ using ( var outerScope = globalSession . OpenTransaction ( ) ) {
83
81
var outerTransaction = Transaction . Current ;
84
82
var theHexagon = new Hexagon ( ) ;
85
- using ( var innerScope = Session . Demand ( ) . OpenTransaction ( TransactionOpenMode . New ) ) {
83
+ using ( var innerScope = globalSession . OpenTransaction ( TransactionOpenMode . New ) ) {
86
84
theHexagon . IncreaseKwanza ( ) ;
87
85
// rollback
88
86
}
@@ -94,11 +92,10 @@ public void ModifiedStateIsInvalidInOuterTransactionAfterInnerTransactionRolledB
94
92
[ Test ]
95
93
public void UnmodifiedStateIsValidInOuterTransactionAfterInnerTransactionCommitedTest ( )
96
94
{
97
- Require . AllFeaturesSupported ( ProviderFeatures . Savepoints ) ;
98
- using ( var outerScope = Session . Demand ( ) . OpenTransaction ( ) ) {
95
+ using ( var outerScope = globalSession . OpenTransaction ( ) ) {
99
96
var outerTransaction = Transaction . Current ;
100
97
var theHexagon = new Hexagon ( ) ;
101
- using ( var innerScope = Session . Demand ( ) . OpenTransaction ( TransactionOpenMode . New ) ) {
98
+ using ( var innerScope = globalSession . OpenTransaction ( TransactionOpenMode . New ) ) {
102
99
innerScope . Complete ( ) ;
103
100
}
104
101
AssertStateIsValid ( theHexagon ) ;
@@ -109,11 +106,10 @@ public void UnmodifiedStateIsValidInOuterTransactionAfterInnerTransactionCommite
109
106
[ Test ]
110
107
public void ModifiedStateIsValidInOuterTransactionAfterInnerTransactionCommitedTest ( )
111
108
{
112
- Require . AllFeaturesSupported ( ProviderFeatures . Savepoints ) ;
113
- using ( var outerScope = Session . Demand ( ) . OpenTransaction ( ) ) {
109
+ using ( var outerScope = globalSession . OpenTransaction ( ) ) {
114
110
var outerTransaction = Transaction . Current ;
115
111
var theHexagon = new Hexagon ( ) ;
116
- using ( var innerScope = Session . Demand ( ) . OpenTransaction ( TransactionOpenMode . New ) ) {
112
+ using ( var innerScope = globalSession . OpenTransaction ( TransactionOpenMode . New ) ) {
117
113
theHexagon . IncreaseKwanza ( ) ;
118
114
innerScope . Complete ( ) ;
119
115
}
@@ -125,9 +121,8 @@ public void ModifiedStateIsValidInOuterTransactionAfterInnerTransactionCommitedT
125
121
[ Test ]
126
122
public void WrongNestedTransactionUsageTest ( )
127
123
{
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 ) ) {
131
126
outerScope . Complete ( ) ;
132
127
AssertEx . ThrowsInvalidOperationException ( outerScope . Dispose ) ;
133
128
}
0 commit comments