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 */")); }
public void CanDefaultAutoIncrementColumnTypeToInteger() { var column = new ColumnDefinition { Name = "Id", IsIdentity = true, IsPrimaryKey = true, Type = DbType.Int64, IsNullable = false }; var 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(); } }