예제 #1
1
        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);
            }
        }
예제 #2
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);
            }
        }
예제 #3
0
        protected static void ExecuteWithSqlServer2014(Action<IMigrationProcessor> test, bool tryRollback)
        {

            var serverOptions = IntegrationTestOptions.SqlServer2014;

            if (!serverOptions.IsEnabled)
                return;

            var announcer = new TextWriterAnnouncer(System.Console.Out);
            announcer.Heading("Testing Migration against MS SQL Server 2014");
            var generator = new SqlServer2014Generator();

            ExecuteWithSqlServer(serverOptions, announcer, generator, test, tryRollback);
        }
예제 #4
0
        private void Execute(string task)
        {
            tbAnnouncer.Clear();

            var version = (int)numVersion.Value;
            var steps = (int)numSteps.Value;
            var tags = new List<string>();
            var profile = tbProfile.Text;
            foreach (var item in lbTags.SelectedItems)
            {
                tags.Add(item.ToString());
            }

            var announcer = new TextWriterAnnouncer(new TextBoxStreamWriter(tbAnnouncer));
            announcer.Heading("Migrate database");

            var runnerContext = new RunnerContext(announcer)
            {
                Database = "SqlServer2008",
                Connection = ConfigurationManager.ConnectionStrings["FluentMigrator"].ConnectionString,

                Target = "DatabaseProject.dll",
                PreviewOnly = false,
                Namespace = "DatabaseProject",
                NestedNamespaces = true,
                Task = task,
                Version = version,
                Steps = steps,
                Tags = tags,
                //WorkingDirectory = "C:\\temp",
                Profile = profile,
                Timeout = 30,
                TransactionPerSession = true
            };

            var executor = new TaskExecutor(runnerContext);


            try
            {
                executor.Execute();
            }
            catch (Exception ex)
            {
                tbAnnouncer.AppendText("Exception: " + ex.Message);
            }

        }
예제 #5
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 FirebirdDbFactory(), options);

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

                connection.Close();
            }
        }
예제 #6
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();
                }
            }
        }