public static bool TryRollback(this WrappedConnection wrappedConnection) { if (wrappedConnection.CurrentTx != null) { wrappedConnection.Rollback(); return(true); } return(false); }
public void When_rollback_transaction_is_cleared() { using (var wrappedConnection = new WrappedConnection(new SqliteConnection("Data Source=:memory:"))) { var tx = wrappedConnection.BeginTransaction(); wrappedConnection.Rollback(); Assert.Null(wrappedConnection.CurrentTx); } }
public void Rollback_a_null_transaction_throws_InvalidOperationException() { var cnn = new SqliteConnection("Data Source=:memory:"); using (var wrappedConnection = new WrappedConnection(cnn)) { Assert.Throws <InvalidOperationException>(() => wrappedConnection.Rollback()); } Assert.True(cnn.State == ConnectionState.Closed); }
public void Rollback_a_null_transaction_throws_InvalidOperationException() { var cnn = _pgContainer.CreateDbConnection(); using (var wrappedConnection = new WrappedConnection(cnn)) { Assert.Throws <InvalidOperationException>(() => wrappedConnection.Rollback()); } Assert.True(cnn.State == ConnectionState.Closed); }