public void IsEscapingTableNameCorrectlyOnTableExists()
        {
            var expression = new CreateTableExpression {
                TableName = tableNameThanMustBeEscaped
            };

            expression.Columns.Add(column.Object);
            processor.Process(expression);
            processor.TableExists(null, tableNameThanMustBeEscaped).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();

            output.ToString().ShouldBe(
                @"/* Performing DB Operation */
");
        }
        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 */"));
        }