Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationActivityTest.cs =================================================================== diff -u -r248229db928c9e5556be704ed274226f80b4ef19 -ra08664f5b196db59fc81cbbd33672627060d38c0 --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationActivityTest.cs (.../WaveHeightCalculationActivityTest.cs) (revision 248229db928c9e5556be704ed274226f80b4ef19) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationActivityTest.cs (.../WaveHeightCalculationActivityTest.cs) (revision a08664f5b196db59fc81cbbd33672627060d38c0) @@ -154,6 +154,8 @@ const string locationName = "locationName"; const string activityName = "GetActivityName"; const string calculationName = "locationName"; + const string ringId = "11-1"; + const double norm = 30; var hydraulicBoundaryLocationMock = mockRepository.Stub(); hydraulicBoundaryLocationMock.Expect(hbl => hbl.Name).Return(locationName).Repeat.AtLeastOnce(); @@ -166,7 +168,9 @@ var activity = new WaveHeightCalculationActivity(calculationMessageProviderMock, hydraulicBoundaryLocationMock, - validFilePath, "", 30); + validFilePath, + ringId, + norm); using (new WaveHeightCalculationServiceConfig()) { @@ -177,6 +181,10 @@ // Assert Assert.AreSame(calculationMessageProviderMock, testService.MessageProvider); + Assert.AreSame(hydraulicBoundaryLocationMock, testService.HydraulicBoundaryLocation); + Assert.AreEqual(validFilePath, testService.HydraulicBoundaryDatabaseFilePath); + Assert.AreEqual(ringId, testService.RingId); + Assert.AreEqual(norm, testService.Norm); } Assert.AreEqual(ActivityState.Executed, activity.State); mockRepository.VerifyAll(); Index: Ringtoets/Common/test/Ringtoets.Common.Service.TestUtil.Test/Ringtoets.Common.Service.TestUtil.Test.csproj =================================================================== diff -u -r248229db928c9e5556be704ed274226f80b4ef19 -ra08664f5b196db59fc81cbbd33672627060d38c0 --- Ringtoets/Common/test/Ringtoets.Common.Service.TestUtil.Test/Ringtoets.Common.Service.TestUtil.Test.csproj (.../Ringtoets.Common.Service.TestUtil.Test.csproj) (revision 248229db928c9e5556be704ed274226f80b4ef19) +++ Ringtoets/Common/test/Ringtoets.Common.Service.TestUtil.Test/Ringtoets.Common.Service.TestUtil.Test.csproj (.../Ringtoets.Common.Service.TestUtil.Test.csproj) (revision a08664f5b196db59fc81cbbd33672627060d38c0) @@ -57,7 +57,6 @@ - Fisheye: Tag a08664f5b196db59fc81cbbd33672627060d38c0 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Service.TestUtil.Test/TestWaveHeightCalculationServiceTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveHeightLocationsContextTreeNodeInfoTest.cs =================================================================== diff -u -r248229db928c9e5556be704ed274226f80b4ef19 -ra08664f5b196db59fc81cbbd33672627060d38c0 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveHeightLocationsContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsContextTreeNodeInfoTest.cs) (revision 248229db928c9e5556be704ed274226f80b4ef19) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveHeightLocationsContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsContextTreeNodeInfoTest.cs) (revision a08664f5b196db59fc81cbbd33672627060d38c0) @@ -415,6 +415,75 @@ mockRepository.VerifyAll(); } + [Test] + public void CalculateDesignWaterLevelsFromContextMenu_Always_SendsRightInputToCalculationService() + { + // Setup + string filePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite"); + + var guiMock = mockRepository.DynamicMock(); + var location = new HydraulicBoundaryLocation(1, "HydraulicBoundaryLocation", 1.1, 2.2); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { + Contribution = 1 + }; + var assessmentSectionMock = mockRepository.Stub(); + assessmentSectionMock.Stub(a => a.Id).Return("Id"); + assessmentSectionMock.Stub(a => a.GetFailureMechanisms()).Return(new[] + { + failureMechanism + }); + assessmentSectionMock.Stub(a => a.FailureMechanismContribution).Return(new FailureMechanismContribution(Enumerable.Empty(), 1, 300)); + assessmentSectionMock.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = filePath, + Locations = + { + location + } + }; + + var grassCoverErosionOutwardsHydraulicBoundaryLocation = new GrassCoverErosionOutwardsHydraulicBoundaryLocation(location); + var context = new GrassCoverErosionOutwardsWaveHeightLocationsContext(new ObservableList + { + grassCoverErosionOutwardsHydraulicBoundaryLocation + }, assessmentSectionMock); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(g => g.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + guiMock.Expect(g => g.MainWindow).Return(mockRepository.Stub()); + mockRepository.ReplayAll(); + + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + plugin.Gui = guiMock; + plugin.Activate(); + + using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl)) + using (new WaveHeightCalculationServiceConfig()) + { + var testService = (TestHydraulicBoundaryLocationCalculationService) WaveHeightCalculationService.Instance; + + // Call + contextMenuAdapter.Items[contextMenuRunWaveHeightCalculationsIndex].PerformClick(); + + // Assert + Assert.AreSame(grassCoverErosionOutwardsHydraulicBoundaryLocation, testService.HydraulicBoundaryLocation); + Assert.AreEqual(filePath, testService.HydraulicBoundaryDatabaseFilePath); + Assert.AreEqual(assessmentSectionMock.Id, testService.RingId); + + var expectedNorm = assessmentSectionMock.FailureMechanismContribution.Norm / + (failureMechanism.Contribution / 100) * + failureMechanism.GeneralInput.N; + Assert.AreEqual(expectedNorm, testService.Norm); + } + } + } + mockRepository.VerifyAll(); + } + private static TreeNodeInfo GetInfo(GrassCoverErosionOutwardsPlugin plugin) { return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(GrassCoverErosionOutwardsWaveHeightLocationsContext));