@@ -16,15 +16,11 @@ public override string BugNumber
1616 [ Test ]
1717 public void ExceptionsInBeforeTransactionCompletionAbortTransaction ( )
1818 {
19- #pragma warning disable 618
20- Assert . IsFalse ( sessions . Settings . IsInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled ) ;
21- #pragma warning restore 618
22-
2319 var c = new C { ID = 1 , Value = "value" } ;
2420
2521 var sessionInterceptor = new SessionInterceptorThatThrowsExceptionAtBeforeTransactionCompletion ( ) ;
26- using ( ISession s = sessions . OpenSession ( sessionInterceptor ) )
27- using ( ITransaction t = s . BeginTransaction ( ) )
22+ using ( var s = sessions . WithOptions ( ) . Interceptor ( sessionInterceptor ) . OpenSession ( ) )
23+ using ( var t = s . BeginTransaction ( ) )
2824 {
2925 s . Save ( c ) ;
3026
@@ -42,10 +38,6 @@ public void ExceptionsInBeforeTransactionCompletionAbortTransaction()
4238 [ Test ]
4339 public void ExceptionsInSynchronizationBeforeTransactionCompletionAbortTransaction ( )
4440 {
45- #pragma warning disable 618
46- Assert . IsFalse ( sessions . Settings . IsInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled ) ;
47- #pragma warning restore 618
48-
4941 var c = new C { ID = 1 , Value = "value" } ;
5042
5143 var synchronization = new SynchronizationThatThrowsExceptionAtBeforeTransactionCompletion ( ) ;
@@ -66,78 +58,4 @@ public void ExceptionsInSynchronizationBeforeTransactionCompletionAbortTransacti
6658 }
6759 }
6860 }
69-
70-
71- [ TestFixture ]
72- [ Obsolete ( "Can be removed when Environment.InterceptorsBeforeTransactionCompletionIgnoreExceptions is removed." ) ]
73- public class OldBehaviorEnabledFixture : BugTestCase
74- {
75- public override string BugNumber
76- {
77- get { return "NH1082" ; }
78- }
79-
80- protected override void Configure ( Configuration configuration )
81- {
82- configuration . SetProperty ( Environment . InterceptorsBeforeTransactionCompletionIgnoreExceptions , "true" ) ;
83- base . Configure ( configuration ) ;
84- }
85-
86- [ Test ]
87- public void ExceptionsInBeforeTransactionCompletionAreIgnored ( )
88- {
89- Assert . IsTrue ( sessions . Settings . IsInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled ) ;
90-
91- var c = new C { ID = 1 , Value = "value" } ;
92-
93- var sessionInterceptor = new SessionInterceptorThatThrowsExceptionAtBeforeTransactionCompletion ( ) ;
94- using ( ISession s = sessions . OpenSession ( sessionInterceptor ) )
95- using ( ITransaction t = s . BeginTransaction ( ) )
96- {
97- s . Save ( c ) ;
98-
99- Assert . DoesNotThrow ( t . Commit ) ;
100- }
101-
102- using ( ISession s = sessions . OpenSession ( ) )
103- {
104- var objectInDb = s . Get < C > ( 1 ) ;
105-
106- Assert . IsNotNull ( objectInDb ) ;
107-
108- s . Delete ( objectInDb ) ;
109- s . Flush ( ) ;
110- }
111- }
112-
113-
114- [ Test ]
115- public void ExceptionsInSynchronizationBeforeTransactionCompletionAreIgnored ( )
116- {
117- Assert . IsTrue ( sessions . Settings . IsInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled ) ;
118-
119- var c = new C { ID = 1 , Value = "value" } ;
120-
121- var synchronization = new SynchronizationThatThrowsExceptionAtBeforeTransactionCompletion ( ) ;
122- using ( ISession s = sessions . OpenSession ( ) )
123- using ( ITransaction t = s . BeginTransaction ( ) )
124- {
125- t . RegisterSynchronization ( synchronization ) ;
126-
127- s . Save ( c ) ;
128-
129- Assert . DoesNotThrow ( t . Commit ) ;
130- }
131-
132- using ( ISession s = sessions . OpenSession ( ) )
133- {
134- var objectInDb = s . Get < C > ( 1 ) ;
135-
136- Assert . IsNotNull ( objectInDb ) ;
137-
138- s . Delete ( objectInDb ) ;
139- s . Flush ( ) ;
140- }
141- }
142- }
14361}
0 commit comments