private void PrepareDatabase()
        {
            var ct = CancellationToken.None;

            using (var connection = new OracleConnection(ConnectionString))
                using (var context = new MigratorTestContext(connection))
                {
                    var manager = new OracleMigrationManager <MigratorTestContext>(
                        context, new DefaultNamingNormalizer <MigratorTestContext>(), LoggingManager.LoggerFactory);

                    manager.PrepareDatabaseAsync(ct)
                    .ConfigureAwait(false)
                    .GetAwaiter()
                    .GetResult();

                    string migrationId;
                    string className;
                    MigrationsTestHelper.GenerateMigrationInfo(
                        DateTimeOffset.UtcNow, out migrationId, out className);

                    //  Existing static migration
                    manager.AddMigrationAsync(migrationId, className, null, ct)
                    .ConfigureAwait(false)
                    .GetAwaiter()
                    .GetResult();
                }
        }
Ejemplo n.º 2
0
        public async Task GivenADatabaseWithMigrationsWhenAddingANewOneThenNoExceptionIsThrown()
        {
            string migrationId;
            string className;

            MigrationsTestHelper.GenerateMigrationInfo(out migrationId, out className);

            await _fixture.Manager.AddMigrationAsync(
                migrationId, className, $"Description for migration {migrationId}", CancellationToken.None);
        }
Ejemplo n.º 3
0
        public async Task GivenADatabaseWithMigrationsWhenGettingAllThenSomeMustBeReturned()
        {
            var ct = CancellationToken.None;

            string migrationId;
            string className;

            MigrationsTestHelper.GenerateMigrationInfo(out migrationId, out className);
            await _fixture.Manager.AddMigrationAsync(
                migrationId, className, $"Description for migration {migrationId}", ct);

            var migrationIds = await _fixture.Manager.GetAllMigrationsAsync(ct);

            Assert.NotNull(migrationIds);
            Assert.NotEmpty(migrationIds);
        }
Ejemplo n.º 4
0
        public async Task GivenADatabaseWithMigrationsWhenAddingAnExistingOneThenAnInvalidOperationExceptionMustBeThrown()
        {
            string migrationId;
            string className;

            MigrationsTestHelper.GenerateMigrationInfo(out migrationId, out className);

            await _fixture.Manager.AddMigrationAsync(
                migrationId, className, $"Description for migration {migrationId}", CancellationToken.None);

            await Assert.ThrowsAsync <InvalidOperationException>(async() =>
            {
                await _fixture.Manager.AddMigrationAsync(
                    migrationId, className, $"Description for migration {migrationId}", CancellationToken.None);
            });
        }
Ejemplo n.º 5
0
        public async Task GivenADatabaseWithMigrationsWhenAddingAnOlderOneThenAnInvalidOperationExceptionMustBeThrown()
        {
            MigrationsTestHelper.GenerateMigrationInfo(out string migrationId, out string className);

            await _fixture.Manager.AddMigrationAsync(
                migrationId, className, $"Description for migration {migrationId}", CancellationToken.None);

            await Assert.ThrowsAsync <InvalidOperationException>(async() =>
            {
                MigrationsTestHelper.GenerateMigrationInfo(
                    DateTimeOffset.UtcNow.AddDays(-1), out migrationId, out className);

                await _fixture.Manager.AddMigrationAsync(
                    migrationId, className, $"Description for migration {migrationId}", CancellationToken.None);
            });
        }
Ejemplo n.º 6
0
        private void PrepareDatabase()
        {
            var ct = CancellationToken.None;

            using (var context = new OracleMigratorTestContext(Options))
            {
                var manager = new OracleMigrationManager <OracleMigratorTestContext>(context, LoggingManager.LoggerFactory);

                manager.PrepareDatabaseAsync(ct)
                .ConfigureAwait(false)
                .GetAwaiter()
                .GetResult();

                MigrationsTestHelper.GenerateMigrationInfo(
                    DateTimeOffset.UtcNow, out var migrationId, out var className);

                //  Existing static migration
                manager.AddMigrationAsync(migrationId, className, null, ct)
                .ConfigureAwait(false)
                .GetAwaiter()
                .GetResult();
            }
        }