Permalink
Browse files

Oracle inserter honours shared connection outside a transaction with …

…unit test
  • Loading branch information...
1 parent 4107f8f commit bd8adefdb4a3db2947c3d468ecd25ec3f2194ecd @SimonH committed Mar 23, 2012
Showing with 29 additions and 1 deletion.
  1. +28 −0 Simple.Data.Oracle.Tests/InsertTests.cs
  2. +1 −1 Simple.Data.Oracle/OracleInserter.cs
@@ -1,5 +1,7 @@
using System;
+using System.Transactions;
using NUnit.Framework;
+using Simple.Data.Ado;
namespace Simple.Data.Oracle.Tests
{
@@ -116,6 +118,32 @@ public void usage_of_next_and_current_value()
}
}
+ [Test]
+ public void TestSequenceInsertUsingSharedConnectionAndTransactionScope()
+ {
+ using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew))
+ {
+ var adapter = _db.GetAdapter() as AdoAdapter;
+ adapter.UseSharedConnection(adapter.ConnectionProvider.CreateConnection());
+
+ _db.Departments.Insert(
+ DepartmentId: Sequence.Next("DEPARTMENTS_SEQ"),
+ DepartmentName: "Sky",
+ ManagerId: 100,
+ LocationId: 1000);
+ _db.Employees.Insert(
+ EmployeeId: Sequence.Next("EMPLOYEES_SEQ"),
+ LastName: "Brannigan",
+ Email: "awesome@gmail.com",
+ HireDate: new DateTime(2011, 1, 1),
+ JobId: "AD_ASST",
+ DepartmentId: Sequence.Current("DEPARTMENTS_SEQ"));
+ var d = _db.Departments.Find(_db.Departments.Employees.LastName == "Brannigan");
+ Assert.AreEqual("Sky", d.DepartmentName);
+ adapter.StopUsingSharedConnection();
+ }
+ }
+
[Test]
public void return_of_insertion_maps_dbnull_to_null()
{
@@ -27,7 +27,7 @@ public class OracleInserter : ICustomInserter
{
var c = transaction != null
? transaction.Connection.CreateCommand()
- : adapter.ConnectionProvider.CreateConnection().CreateCommand();
+ : adapter.CreateConnection().CreateCommand();
return c;
};

0 comments on commit bd8adef

Please sign in to comment.