Skip to content

Commit 631e364

Browse files
committed
SystemTransactions/TransactionNotificationFixture.cs, ShouldNotifyAfterDistributedTransactionWithOwnConnection(): It doesn't seem important for this test to use two connection and sessions - the important part is the use of TransactionScope. So use just one connection, to avoid problems with sqlite and others which don't support simultaneous connections.
1 parent 147ede4 commit 631e364

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,37 +157,36 @@ public void ShouldNotifyAfterDistributedTransactionWithOwnConnection(bool doComm
157157

158158
var interceptor = new RecordingInterceptor();
159159
ISession s1 = null;
160-
ISession s2 = null;
161160

162161
using (var tx = new TransactionScope())
163162
{
164-
using (IDbConnection ownConnection1 = sessions.ConnectionProvider.GetConnection())
165-
using (IDbConnection ownConnection2 = sessions.ConnectionProvider.GetConnection())
163+
IDbConnection ownConnection1 = sessions.ConnectionProvider.GetConnection();
164+
165+
try
166166
{
167167
try
168168
{
169169
s1 = sessions.OpenSession(ownConnection1, interceptor);
170-
s2 = sessions.OpenSession(ownConnection2, interceptor);
171170

172171
s1.CreateCriteria<object>().List();
173-
s2.CreateCriteria<object>().List();
174172
}
175173
finally
176174
{
177175
if (s1 != null)
178176
s1.Dispose();
179-
if (s2 != null)
180-
s2.Dispose();
181177
}
182178

183179
if (doCommit)
184180
tx.Complete();
185181
}
182+
finally
183+
{
184+
sessions.ConnectionProvider.CloseConnection(ownConnection1);
185+
}
186186
}
187187

188188
Assert.That(s1.IsOpen, Is.False);
189-
Assert.That(s2.IsOpen, Is.False);
190-
Assert.That(interceptor.afterTransactionCompletionCalled, Is.EqualTo(2));
189+
Assert.That(interceptor.afterTransactionCompletionCalled, Is.EqualTo(1));
191190
}
192191

193192
}

0 commit comments

Comments
 (0)