Esempio n. 1
0
        public void EnsureJournal_ShouldCallCreateJournal()
        {
            var mockJournal = new FakeJournal();
            var subject     = new Migrator(mockJournal, Mock.Of <IMigrationsProvider>(), Mock.Of <IProgressReporter>());

            subject.EnsureJournal();

            Assert.That(mockJournal.IsCreated);
        }
Esempio n. 2
0
        public void Plan_ShouldReturnAnError_WhenTheLastDeployedMigrationIsAnIncompleteOfflineMigration()
        {
            var mockProvider = new FakeMigrationsProvider().WithMigrations(new[] { _offlineMigration });
            var journal      = new FakeJournal().Created().WithMigrations(new[] { _offlineMigration.AsDeployedMigration(false) });

            // even if we tell it to include online migrations during an offline migration.
            var subject = new Migrator(journal, mockProvider, Mock.Of <IProgressReporter>(), true);

            var planResult = subject.Plan();

            Assert.That(planResult.OfflineErrorMessage, Is.Not.Null.And.Contains("incomplete prior offline migration."));
            Assert.That(planResult.OnlineErrorMessage, Is.EqualTo(planResult.OfflineErrorMessage));
        }
Esempio n. 3
0
        public void Plan_ShouldNotReturnAnyError_WhenTheLastDeployedMigrationIsAnIncompleteOnlineMigration_AndThereAreNoOfflineMigrationsToRun()
        {
            var mockProvider = new FakeMigrationsProvider().WithMigrations(new [] { _onlineMigration });
            var journal      = new FakeJournal().Created().WithMigrations(new [] { _onlineMigration.AsDeployedMigration(false) });

            var subject = new Migrator(journal, mockProvider, Mock.Of <IProgressReporter>());

            var planResult = subject.Plan();

            Assert.That(planResult.OnlineErrorMessage, Is.Null);
            Assert.That(planResult.OfflineErrorMessage, Is.Null);
            Assert.That(planResult.HasOfflineMigrations, Is.False);
            Assert.That(planResult.HasOnlineMigrations, Is.True, "there should be an online migration that needs to resume");
            Assert.That(planResult.HasStoredCodeChanges, Is.False);
        }
Esempio n. 4
0
        public void Plan_ShouldNotReturnAnyError_WhenThereAreNoMigrations()
        {
            // return empty lists
            var mockProvider = new FakeMigrationsProvider();
            var emptyJournal = new FakeJournal().Created();

            var subject = new Migrator(emptyJournal, mockProvider, Mock.Of <IProgressReporter>());

            var planResult = subject.Plan();

            Assert.That(planResult.OnlineErrorMessage, Is.Null);
            Assert.That(planResult.OfflineErrorMessage, Is.Null);
            Assert.That(planResult.HasOfflineMigrations, Is.False);
            Assert.That(planResult.HasOnlineMigrations, Is.False);
            Assert.That(planResult.HasStoredCodeChanges, Is.False);
        }