Exemple #1
0
        public void ShouldCommitAllChangesToTheDatabase()
        {
            var testSubject = new ChangePlan(Do.Unapply, new[] { 4, 3 });

            testSubject.ApplyTo(_database, _definedMigrations.ToLoaders());
            _database.CommittedTheChanges.Should().BeTrue();
        }
Exemple #2
0
        public void PlanToUnapplyShouldLoadCorrectMigrationsAndUnapplyThemAgainstTheDatabase()
        {
            var testSubject = new ChangePlan(Do.Unapply, new[] { 4, 3 });

            testSubject.ApplyTo(_database, _definedMigrations.ToLoaders());
            _database.UnappliedMigrations.Should().ContainInOrder(MigrationsForVersions(_definedMigrations, 4, 3));
        }
Exemple #3
0
        public void PlanToUnapplyShouldSetDatabaseVersionToOneLessThanLastMigrationUnapplied()
        {
            var testSubject = new ChangePlan(Do.Unapply, new[] { 4, 3 });

            testSubject.ApplyTo(_database, _definedMigrations.ToLoaders());
            _database.CurrentVersion.Result.Should().Be(2);
        }
 public void ApplyingNoMigrationsShouldDoNothing()
 {
     var testSubject = new ChangePlan(Do.Apply, new int[] {});
     testSubject.ApplyTo(this._database, this._definedMigrations.ToLoaders());
     this._database.AppliedMigrations.Should().BeEmpty();
     this._database.CommittedTheChanges.Should().BeFalse();
 }
Exemple #5
0
        public void ApplyingNoMigrationsShouldDoNothing()
        {
            var testSubject = new ChangePlan(Do.Apply, new int[] { });

            testSubject.ApplyTo(_database, _definedMigrations.ToLoaders());
            _database.AppliedMigrations.Should().BeEmpty();
            _database.CommittedTheChanges.Should().BeFalse();
        }
        public void UnapplyingMigrationShouldNotifyUser()
        {
            var testSubject = new ChangePlan(Do.Unapply, new[] {5, 4});
            testSubject.ApplyTo(new DatabaseLocalMemory(), TestData.Migrations(4, 5).ToLoaders());

            this._messagesSentToUser.Should().ContainInOrder(new[]
                {
                    "Unapplying version 5 from the database.",
                    "Unapplying version 4 from the database.",
                });
        }
        public void ApplyingMigrationShouldNotifyUser()
        {
            var testSubject = new ChangePlan(Do.Apply, new[] {3, 4});
            testSubject.ApplyTo(new DatabaseLocalMemory(), TestData.Migrations(3, 4).ToLoaders());

            this._messagesSentToUser.Should().ContainInOrder(new[]
                {
                    "Applying version 3 to the database.",
                    "Applying version 4 to the database."
                });
        }
        public void UnapplyingMigrationShouldNotifyUser()
        {
            var testSubject = new ChangePlan(Do.Unapply, new[] { 5, 4 });

            testSubject.ApplyTo(new DatabaseLocalMemory(), TestData.Migrations(4, 5).ToLoaders());

            _messagesSentToUser.Should().ContainInOrder(new[]
            {
                "Unapplying version 5 from the database.",
                "Unapplying version 4 from the database."
            });
        }
Exemple #9
0
        public void ShouldGiveGoodErrorWhenAttemptToApplyUndefinedMigration()
        {
            var    testSubject = new ChangePlan(Do.Unapply, new[] { 19 });
            Action application = () => testSubject.ApplyTo(_database, _definedMigrations.ToLoaders());

            application.Should().Throw <TerminateProgramWithMessageException>().WithMessage(
                @"Missing migration 19

I needed to Unapply migration 19, but could not find a definition for it.
Please make sure there is a file in your migration directory named

'19_some_name.migration.sql'."
                ).And.ErrorLevel.Should().Be(1);
        }
        public void ShouldGiveGoodErrorWhenAttemptToApplyUndefinedMigration()
        {
            var testSubject = new ChangePlan(Do.Unapply, new[] {19});
            Action application = () => testSubject.ApplyTo(this._database, this._definedMigrations.ToLoaders());
            application.ShouldThrow<TerminateProgramWithMessageException>().WithMessage(
                @"Missing migration 19

I needed to Unapply migration 19, but could not find a definition for it.
Please make sure there is a file in your migration directory named

'19_some_name.migration.sql'."
                ).And.ErrorLevel.Should().Be(1);
        }
 public void ShouldCommitAllChangesToTheDatabase()
 {
     var testSubject = new ChangePlan(Do.Unapply, new[] {4, 3});
     testSubject.ApplyTo(this._database, this._definedMigrations.ToLoaders());
     this._database.CommittedTheChanges.Should().BeTrue();
 }
 public void PlanToUnapplyShouldSetDatabaseVersionToOneLessThanLastMigrationUnapplied()
 {
     var testSubject = new ChangePlan(Do.Unapply, new[] {4, 3});
     testSubject.ApplyTo(this._database, this._definedMigrations.ToLoaders());
     this._database.CurrentVersion.Result.Should().Be(2);
 }
 public void PlanToUnapplyShouldLoadCorrectMigrationsAndUnapplyThemAgainstTheDatabase()
 {
     var testSubject = new ChangePlan(Do.Unapply, new[] {4, 3});
     testSubject.ApplyTo(this._database, this._definedMigrations.ToLoaders());
     this._database.UnappliedMigrations.Should().ContainInOrder(MigrationsForVersions(this._definedMigrations, 4, 3));
 }