public override void Process(PerformDBOperationExpression expression) { if (Connection.State != ConnectionState.Open) Connection.Open(); if (expression.Operation != null) expression.Operation(Connection, null); }
public void CanCreateAndDeleteTableUsingThePerformDBOperationExpressions() { var expression = new PerformDBOperationExpression { Operation = (connection, transaction) => { // I know I could be using the expressions to create and delete this table, // but really I just want to test whether I can execute some commands against the connection. var command = connection.CreateCommand(); command.Transaction = transaction; command.CommandText = "CREATE TABLE dbo.TestTable(TestTableID int NULL)"; command.ExecuteNonQuery(); var command2 = connection.CreateCommand(); command2.Transaction = transaction; command2.CommandText = "DROP TABLE dbo.TestTable"; command2.ExecuteNonQuery(); } }; ExecuteWithSqlServer(processor => processor.Process(expression), IntegrationTestOptions.SqlServer); }
public void WithConnection(Action <IDbConnection, IDbTransaction> operation) { var expression = new PerformDBOperationExpression { Operation = operation }; _context.Expressions.Add(expression); }
public override void Process(PerformDBOperationExpression expression) { Announcer.Say("Performing DB Operation"); if (Options.PreviewOnly) return; if (Connection.State != ConnectionState.Open) Connection.Open(); if (expression.Operation != null) expression.Operation(Connection, null); }
public override void Process(PerformDBOperationExpression expression) { Announcer.Say("Performing DB Operation"); if (Options.PreviewOnly) return; EnsureConnectionIsOpen(); if (expression.Operation != null) expression.Operation(Connection, Transaction); }
public void CallingProcessWithPerformDBOperationExpressionWhenInPreviewOnlyModeWillNotMakeDbChanges() { var output = new StringWriter(); var connection = new SQLiteConnection(IntegrationTestOptions.SqlLite.ConnectionString); var processor = new SqliteProcessor( connection, new SqliteGenerator(), new TextWriterAnnouncer(output), new ProcessorOptions { PreviewOnly = true }, new SqliteDbFactory()); bool tableExists; try { var expression = new PerformDBOperationExpression { Operation = (con, trans) => { var command = con.CreateCommand(); command.CommandText = "CREATE TABLE ProcessTestTable (test int NULL) "; command.Transaction = trans; command.ExecuteNonQuery(); } }; processor.Process(expression); tableExists = processor.TableExists("", "ProcessTestTable"); } finally { processor.RollbackTransaction(); } tableExists.ShouldBeFalse(); output.ToString().ShouldBe( @"/* Performing DB Operation */ "); }
public void CallingProcessWithPerformDBOperationExpressionWhenInPreviewOnlyModeWillNotMakeDbChanges() { var output = new StringWriter(); var connection = new MySqlConnection(IntegrationTestOptions.MySql.ConnectionString); var processor = SetupMySqlProcessorWithPreviewOnly(output, connection); bool tableExists; try { var expression = new PerformDBOperationExpression { Operation = (con, trans) => { var command = con.CreateCommand(); command.CommandText = "CREATE TABLE processtesttable (test int NULL) "; command.Transaction = trans; command.ExecuteNonQuery(); } }; processor.Process(expression); var com = connection.CreateCommand(); com.CommandText = ""; tableExists = processor.TableExists("", "processtesttable"); } finally { processor.RollbackTransaction(); } tableExists.ShouldBeFalse(); }
public override void Process(PerformDBOperationExpression expression) { EnsureConnectionIsOpen(); if (expression.Operation != null) expression.Operation(Connection, Transaction); }
public abstract void Process(PerformDBOperationExpression expression);
public virtual void Process(PerformDBOperationExpression expression) { Processor.Process(expression); }
public void WithConnection(Action<IDbConnection, IDbTransaction> operation) { var expression = new PerformDBOperationExpression { Operation = operation }; _context.Expressions.Add(expression); }
public override void Process(PerformDBOperationExpression expression) { throw new NotImplementedException(); }
public void ErrorIsReturnedWhenOperationIsNull() { var expression = new PerformDBOperationExpression() { Operation = null }; var errors = ValidationHelper.CollectErrors(expression); errors.ShouldContain(ErrorMessages.OperationCannotBeNull); }