Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsDesignWaterLevelCalculationsGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r90fddc8b4b22bab44df62ddf4f7118dc15926550 -rbcab4543e8b75f5d00850c4e7780097cfabf67da --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsDesignWaterLevelCalculationsGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelCalculationsGroupContextTreeNodeInfoTest.cs) (revision 90fddc8b4b22bab44df62ddf4f7118dc15926550) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsDesignWaterLevelCalculationsGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelCalculationsGroupContextTreeNodeInfoTest.cs) (revision bcab4543e8b75f5d00850c4e7780097cfabf67da) @@ -20,28 +20,45 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Drawing; +using System.IO; using System.Linq; +using System.Threading; +using System.Windows.Forms; using Core.Common.Base; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.ContextMenu; +using Core.Common.Gui.Forms.MainWindow; +using Core.Common.Gui.Forms.ViewHost; +using Core.Common.Gui.TestUtil.ContextMenu; using Core.Common.TestUtil; +using Core.Common.Util; +using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Service; +using Ringtoets.Common.Service.TestUtil; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; +using Ringtoets.HydraRing.Calculation.Calculator; +using Ringtoets.HydraRing.Calculation.Calculator.Factory; +using Ringtoets.HydraRing.Calculation.Data.Input; +using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.GrassCoverErosionOutwards.Plugin.Test.TreeNodeInfos { [TestFixture] - public class GrassCoverErosionOutwardsDesignWaterLevelCalculationsGroupContextTreeNodeInfoTest + public class GrassCoverErosionOutwardsDesignWaterLevelCalculationsGroupContextTreeNodeInfoTest : NUnitFormTest { + private const int contextMenuRunDesignWaterLevelCalculationsIndex = 0; + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); + [Test] public void Initialized_Always_ExpectedPropertiesSet() { @@ -109,11 +126,13 @@ { // Setup var mockRepository = new MockRepository(); - var assessmentSection = mockRepository.StrictMock(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository); var menuBuilder = mockRepository.StrictMock(); using (mockRepository.Ordered()) { + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.Build()).Return(null); @@ -145,9 +164,221 @@ } [Test] - public void ChildNodeObjects_Always_ReturnsExpectedChildData() + [Apartment(ApartmentState.STA)] + public void CalculateDesignWaterLevelsFromContextMenu_AllRequiredInputSet_SendsRightInputToCalculationService() { // Setup + var mockRepository = new MockRepository(); + var assessmentSection = new AssessmentSectionStub + { + HydraulicBoundaryDatabase = + { + FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") + } + }; + + var hydraulicBoundaryLocation1 = new TestHydraulicBoundaryLocation("locationName 1"); + var hydraulicBoundaryLocation2 = new TestHydraulicBoundaryLocation("locationName 2"); + assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation1, + hydraulicBoundaryLocation2 + }); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { + Contribution = 5 + }; + failureMechanism.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation1, + hydraulicBoundaryLocation2 + }); + + var context = new GrassCoverErosionOutwardsDesignWaterLevelCalculationsGroupContext(new ObservableList(), + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mockRepository.Stub(); + 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.MainWindow).Return(mockRepository.Stub()); + gui.Stub(g => g.DocumentViewController).Return(mockRepository.Stub()); + + var designWaterLevelCalculator = new TestDesignWaterLevelCalculator(); + var calculatorFactory = mockRepository.Stub(); + calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath, string.Empty)).Return(designWaterLevelCalculator).Repeat.Times(10); + mockRepository.ReplayAll(); + + DialogBoxHandler = (name, wnd) => + { + // Expect an activity dialog which is automatically closed + }; + + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + plugin.Gui = gui; + plugin.Activate(); + + using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl)) + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + contextMenuAdapter.Items[contextMenuRunDesignWaterLevelCalculationsIndex].PerformClick(); + + // Assert + double mechanismSpecificFactorizedSignalingNorm = GetExpectedNorm(failureMechanism, + () => assessmentSection.FailureMechanismContribution.SignalingNorm / 30); + AssertHydraRingCalculationInput(hydraulicBoundaryLocation1, + mechanismSpecificFactorizedSignalingNorm, + designWaterLevelCalculator.ReceivedInputs.ElementAt(0)); + AssertHydraRingCalculationInput(hydraulicBoundaryLocation2, + mechanismSpecificFactorizedSignalingNorm, + designWaterLevelCalculator.ReceivedInputs.ElementAt(1)); + + double mechanismSpecificSignalingNorm = GetExpectedNorm(failureMechanism, () => assessmentSection.FailureMechanismContribution.SignalingNorm); + AssertHydraRingCalculationInput(hydraulicBoundaryLocation1, + mechanismSpecificSignalingNorm, + designWaterLevelCalculator.ReceivedInputs.ElementAt(2)); + AssertHydraRingCalculationInput(hydraulicBoundaryLocation2, + mechanismSpecificSignalingNorm, + designWaterLevelCalculator.ReceivedInputs.ElementAt(3)); + + double mechanismSpecificLowerLimitNorm = GetExpectedNorm(failureMechanism, () => assessmentSection.FailureMechanismContribution.LowerLimitNorm); + AssertHydraRingCalculationInput(hydraulicBoundaryLocation1, + mechanismSpecificLowerLimitNorm, + designWaterLevelCalculator.ReceivedInputs.ElementAt(4)); + AssertHydraRingCalculationInput(hydraulicBoundaryLocation2, + mechanismSpecificLowerLimitNorm, + designWaterLevelCalculator.ReceivedInputs.ElementAt(5)); + + double lowerLimitNorm = assessmentSection.FailureMechanismContribution.LowerLimitNorm; + AssertHydraRingCalculationInput(hydraulicBoundaryLocation1, + lowerLimitNorm, + designWaterLevelCalculator.ReceivedInputs.ElementAt(6)); + AssertHydraRingCalculationInput(hydraulicBoundaryLocation2, + lowerLimitNorm, + designWaterLevelCalculator.ReceivedInputs.ElementAt(7)); + + double factorizedLowerLimitNorm = lowerLimitNorm * 30; + AssertHydraRingCalculationInput(hydraulicBoundaryLocation1, + factorizedLowerLimitNorm, + designWaterLevelCalculator.ReceivedInputs.ElementAt(8)); + AssertHydraRingCalculationInput(hydraulicBoundaryLocation2, + factorizedLowerLimitNorm, + designWaterLevelCalculator.ReceivedInputs.ElementAt(9)); + } + } + } + + mockRepository.VerifyAll(); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void GivenHydraulicBoundaryLocationThatSucceeds_CalculatingDesignWaterLevelFromContextMenu_ThenLogMessagesAddedOutputSet() + { + // Given + var mockRepository = new MockRepository(); + var assessmentSection = new AssessmentSectionStub + { + HydraulicBoundaryDatabase = + { + FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") + } + }; + + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("locationName"); + assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation + }); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { + Contribution = 5 + }; + failureMechanism.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation + }); + + var context = new GrassCoverErosionOutwardsDesignWaterLevelCalculationsGroupContext(new ObservableList(), + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mockRepository.Stub(); + 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.MainWindow).Return(mockRepository.Stub()); + gui.Stub(g => g.DocumentViewController).Return(mockRepository.Stub()); + + var designWaterLevelCalculator = new TestDesignWaterLevelCalculator + { + Converged = false + }; + var calculatorFactory = mockRepository.Stub(); + calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath, string.Empty)).Return(designWaterLevelCalculator).Repeat.Times(5); + mockRepository.ReplayAll(); + + DialogBoxHandler = (name, wnd) => + { + // Expect an activity dialog which is automatically closed + }; + + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + plugin.Gui = gui; + plugin.Activate(); + + using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl)) + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // When + Action call = () => contextMenuAdapter.Items[contextMenuRunDesignWaterLevelCalculationsIndex].PerformClick(); + + // Then + TestHelper.AssertLogMessages(call, messages => + { + string[] msgs = messages.ToArray(); + Assert.AreEqual(40, msgs.Length); + AssertHydraulicBoundaryLocationCalculationMessages(hydraulicBoundaryLocation, msgs, 0, "Iv->IIv"); + AssertHydraulicBoundaryLocationCalculationMessages(hydraulicBoundaryLocation, msgs, 7, "IIv->IIIv"); + AssertHydraulicBoundaryLocationCalculationMessages(hydraulicBoundaryLocation, msgs, 14, "IIIv->IVv"); + AssertHydraulicBoundaryLocationCalculationMessages(hydraulicBoundaryLocation, msgs, 21, "IVv->Vv"); + AssertHydraulicBoundaryLocationCalculationMessages(hydraulicBoundaryLocation, msgs, 28, "Vv->VIv"); + + Assert.AreEqual($"Waterstand berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie Iv->IIv) is gelukt.", msgs.ElementAt(35)); + Assert.AreEqual($"Waterstand berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie IIv->IIIv) is gelukt.", msgs.ElementAt(36)); + Assert.AreEqual($"Waterstand berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie IIIv->IVv) is gelukt.", msgs.ElementAt(37)); + Assert.AreEqual($"Waterstand berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie IVv->Vv) is gelukt.", msgs.ElementAt(38)); + Assert.AreEqual($"Waterstand berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie Vv->VIv) is gelukt.", msgs.ElementAt(39)); + }); + + AssertHydraulicBoundaryLocationCalculationOutput(designWaterLevelCalculator, failureMechanism.WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm.Single().Output); + AssertHydraulicBoundaryLocationCalculationOutput(designWaterLevelCalculator, failureMechanism.WaterLevelCalculationsForMechanismSpecificSignalingNorm.Single().Output); + AssertHydraulicBoundaryLocationCalculationOutput(designWaterLevelCalculator, failureMechanism.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm.Single().Output); + AssertHydraulicBoundaryLocationCalculationOutput(designWaterLevelCalculator, assessmentSection.WaterLevelCalculationsForLowerLimitNorm.Single().Output); + AssertHydraulicBoundaryLocationCalculationOutput(designWaterLevelCalculator, assessmentSection.WaterLevelCalculationsForFactorizedLowerLimitNorm.Single().Output); + } + } + } + + mockRepository.VerifyAll(); + } + + [Test] + public void ChildNodeObjects_Always_ReturnsChildrenOfData() + { + // Setup const double signalingNorm = 0.002; const double lowerLimitNorm = 0.005; @@ -201,6 +432,35 @@ } } + private static void AssertHydraulicBoundaryLocationCalculationOutput(IDesignWaterLevelCalculator designWaterLevelCalculator, + HydraulicBoundaryLocationCalculationOutput actualOutput) + { + Assert.AreEqual(designWaterLevelCalculator.DesignWaterLevel, actualOutput.Result, actualOutput.Result.GetAccuracy()); + Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, actualOutput.CalculationConvergence); + } + + private static void AssertHydraulicBoundaryLocationCalculationMessages(HydraulicBoundaryLocation hydraulicBoundaryLocation, + IEnumerable messages, + int startIndex, + string categoryName) + { + Assert.AreEqual($"Waterstand berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie {categoryName}) is gestart.", messages.ElementAt(startIndex)); + CalculationServiceTestHelper.AssertValidationStartMessage(messages.ElementAt(startIndex + 1)); + CalculationServiceTestHelper.AssertValidationEndMessage(messages.ElementAt(startIndex + 2)); + CalculationServiceTestHelper.AssertCalculationStartMessage(messages.ElementAt(startIndex + 3)); + Assert.AreEqual($"Waterstand berekening voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie {categoryName}) is niet geconvergeerd.", messages.ElementAt(startIndex + 4)); + StringAssert.StartsWith("Waterstand berekening is uitgevoerd op de tijdelijke locatie", messages.ElementAt(startIndex + 5)); + CalculationServiceTestHelper.AssertCalculationEndMessage(messages.ElementAt(startIndex + 6)); + } + + private static void AssertHydraRingCalculationInput(HydraulicBoundaryLocation hydraulicBoundaryLocation, + double norm, + HydraRingCalculationInput actualCalculationInput) + { + Assert.AreEqual(hydraulicBoundaryLocation.Id, actualCalculationInput.HydraulicBoundaryLocationId); + Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(norm), actualCalculationInput.Beta); + } + private static double GetExpectedNorm(GrassCoverErosionOutwardsFailureMechanism failureMechanism, Func getNormFunc) { return RingtoetsCommonDataCalculationService.ProfileSpecificRequiredProbability( Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveHeightCalculationsGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r90fddc8b4b22bab44df62ddf4f7118dc15926550 -rbcab4543e8b75f5d00850c4e7780097cfabf67da --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveHeightCalculationsGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveHeightCalculationsGroupContextTreeNodeInfoTest.cs) (revision 90fddc8b4b22bab44df62ddf4f7118dc15926550) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveHeightCalculationsGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveHeightCalculationsGroupContextTreeNodeInfoTest.cs) (revision bcab4543e8b75f5d00850c4e7780097cfabf67da) @@ -20,28 +20,45 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Drawing; +using System.IO; using System.Linq; +using System.Threading; +using System.Windows.Forms; using Core.Common.Base; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.ContextMenu; +using Core.Common.Gui.Forms.MainWindow; +using Core.Common.Gui.Forms.ViewHost; +using Core.Common.Gui.TestUtil.ContextMenu; using Core.Common.TestUtil; +using Core.Common.Util; +using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Service; +using Ringtoets.Common.Service.TestUtil; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; +using Ringtoets.HydraRing.Calculation.Calculator; +using Ringtoets.HydraRing.Calculation.Calculator.Factory; +using Ringtoets.HydraRing.Calculation.Data.Input; +using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.GrassCoverErosionOutwards.Plugin.Test.TreeNodeInfos { [TestFixture] - public class GrassCoverErosionOutwardsWaveHeightCalculationsGroupContextTreeNodeInfoTest + public class GrassCoverErosionOutwardsWaveHeightCalculationsGroupContextTreeNodeInfoTest : NUnitFormTest { + private const int contextMenuRunWaveHeightCalculationsIndex = 0; + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); + [Test] public void Initialized_Always_ExpectedPropertiesSet() { @@ -109,11 +126,13 @@ { // Setup var mockRepository = new MockRepository(); - var assessmentSection = mockRepository.StrictMock(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository); var menuBuilder = mockRepository.StrictMock(); using (mockRepository.Ordered()) { + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.Build()).Return(null); @@ -145,6 +164,218 @@ } [Test] + [Apartment(ApartmentState.STA)] + public void CalculateWaveHeightsFromContextMenu_AllRequiredInputSet_SendsRightInputToCalculationService() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSection = new AssessmentSectionStub + { + HydraulicBoundaryDatabase = + { + FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") + } + }; + + var hydraulicBoundaryLocation1 = new TestHydraulicBoundaryLocation("locationName 1"); + var hydraulicBoundaryLocation2 = new TestHydraulicBoundaryLocation("locationName 2"); + assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation1, + hydraulicBoundaryLocation2 + }); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { + Contribution = 5 + }; + failureMechanism.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation1, + hydraulicBoundaryLocation2 + }); + + var context = new GrassCoverErosionOutwardsWaveHeightCalculationsGroupContext(new ObservableList(), + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mockRepository.Stub(); + 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.MainWindow).Return(mockRepository.Stub()); + gui.Stub(g => g.DocumentViewController).Return(mockRepository.Stub()); + + var waveHeightCalculator = new TestWaveHeightCalculator(); + var calculatorFactory = mockRepository.Stub(); + calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath, string.Empty)).Return(waveHeightCalculator).Repeat.Times(10); + mockRepository.ReplayAll(); + + DialogBoxHandler = (name, wnd) => + { + // Expect an activity dialog which is automatically closed + }; + + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + plugin.Gui = gui; + plugin.Activate(); + + using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl)) + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + contextMenuAdapter.Items[contextMenuRunWaveHeightCalculationsIndex].PerformClick(); + + // Assert + double mechanismSpecificFactorizedSignalingNorm = GetExpectedNorm(failureMechanism, + () => assessmentSection.FailureMechanismContribution.SignalingNorm / 30); + AssertHydraRingCalculationInput(hydraulicBoundaryLocation1, + mechanismSpecificFactorizedSignalingNorm, + waveHeightCalculator.ReceivedInputs.ElementAt(0)); + AssertHydraRingCalculationInput(hydraulicBoundaryLocation2, + mechanismSpecificFactorizedSignalingNorm, + waveHeightCalculator.ReceivedInputs.ElementAt(1)); + + double mechanismSpecificSignalingNorm = GetExpectedNorm(failureMechanism, () => assessmentSection.FailureMechanismContribution.SignalingNorm); + AssertHydraRingCalculationInput(hydraulicBoundaryLocation1, + mechanismSpecificSignalingNorm, + waveHeightCalculator.ReceivedInputs.ElementAt(2)); + AssertHydraRingCalculationInput(hydraulicBoundaryLocation2, + mechanismSpecificSignalingNorm, + waveHeightCalculator.ReceivedInputs.ElementAt(3)); + + double mechanismSpecificLowerLimitNorm = GetExpectedNorm(failureMechanism, () => assessmentSection.FailureMechanismContribution.LowerLimitNorm); + AssertHydraRingCalculationInput(hydraulicBoundaryLocation1, + mechanismSpecificLowerLimitNorm, + waveHeightCalculator.ReceivedInputs.ElementAt(4)); + AssertHydraRingCalculationInput(hydraulicBoundaryLocation2, + mechanismSpecificLowerLimitNorm, + waveHeightCalculator.ReceivedInputs.ElementAt(5)); + + double lowerLimitNorm = assessmentSection.FailureMechanismContribution.LowerLimitNorm; + AssertHydraRingCalculationInput(hydraulicBoundaryLocation1, + lowerLimitNorm, + waveHeightCalculator.ReceivedInputs.ElementAt(6)); + AssertHydraRingCalculationInput(hydraulicBoundaryLocation2, + lowerLimitNorm, + waveHeightCalculator.ReceivedInputs.ElementAt(7)); + + double factorizedLowerLimitNorm = lowerLimitNorm * 30; + AssertHydraRingCalculationInput(hydraulicBoundaryLocation1, + factorizedLowerLimitNorm, + waveHeightCalculator.ReceivedInputs.ElementAt(8)); + AssertHydraRingCalculationInput(hydraulicBoundaryLocation2, + factorizedLowerLimitNorm, + waveHeightCalculator.ReceivedInputs.ElementAt(9)); + } + } + } + + mockRepository.VerifyAll(); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void GivenHydraulicBoundaryLocationThatSucceeds_CalculatingWaveHeightFromContextMenu_ThenLogMessagesAddedOutputSet() + { + // Given + var mockRepository = new MockRepository(); + var assessmentSection = new AssessmentSectionStub + { + HydraulicBoundaryDatabase = + { + FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") + } + }; + + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("locationName"); + assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation + }); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { + Contribution = 5 + }; + failureMechanism.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation + }); + + var context = new GrassCoverErosionOutwardsWaveHeightCalculationsGroupContext(new ObservableList(), + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mockRepository.Stub(); + 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.MainWindow).Return(mockRepository.Stub()); + gui.Stub(g => g.DocumentViewController).Return(mockRepository.Stub()); + + var waveHeightCalculator = new TestWaveHeightCalculator + { + Converged = false + }; + var calculatorFactory = mockRepository.Stub(); + calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath, string.Empty)).Return(waveHeightCalculator).Repeat.Times(5); + mockRepository.ReplayAll(); + + DialogBoxHandler = (name, wnd) => + { + // Expect an activity dialog which is automatically closed + }; + + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + plugin.Gui = gui; + plugin.Activate(); + + using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl)) + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // When + Action call = () => contextMenuAdapter.Items[contextMenuRunWaveHeightCalculationsIndex].PerformClick(); + + // Then + TestHelper.AssertLogMessages(call, messages => + { + string[] msgs = messages.ToArray(); + Assert.AreEqual(40, msgs.Length); + AssertHydraulicBoundaryLocationCalculationMessages(hydraulicBoundaryLocation, msgs, 0, "Iv->IIv"); + AssertHydraulicBoundaryLocationCalculationMessages(hydraulicBoundaryLocation, msgs, 7, "IIv->IIIv"); + AssertHydraulicBoundaryLocationCalculationMessages(hydraulicBoundaryLocation, msgs, 14, "IIIv->IVv"); + AssertHydraulicBoundaryLocationCalculationMessages(hydraulicBoundaryLocation, msgs, 21, "IVv->Vv"); + AssertHydraulicBoundaryLocationCalculationMessages(hydraulicBoundaryLocation, msgs, 28, "Vv->VIv"); + + Assert.AreEqual($"Golfhoogte berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie Iv->IIv) is gelukt.", msgs.ElementAt(35)); + Assert.AreEqual($"Golfhoogte berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie IIv->IIIv) is gelukt.", msgs.ElementAt(36)); + Assert.AreEqual($"Golfhoogte berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie IIIv->IVv) is gelukt.", msgs.ElementAt(37)); + Assert.AreEqual($"Golfhoogte berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie IVv->Vv) is gelukt.", msgs.ElementAt(38)); + Assert.AreEqual($"Golfhoogte berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie Vv->VIv) is gelukt.", msgs.ElementAt(39)); + }); + + AssertHydraulicBoundaryLocationCalculationOutput(waveHeightCalculator, failureMechanism.WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm.Single().Output); + AssertHydraulicBoundaryLocationCalculationOutput(waveHeightCalculator, failureMechanism.WaveHeightCalculationsForMechanismSpecificSignalingNorm.Single().Output); + AssertHydraulicBoundaryLocationCalculationOutput(waveHeightCalculator, failureMechanism.WaveHeightCalculationsForMechanismSpecificLowerLimitNorm.Single().Output); + AssertHydraulicBoundaryLocationCalculationOutput(waveHeightCalculator, assessmentSection.WaveHeightCalculationsForLowerLimitNorm.Single().Output); + AssertHydraulicBoundaryLocationCalculationOutput(waveHeightCalculator, assessmentSection.WaveHeightCalculationsForFactorizedLowerLimitNorm.Single().Output); + } + } + } + + mockRepository.VerifyAll(); + } + + [Test] public void ChildNodeObjects_Always_ReturnsExpectedChildData() { // Setup @@ -201,6 +432,13 @@ } } + private static void AssertHydraulicBoundaryLocationCalculationOutput(IWaveHeightCalculator waveHeightCalculator, + HydraulicBoundaryLocationCalculationOutput actualOutput) + { + Assert.AreEqual(waveHeightCalculator.WaveHeight, actualOutput.Result, actualOutput.Result.GetAccuracy()); + Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, actualOutput.CalculationConvergence); + } + private static double GetExpectedNorm(GrassCoverErosionOutwardsFailureMechanism failureMechanism, Func getNormFunc) { return RingtoetsCommonDataCalculationService.ProfileSpecificRequiredProbability( @@ -213,5 +451,27 @@ { return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(GrassCoverErosionOutwardsWaveHeightCalculationsGroupContext)); } + + private static void AssertHydraulicBoundaryLocationCalculationMessages(HydraulicBoundaryLocation hydraulicBoundaryLocation, + IEnumerable messages, + int startIndex, + string categoryName) + { + Assert.AreEqual($"Golfhoogte berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie {categoryName}) is gestart.", messages.ElementAt(startIndex)); + CalculationServiceTestHelper.AssertValidationStartMessage(messages.ElementAt(startIndex + 1)); + CalculationServiceTestHelper.AssertValidationEndMessage(messages.ElementAt(startIndex + 2)); + CalculationServiceTestHelper.AssertCalculationStartMessage(messages.ElementAt(startIndex + 3)); + Assert.AreEqual($"Golfhoogte berekening voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie {categoryName}) is niet geconvergeerd.", messages.ElementAt(startIndex + 4)); + StringAssert.StartsWith("Golfhoogte berekening is uitgevoerd op de tijdelijke locatie", messages.ElementAt(startIndex + 5)); + CalculationServiceTestHelper.AssertCalculationEndMessage(messages.ElementAt(startIndex + 6)); + } + + private static void AssertHydraRingCalculationInput(HydraulicBoundaryLocation hydraulicBoundaryLocation, + double norm, + HydraRingCalculationInput actualCalculationInput) + { + Assert.AreEqual(hydraulicBoundaryLocation.Id, actualCalculationInput.HydraulicBoundaryLocationId); + Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(norm), actualCalculationInput.Beta); + } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelCalculationsContextTreeNodeInfoTest.cs =================================================================== diff -u -rda7bb9a6d96d7118d6dcdc2ee17a11d5b43f44c7 -rbcab4543e8b75f5d00850c4e7780097cfabf67da --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelCalculationsContextTreeNodeInfoTest.cs (.../DesignWaterLevelCalculationsContextTreeNodeInfoTest.cs) (revision da7bb9a6d96d7118d6dcdc2ee17a11d5b43f44c7) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelCalculationsContextTreeNodeInfoTest.cs (.../DesignWaterLevelCalculationsContextTreeNodeInfoTest.cs) (revision bcab4543e8b75f5d00850c4e7780097cfabf67da) @@ -586,14 +586,14 @@ { string[] msgs = messages.ToArray(); Assert.AreEqual(8, msgs.Length); - Assert.AreEqual($"Toetspeil berekenen voor locatie '{locationName}' ({categoryBoundaryName}) is gestart.", msgs[0]); + Assert.AreEqual($"Waterstand berekenen voor locatie '{locationName}' ({categoryBoundaryName}) is gestart.", msgs[0]); CalculationServiceTestHelper.AssertValidationStartMessage(msgs[1]); CalculationServiceTestHelper.AssertValidationEndMessage(msgs[2]); CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[3]); - Assert.AreEqual($"Toetspeil berekening voor locatie '{locationName}' ({categoryBoundaryName}) is niet geconvergeerd.", msgs[4]); - StringAssert.StartsWith("Toetspeil berekening is uitgevoerd op de tijdelijke locatie", msgs[5]); + Assert.AreEqual($"Waterstand berekening voor locatie '{locationName}' ({categoryBoundaryName}) is niet geconvergeerd.", msgs[4]); + StringAssert.StartsWith("Waterstand berekening is uitgevoerd op de tijdelijke locatie", msgs[5]); CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[6]); - Assert.AreEqual($"Toetspeil berekenen voor locatie '{locationName}' ({categoryBoundaryName}) is gelukt.", msgs[7]); + Assert.AreEqual($"Waterstand berekenen voor locatie '{locationName}' ({categoryBoundaryName}) is gelukt.", msgs[7]); }); HydraulicBoundaryLocationCalculationOutput output = hydraulicBoundaryLocationCalculation.Output; Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelCalculationsGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r5bb5f922652f2a8cc9a31c94ae2e891ffde02b6c -rbcab4543e8b75f5d00850c4e7780097cfabf67da --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelCalculationsGroupContextTreeNodeInfoTest.cs (.../DesignWaterLevelCalculationsGroupContextTreeNodeInfoTest.cs) (revision 5bb5f922652f2a8cc9a31c94ae2e891ffde02b6c) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelCalculationsGroupContextTreeNodeInfoTest.cs (.../DesignWaterLevelCalculationsGroupContextTreeNodeInfoTest.cs) (revision bcab4543e8b75f5d00850c4e7780097cfabf67da) @@ -43,6 +43,7 @@ using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Service.TestUtil; +using Ringtoets.HydraRing.Calculation.Calculator; using Ringtoets.HydraRing.Calculation.Calculator.Factory; using Ringtoets.HydraRing.Calculation.Data.Input; using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; @@ -449,15 +450,16 @@ AssertHydraulicBoundaryLocationCalculationMessages(hydraulicBoundaryLocation, msgs, 14, "B->C"); AssertHydraulicBoundaryLocationCalculationMessages(hydraulicBoundaryLocation, msgs, 21, "C->D"); - Assert.AreEqual($"Toetspeil berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie A+->A) is gelukt.", msgs.ElementAt(28)); - Assert.AreEqual($"Toetspeil berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie A->B) is gelukt.", msgs.ElementAt(29)); - Assert.AreEqual($"Toetspeil berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie B->C) is gelukt.", msgs.ElementAt(30)); - Assert.AreEqual($"Toetspeil berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie C->D) is gelukt.", msgs.ElementAt(31)); + Assert.AreEqual($"Waterstand berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie A+->A) is gelukt.", msgs.ElementAt(28)); + Assert.AreEqual($"Waterstand berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie A->B) is gelukt.", msgs.ElementAt(29)); + Assert.AreEqual($"Waterstand berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie B->C) is gelukt.", msgs.ElementAt(30)); + Assert.AreEqual($"Waterstand berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie C->D) is gelukt.", msgs.ElementAt(31)); }); - HydraulicBoundaryLocationCalculationOutput output = assessmentSection.WaterLevelCalculationsForFactorizedSignalingNorm.Single().Output; - Assert.AreEqual(designWaterLevelCalculator.DesignWaterLevel, output.Result, output.Result.GetAccuracy()); - Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, output.CalculationConvergence); + AssertHydraulicBoundaryLocationCalculationOutput(designWaterLevelCalculator, assessmentSection.WaterLevelCalculationsForFactorizedSignalingNorm.Single().Output); + AssertHydraulicBoundaryLocationCalculationOutput(designWaterLevelCalculator, assessmentSection.WaterLevelCalculationsForSignalingNorm.Single().Output); + AssertHydraulicBoundaryLocationCalculationOutput(designWaterLevelCalculator, assessmentSection.WaterLevelCalculationsForLowerLimitNorm.Single().Output); + AssertHydraulicBoundaryLocationCalculationOutput(designWaterLevelCalculator, assessmentSection.WaterLevelCalculationsForFactorizedLowerLimitNorm.Single().Output); } } } @@ -517,12 +519,12 @@ int startIndex, string categoryName) { - Assert.AreEqual($"Toetspeil berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie {categoryName}) is gestart.", messages.ElementAt(startIndex)); + Assert.AreEqual($"Waterstand berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie {categoryName}) is gestart.", messages.ElementAt(startIndex)); CalculationServiceTestHelper.AssertValidationStartMessage(messages.ElementAt(startIndex + 1)); CalculationServiceTestHelper.AssertValidationEndMessage(messages.ElementAt(startIndex + 2)); CalculationServiceTestHelper.AssertCalculationStartMessage(messages.ElementAt(startIndex + 3)); - Assert.AreEqual($"Toetspeil berekening voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie {categoryName}) is niet geconvergeerd.", messages.ElementAt(startIndex + 4)); - StringAssert.StartsWith("Toetspeil berekening is uitgevoerd op de tijdelijke locatie", messages.ElementAt(startIndex + 5)); + Assert.AreEqual($"Waterstand berekening voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie {categoryName}) is niet geconvergeerd.", messages.ElementAt(startIndex + 4)); + StringAssert.StartsWith("Waterstand berekening is uitgevoerd op de tijdelijke locatie", messages.ElementAt(startIndex + 5)); CalculationServiceTestHelper.AssertCalculationEndMessage(messages.ElementAt(startIndex + 6)); } @@ -534,6 +536,13 @@ Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(norm), actualCalculationInput.Beta); } + private static void AssertHydraulicBoundaryLocationCalculationOutput(IDesignWaterLevelCalculator designWaterLevelCalculator, + HydraulicBoundaryLocationCalculationOutput actualOutput) + { + Assert.AreEqual(designWaterLevelCalculator.DesignWaterLevel, actualOutput.Result, actualOutput.Result.GetAccuracy()); + Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, actualOutput.CalculationConvergence); + } + private static TreeNodeInfo GetInfo(RingtoetsPlugin plugin) { return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(DesignWaterLevelCalculationsGroupContext)); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightCalculationsGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r5bb5f922652f2a8cc9a31c94ae2e891ffde02b6c -rbcab4543e8b75f5d00850c4e7780097cfabf67da --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightCalculationsGroupContextTreeNodeInfoTest.cs (.../WaveHeightCalculationsGroupContextTreeNodeInfoTest.cs) (revision 5bb5f922652f2a8cc9a31c94ae2e891ffde02b6c) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightCalculationsGroupContextTreeNodeInfoTest.cs (.../WaveHeightCalculationsGroupContextTreeNodeInfoTest.cs) (revision bcab4543e8b75f5d00850c4e7780097cfabf67da) @@ -43,6 +43,7 @@ using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Service.TestUtil; +using Ringtoets.HydraRing.Calculation.Calculator; using Ringtoets.HydraRing.Calculation.Calculator.Factory; using Ringtoets.HydraRing.Calculation.Data.Input; using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; @@ -322,9 +323,9 @@ gui.Stub(g => g.MainWindow).Return(mockRepository.Stub()); gui.Stub(g => g.DocumentViewController).Return(mockRepository.Stub()); - var designWaveHeightCalculator = new TestWaveHeightCalculator(); + var waveHeightCalculator = new TestWaveHeightCalculator(); var calculatorFactory = mockRepository.Stub(); - calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath, string.Empty)).Return(designWaveHeightCalculator).Repeat.Times(8); + calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath, string.Empty)).Return(waveHeightCalculator).Repeat.Times(8); mockRepository.ReplayAll(); DialogBoxHandler = (name, wnd) => @@ -349,33 +350,33 @@ double factorizedSignalingNorm = signalingNorm / 30; AssertHydraRingCalculationInput(hydraulicBoundaryLocation1, factorizedSignalingNorm, - designWaveHeightCalculator.ReceivedInputs.ElementAt(0)); + waveHeightCalculator.ReceivedInputs.ElementAt(0)); AssertHydraRingCalculationInput(hydraulicBoundaryLocation2, factorizedSignalingNorm, - designWaveHeightCalculator.ReceivedInputs.ElementAt(1)); + waveHeightCalculator.ReceivedInputs.ElementAt(1)); AssertHydraRingCalculationInput(hydraulicBoundaryLocation1, signalingNorm, - designWaveHeightCalculator.ReceivedInputs.ElementAt(2)); + waveHeightCalculator.ReceivedInputs.ElementAt(2)); AssertHydraRingCalculationInput(hydraulicBoundaryLocation2, signalingNorm, - designWaveHeightCalculator.ReceivedInputs.ElementAt(3)); + waveHeightCalculator.ReceivedInputs.ElementAt(3)); double lowerLimitNorm = assessmentSection.FailureMechanismContribution.LowerLimitNorm; AssertHydraRingCalculationInput(hydraulicBoundaryLocation1, lowerLimitNorm, - designWaveHeightCalculator.ReceivedInputs.ElementAt(4)); + waveHeightCalculator.ReceivedInputs.ElementAt(4)); AssertHydraRingCalculationInput(hydraulicBoundaryLocation2, lowerLimitNorm, - designWaveHeightCalculator.ReceivedInputs.ElementAt(5)); + waveHeightCalculator.ReceivedInputs.ElementAt(5)); double factorizedLowerLimitNorm = lowerLimitNorm * 30; AssertHydraRingCalculationInput(hydraulicBoundaryLocation1, factorizedLowerLimitNorm, - designWaveHeightCalculator.ReceivedInputs.ElementAt(6)); + waveHeightCalculator.ReceivedInputs.ElementAt(6)); AssertHydraRingCalculationInput(hydraulicBoundaryLocation2, factorizedLowerLimitNorm, - designWaveHeightCalculator.ReceivedInputs.ElementAt(7)); + waveHeightCalculator.ReceivedInputs.ElementAt(7)); } } } @@ -415,12 +416,12 @@ gui.Stub(g => g.MainWindow).Return(mockRepository.Stub()); gui.Stub(g => g.DocumentViewController).Return(mockRepository.Stub()); - var designWaveHeightCalculator = new TestWaveHeightCalculator + var waveHeightCalculator = new TestWaveHeightCalculator { Converged = false }; var calculatorFactory = mockRepository.Stub(); - calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath, string.Empty)).Return(designWaveHeightCalculator).Repeat.Times(4); + calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath, string.Empty)).Return(waveHeightCalculator).Repeat.Times(4); mockRepository.ReplayAll(); DialogBoxHandler = (name, wnd) => @@ -456,9 +457,10 @@ Assert.AreEqual($"Golfhoogte berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie C->D) is gelukt.", msgs.ElementAt(31)); }); - HydraulicBoundaryLocationCalculationOutput output = assessmentSection.WaveHeightCalculationsForFactorizedSignalingNorm.Single().Output; - Assert.AreEqual(designWaveHeightCalculator.WaveHeight, output.Result, output.Result.GetAccuracy()); - Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, output.CalculationConvergence); + AssertHydraulicBoundaryLocationCalculationOutput(waveHeightCalculator, assessmentSection.WaveHeightCalculationsForFactorizedSignalingNorm.Single().Output); + AssertHydraulicBoundaryLocationCalculationOutput(waveHeightCalculator, assessmentSection.WaveHeightCalculationsForSignalingNorm.Single().Output); + AssertHydraulicBoundaryLocationCalculationOutput(waveHeightCalculator, assessmentSection.WaveHeightCalculationsForLowerLimitNorm.Single().Output); + AssertHydraulicBoundaryLocationCalculationOutput(waveHeightCalculator, assessmentSection.WaveHeightCalculationsForFactorizedLowerLimitNorm.Single().Output); } } } @@ -535,6 +537,13 @@ Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(norm), actualCalculationInput.Beta); } + private static void AssertHydraulicBoundaryLocationCalculationOutput(IWaveHeightCalculator waveHeightCalculator, + HydraulicBoundaryLocationCalculationOutput actualOutput) + { + Assert.AreEqual(waveHeightCalculator.WaveHeight, actualOutput.Result, actualOutput.Result.GetAccuracy()); + Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, actualOutput.CalculationConvergence); + } + private static TreeNodeInfo GetInfo(RingtoetsPlugin plugin) { return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(WaveHeightCalculationsGroupContext));