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 CanDefaultAutoIncrementColumnTypeToInteger() { ColumnDefinition column = new ColumnDefinition(); column.Name = "Id"; column.IsIdentity = true; column.IsPrimaryKey = true; column.Type = DbType.Int64; column.IsNullable = false; CreateTableExpression expression = new CreateTableExpression { TableName = tableName }; expression.Columns.Add(column); using (command) { processor.Process(expression); command.CommandText = string.Format("SELECT name FROM sqlite_master WHERE type='table' and name='{0}'", tableName); command.ExecuteReader().Read().ShouldBeTrue(); } }
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(); Assert.That(output.ToString(), Is.StringContaining(@"/* Performing DB Operation */")); }