Ejemplo n.º 1
0
        //[InlineData(SupportedDatabaseTypes.Oracle)]
        public async Task DbProvider_ExampleRepository_Success(SupportedDatabaseTypes databaseType)
        {
            var overrideConfig = OverrideConfig.GetInMemoryOverrideConfig(databaseType);

            overrideConfig.TryGetValue("database:schema", out var schema);
            //overrideConfig.Add("database:schemaprefix:id", "EX");
            //overrideConfig.Add("database:migration:schemaprefix:id", "EX");
            var logFile    = $"DbProvider_ExampleRepository_Success_{schema}_{databaseType}.sql";
            var loglogFile = $"DbProvider_ExampleRepository_Success_{schema}_{databaseType}.log";

            overrideConfig.Add("Logging:Migration:File:ShowSql", "false");
            overrideConfig.Add("Logging:Migration:ShowElapsedTime", "True");
            overrideConfig.Add("Logging:Migration:File", logFile);
            overrideConfig.Add("Logging:Migration:Console:ShowSql", "false");
            //overrideConfig.Add("Logging:Migration:Console", "True");
            overrideConfig.Add("Logging:File", loglogFile);

            var provider = MigrationBuilder.BuildMigration(databaseType, overrideConfig, assemblies: new [] { typeof(AddPersonTable).Assembly });

            using var scope = provider.CreateScope();
            try
            {
                var migrationRunner = scope.ServiceProvider.GetService <IMigrationRunner>();
                var configuration   = scope.ServiceProvider.GetService <IConfiguration>();
                logFile = configuration.GetMigrationLogFile();
                migrationRunner.DropSchema(scope.ServiceProvider.GetVersionTableMetaData());
                migrationRunner.MigrateUp();
                await DbExampleExecutor.ExecuteDbExample(databaseType, overrideConfig);

                migrationRunner.DropSchema(scope.ServiceProvider.GetVersionTableMetaData());
            }
            catch (InvalidOperationException)
            {
                //
            }

            ShowLogFileContent(logFile);
        }
Ejemplo n.º 2
0
 public async Task DbProvider_ExampleRepository_WithDbProviderFactory_Success(SupportedDatabaseTypes databaseType)
 {
     var overrideConfig = OverrideConfig.GetInMemoryOverrideConfig(databaseType);
     await DbExampleExecutor.ExecuteDbExample(databaseType, true, overrideConfig);
 }