コード例 #1
0
ファイル: Scenario006.cs プロジェクト: lecaillon/Evolve
 public void Scenario_repeatable_migration_executed_everytime()
 {
     for (int i = 1; i <= 3; i++)
     {
         Evolve.Migrate();
         Assert.True(Evolve.AppliedMigrations.Count == 1, $"This repeat always migration should be executed each time.");
         Assert.True(MetadataTable.GetAllAppliedRepeatableMigration().Count() == i);
         Assert.False(MetadataTable.GetAllAppliedMigration().Any());
     }
 }
コード例 #2
0
ファイル: Scenario003.cs プロジェクト: lecaillon/Evolve
        public void Scenario_postresql_tx_commit_all_only_when_every_scripts_succeed()
        {
            // Arrange
            Evolve.TransactionMode = TransactionKind.CommitAll;
            // Assert migration fails on last script, nothing applied
            Evolve.AssertMigrateThrows <EvolveException>(Cnn);
            Assert.True(Evolve.AppliedMigrations.Count == 0, $"There should be no migration applied when a migration fails in CommitAll mode.");
            Assert.False(MetadataTable.GetAllAppliedMigration().Any());
            Assert.False(MetadataTable.GetAllAppliedRepeatableMigration().Any());

            // Arrange
            Evolve.TargetVersion = new("2_0");
            // Assert migration succeeds, 2 scripts applied
            Evolve.AssertMigrateIsSuccessful(Cnn);
        }
コード例 #3
0
ファイル: Scenario004.cs プロジェクト: lecaillon/Evolve
        public void Scenario_postresql_tx_rollback_all_either_when_migration_succeeds_or_fails()
        {
            // Arrange
            Evolve.TransactionMode = TransactionKind.RollbackAll;
            // Assert migration fails on last script, nothing applied
            Evolve.AssertMigrateThrows <EvolveException>(Cnn);
            Assert.True(Evolve.AppliedMigrations.Count == 0, $"There should be no migration applied when a migration fails in RollbackAll mode.");
            Assert.False(MetadataTable.GetAllAppliedMigration().Any());
            Assert.False(MetadataTable.GetAllAppliedRepeatableMigration().Any());

            // Arrange
            Evolve.TargetVersion = new("2_0");
            // Assert migration succeeds, nothing applied
            Evolve.Migrate();
            Assert.True(Evolve.AppliedMigrations.Count == 0, $"There should be no migration applied when a migration succeeds in RollbackAll mode.");
            Assert.False(MetadataTable.GetAllAppliedMigration().Any());
            Assert.False(MetadataTable.GetAllAppliedRepeatableMigration().Any());
        }