public void Connection_BeginTransaction() { using (var connection = new VodbConnection(Utils.ConnectionCreator)) { Assert.That(connection.BeginTransaction(), Is.Not.Null); } }
public void VodbCommand_Execution_Failed_ConnectionClosed() { using (var connection = new VodbConnection(Utils.ConnectionCreator)) { var command = connection.MakeCommand("Insert Into Employees (FirstName, LastName) values ('testing', 'testing')"); command.ExecuteNonQuery(); } }
public void Connection_CantClose_From_Inner_Transaction() { using (var connection = new VodbConnection(Utils.ConnectionCreator)) { connection.BeginTransaction(); connection.BeginTransaction(); connection.Close(); Assert.That(connection.IsOpened, Is.True); } }
public int VodbCommand_Execution_AssertNonQuery(Func<IVodbCommandFactory, IVodbCommand> makeCommand) { var result = 0; using (var connection = new VodbConnection(Utils.ConnectionCreator)) { connection.WithRollback(c => { result = connection.ExecuteNonQuery(makeCommand(connection)); }); } return result; }
public void Connection_BeginTransaction_And_Rollback() { using (var connection = new VodbConnection(Utils.ConnectionCreator)) { var transaction = connection.BeginTransaction(); try { Assert.That(GetEmployeesCount(connection), Is.EqualTo(9)); connection.ExecuteNonQuery( connection.MakeCommand("Insert Into Employees (FirstName, LastName) values ('testing', 'testing')") ); Assert.That(GetEmployeesCount(connection), Is.EqualTo(10)); } finally { transaction.Rollback(); } } }
public void Connection_CantClose_From_Inner_Transactions() { using (var connection = new VodbConnection(Utils.ConnectionCreator)) { var transaction = connection.BeginTransaction(); for (int i = 0; i < 10; i++) { var inner = connection.BeginTransaction(); // Should not close! connection.Close(); Assert.That(connection.IsOpened, Is.True); // Should not influence the connection or Transaction. inner.Commit(); } // Ends the transaction by Rollback. transaction.Rollback(); // Then the close statement has efect. connection.Close(); Assert.That(connection.IsOpened, Is.False); } }
public void Connection_IsNotOpen_After_Dispose() { VodbConnection connection; using (connection = new VodbConnection(Utils.ConnectionCreator)) { connection.Open(); Assert.That(connection.IsOpened, Is.True); } Assert.That(connection.IsOpened, Is.False); }
public void Connection_Close_NoOpen() { var connection = new VodbConnection(Utils.ConnectionCreator); connection.Close(); Assert.That(connection.IsOpened, Is.False); }
private static int GetEmployeesCount(VodbConnection connection) { return (int)connection.ExecuteScalar(connection.MakeCommand("Select count(*) From Employees")); }
public void Connection_Reopen() { var connection = new VodbConnection(Utils.ConnectionCreator); for (int i = 0; i < 10; i++) { connection.Open(); Assert.That(connection.IsOpened, Is.True); connection.Close(); Assert.That(connection.IsOpened, Is.False); } }
public void Connection_MakeCommand() { VodbConnection connection; using (connection = new VodbConnection(Utils.ConnectionCreator)) { var command = connection.MakeCommand(); Assert.That(command, Is.Not.Null); Assert.That(connection.IsOpened, Is.False); } }