public void GivenPluginWithGuiSetAndOpenedDuneLocationCalculationsView_WhenRemovingDataForOpenedViewAndObserversNotified_ThenNoExceptionThrown() { // Given var mocks = new MockRepository(); var projectStore = mocks.Stub <IStoreProject>(); var projectMigrator = mocks.Stub <IMigrateProject>(); var projectFactory = mocks.Stub <IProjectFactory>(); var project = mocks.Stub <IProject>(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, projectFactory, new GuiCoreSettings())) { gui.Plugins.AddRange(new PluginBase[] { new DuneErosionPlugin() }); gui.Run(); gui.SetProject(project, null); var calculations = new DuneLocationCalculationsForTargetProbability(0.1); var failureMechanism = new DuneErosionFailureMechanism { DuneLocationCalculationsForUserDefinedTargetProbabilities = { calculations } }; gui.SetProject(project, null); gui.DocumentViewController.CloseAllViews(); gui.DocumentViewController.OpenViewForData(new DuneLocationCalculationsForUserDefinedTargetProbabilityContext(calculations, failureMechanism, assessmentSection)); IView view = gui.ViewHost.DocumentViews.First(); // Precondition Assert.IsInstanceOf <DuneLocationCalculationsView>(view); // When failureMechanism.DuneLocationCalculationsForUserDefinedTargetProbabilities.Remove(calculations); void Call() => failureMechanism.DuneLocationCalculationsForUserDefinedTargetProbabilities.NotifyObservers(); // Then Assert.DoesNotThrow(Call); mocks.VerifyAll(); } }
public void GivenPluginWithGuiSetAndOpenedDuneLocationCalculationsView_WhenUserDefinedTargetProbabilityRemovedFromCollectionAndObserversNotified_ThenViewTitleUpdated() { // Given var mocks = new MockRepository(); var projectStore = mocks.Stub <IStoreProject>(); var projectMigrator = mocks.Stub <IMigrateProject>(); var projectFactory = mocks.Stub <IProjectFactory>(); var project = mocks.Stub <IProject>(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, projectFactory, new GuiCoreSettings())) { gui.Plugins.AddRange(new PluginBase[] { new DuneErosionPlugin() }); gui.Run(); gui.SetProject(project, null); const double targetProbability = 0.1; var removedCalculations = new DuneLocationCalculationsForTargetProbability(targetProbability); var affectedCalculations = new DuneLocationCalculationsForTargetProbability(targetProbability); var failureMechanism = new DuneErosionFailureMechanism { DuneLocationCalculationsForUserDefinedTargetProbabilities = { removedCalculations, affectedCalculations } }; gui.DocumentViewController.CloseAllViews(); gui.DocumentViewController.OpenViewForData(new DuneLocationCalculationsForUserDefinedTargetProbabilityContext(affectedCalculations, failureMechanism, assessmentSection)); IView view = gui.ViewHost.DocumentViews.First(); // Precondition Assert.IsInstanceOf <DuneLocationCalculationsView>(view); Assert.IsTrue(AvalonDockViewHostTestHelper.IsTitleSet((AvalonDockViewHost)gui.ViewHost, view, "Hydraulische belastingen - 1/10 (1)")); // When failureMechanism.DuneLocationCalculationsForUserDefinedTargetProbabilities.Remove(removedCalculations); failureMechanism.DuneLocationCalculationsForUserDefinedTargetProbabilities.NotifyObservers(); // Then Assert.IsTrue(AvalonDockViewHostTestHelper.IsTitleSet((AvalonDockViewHost)gui.ViewHost, view, "Hydraulische belastingen - 1/10")); mocks.VerifyAll(); } }