Exemplo n.º 1
0
        public SQLiteTestTable(SQLiteProcessor processor, string schemaName, params string[] columnDefinitions)
        {
            _schemaName = schemaName;
            Connection  = ( IDbConnection )processor.Connection;
            Transaction = ( IDbTransaction )processor.Transaction;

            Name = "Table" + Guid.NewGuid().ToString("N");
            Create(columnDefinitions);
        }
        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 */"));
        }
        protected static void ExecuteWithSqlite(Action <IMigrationProcessor> test, IntegrationTestOptions.DatabaseServerOptions serverOptions)
        {
            if (!serverOptions.IsEnabled)
            {
                return;
            }

            var announcer = new TextWriterAnnouncer(System.Console.Out);

            announcer.Heading("Testing Migration against SQLite");

            var factory = new SQLiteDbFactory();

            using (var connection = factory.CreateConnection(serverOptions.ConnectionString))
            {
                var processor = new SQLiteProcessor(connection, new SQLiteGenerator(), announcer, new ProcessorOptions(), factory);
                test(processor);
            }
        }
        public void SetUp()
        {
            // This connection used in the tests
            _dbFactory  = new SQLiteDbFactory();
            _connection = _dbFactory.CreateConnection(IntegrationTestOptions.SqlLite.ConnectionString);
            _connection.Open();
            _command = _connection.CreateCommand();

            // SUT
            _processor = new SQLiteProcessor(_connection, new SQLiteGenerator(), new TextWriterAnnouncer(TestContext.Out), new ProcessorOptions(), _dbFactory);

            column    = new Mock <ColumnDefinition>();
            tableName = "NewTable";
            tableNameThanMustBeEscaped = "123NewTable";
            columnName = "ColumnName";
            column.SetupGet(c => c.Name).Returns(columnName);
            column.SetupGet(c => c.IsNullable).Returns(true);
            column.SetupGet(c => c.Type).Returns(DbType.Int32);
        }
        public void SetUp()
        {
            // This connection used in the tests
            var factory = new SQLiteDbFactory();

            _connection = factory.CreateConnection("Data Source=:memory:;Version=3;New=True;");
            _connection.Open();
            _command = _connection.CreateCommand();

            // SUT
            _processor = new SQLiteProcessor(_connection, new SQLiteGenerator(), new TextWriterAnnouncer(System.Console.Out), new ProcessorOptions(), factory);

            column    = new Mock <ColumnDefinition>();
            tableName = "NewTable";
            tableNameThanMustBeEscaped = "123NewTable";
            columnName = "ColumnName";
            column.SetupGet(c => c.Name).Returns(columnName);
            column.SetupGet(c => c.IsNullable).Returns(true);
            column.SetupGet(c => c.Type).Returns(DbType.Int32);
        }
Exemplo n.º 6
0
 public SqliteSchemaDumper(SQLiteProcessor processor, IAnnouncer announcer)
 {
     Announcer = announcer;
     Processor = processor;
 }
Exemplo n.º 7
0
 public void SetUp()
 {
     ServiceScope = ServiceProvider.CreateScope();
     Processor    = ServiceScope.ServiceProvider.GetRequiredService <SQLiteProcessor>();
 }
Exemplo n.º 8
0
 public SqliteSchemaDumper(SQLiteProcessor processor)
 {
     Processor = processor;
 }