Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/WaterLevelCalculationsForUserDefinedTargetProbabilitiesGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r9087c4fdc971c7bad6f72298863ab7821eaf31b9 -rc799f3def0c4e94bda8d5ffcbfa32cadea04ffbd --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/WaterLevelCalculationsForUserDefinedTargetProbabilitiesGroupContextTreeNodeInfoTest.cs (.../WaterLevelCalculationsForUserDefinedTargetProbabilitiesGroupContextTreeNodeInfoTest.cs) (revision 9087c4fdc971c7bad6f72298863ab7821eaf31b9) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/WaterLevelCalculationsForUserDefinedTargetProbabilitiesGroupContextTreeNodeInfoTest.cs (.../WaterLevelCalculationsForUserDefinedTargetProbabilitiesGroupContextTreeNodeInfoTest.cs) (revision c799f3def0c4e94bda8d5ffcbfa32cadea04ffbd) @@ -51,6 +51,7 @@ using Riskeer.HydraRing.Calculation.Calculator.Factory; using Riskeer.HydraRing.Calculation.Data.Input; using Riskeer.HydraRing.Calculation.TestUtil.Calculator; +using Riskeer.Integration.Data; using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; namespace Riskeer.Integration.Plugin.Test.TreeNodeInfos @@ -209,6 +210,65 @@ } [Test] + public void ContextMenuStrip_ClickOnAddTargetProbabilityItem_CalculationsForTargetProbabilityAddedAndObserversNotified() + { + // Given + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = + { + Locations = + { + new TestHydraulicBoundaryLocation("Location 1"), + new TestHydraulicBoundaryLocation("Location 2") + } + } + }; + + var calculations = new ObservableList(); + var context = new WaterLevelCalculationsForUserDefinedTargetProbabilitiesGroupContext(calculations, assessmentSection); + + var mockRepository = new MockRepository(); + var calculationsObserver = mockRepository.StrictMock(); + calculationsObserver.Expect(o => o.UpdateObserver()); + calculations.Attach(calculationsObserver); + + using (var treeViewControl = new TreeViewControl()) + { + IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub(mockRepository); + + var gui = mockRepository.Stub(); + gui.Stub(g => g.MainWindow).Return(mainWindow); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.ProjectStore).Return(mockRepository.Stub()); + + mockRepository.ReplayAll(); + + using (var plugin = new RiskeerPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + plugin.Gui = gui; + plugin.Activate(); + + using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl)) + { + // When + contextMenuAdapter.Items[contextMenuAddTargetProbabilityIndex].PerformClick(); + + // Then + Assert.AreEqual(1, calculations.Count); + Assert.AreEqual(0.1, calculations[0].TargetProbability); + Assert.AreEqual(2, calculations[0].HydraulicBoundaryLocationCalculations.Count); + } + } + } + + mockRepository.VerifyAll(); + } + + [Test] public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_ContextMenuItemCalculateAllDisabledAndTooltipSet() { // Setup