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