protected static void ExecuteWithPostgres(Action <IMigrationProcessor> test, IntegrationTestOptions.DatabaseServerOptions serverOptions, Boolean tryRollback)
        {
            if (!serverOptions.IsEnabled)
            {
                return;
            }
            var connection = new NpgsqlConnection(serverOptions.ConnectionString);
            var processor  = new PostgresProcessor(connection, new PostgresGenerator(), new TextWriterAnnouncer(System.Console.Out), new ProcessorOptions());

            test(processor);
        }
예제 #2
0
        private static void ExecuteWithSqlServer(IntegrationTestOptions.DatabaseServerOptions serverOptions, TextWriterAnnouncer announcer, SqlServer2005Generator generator, Action <IMigrationProcessor> test, bool tryRollback)
        {
            using (var connection = new SqlConnection(serverOptions.ConnectionString))
            {
                var processor = new SqlServerProcessor(connection, generator, announcer, new ProcessorOptions(), new SqlServerDbFactory());
                test(processor);

                if (tryRollback && !processor.WasCommitted)
                {
                    processor.RollbackTransaction();
                }
            }
        }
예제 #3
0
        protected static void ExecuteWithMySql(Action <IMigrationProcessor> test, IntegrationTestOptions.DatabaseServerOptions serverOptions)
        {
            if (!serverOptions.IsEnabled)
            {
                return;
            }

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

            announcer.Heading("Testing Migration against MySQL Server");

            using (var connection = new MySqlConnection(serverOptions.ConnectionString))
            {
                var processor = new MySqlProcessor(connection, new MySqlGenerator(), announcer, new ProcessorOptions(), new MySqlDbFactory());
                test(processor);
            }
        }
예제 #4
0
        protected static void ExecuteWithFirebird(Action <IMigrationProcessor> test, IntegrationTestOptions.DatabaseServerOptions serverOptions)
        {
            if (!serverOptions.IsEnabled)
            {
                return;
            }

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

            announcer.ShowSql = true;
            announcer.Heading("Testing Migration against Firebird Server");

            if (!System.IO.File.Exists("fbtest.fdb"))
            {
                FbConnection.CreateDatabase(serverOptions.ConnectionString);
            }

            using (var connection = new FbConnection(serverOptions.ConnectionString))
            {
                var options   = FirebirdOptions.AutoCommitBehaviour();
                var processor = new FirebirdProcessor(connection, new FirebirdGenerator(options), announcer, new ProcessorOptions(), new PostgresDbFactory(), options);

                try
                {
                    test(processor);
                }
                catch (Exception e)
                {
                    if (!processor.WasCommitted)
                    {
                        processor.RollbackTransaction();
                    }
                    throw e;
                }


                if (!processor.WasCommitted)
                {
                    processor.RollbackTransaction();
                }

                connection.Close();
            }
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
        public TemporaryDatabase(IntegrationTestOptions.DatabaseServerOptions connectionOptions, FirebirdLibraryProber prober)
        {
            if (!connectionOptions.IsEnabled)
            {
                Assert.Ignore();
            }

            DbFileName        = Path.GetTempFileName();
            _connectionString = new Lazy <string>(() =>
            {
                var csb = new FbConnectionStringBuilder(connectionOptions.ConnectionString)
                {
                    Pooling  = false,
                    Database = DbFileName,
                };

                return(prober.CreateDb(csb));
            });
        }
예제 #7
0
        protected static void ExecuteWithPostgres(Action <IMigrationProcessor> test, IntegrationTestOptions.DatabaseServerOptions serverOptions, Boolean tryRollback)
        {
            if (!serverOptions.IsEnabled)
            {
                return;
            }

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

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

            using (var connection = new NpgsqlConnection(serverOptions.ConnectionString))
            {
                var processor = new PostgresProcessor(connection, new PostgresGenerator(), new TextWriterAnnouncer(System.Console.Out), new ProcessorOptions(), new PostgresDbFactory());

                test(processor);

                if (!processor.WasCommitted)
                {
                    processor.RollbackTransaction();
                }
            }
        }