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); } }
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); } }
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); }
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); } }
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(); } }
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(); } } }