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