Index: Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs =================================================================== diff -u -ra5cd9b063d07cb1205e7691b7ff38fc393005210 -r211ed9d209b72a515105428e9ad08ec6972ad95d --- Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs (.../DesignWaterLevelCalculationService.cs) (revision a5cd9b063d07cb1205e7691b7ff38fc393005210) +++ Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs (.../DesignWaterLevelCalculationService.cs) (revision 211ed9d209b72a515105428e9ad08ec6972ad95d) @@ -36,7 +36,7 @@ using Ringtoets.HydraRing.Calculation.Calculator.Factory; using Ringtoets.HydraRing.Calculation.Data.Input.Hydraulics; using Ringtoets.HydraRing.Calculation.Exceptions; -using HydraGeneralResult = Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints.GeneralResult; +using HydraRingGeneralResult = Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints.GeneralResult; namespace Ringtoets.Common.Service { @@ -205,15 +205,26 @@ designWaterLevelCalculation.Output = hydraulicBoundaryLocationOutput; } + /// + /// Sets a based on the information + /// of to the . + /// + /// The + /// to set the . + /// The to base the + /// to create on. + /// Thrown when + /// is null. private static void SetIllustrationPointsResult(HydraulicBoundaryLocationOutput hydraulicBoundaryLocationOutput, - HydraGeneralResult hydraGeneralResult) + HydraRingGeneralResult hydraRingGeneralResult) { - if (hydraGeneralResult != null) + if (hydraRingGeneralResult == null) { - GeneralResultSubMechanismIllustrationPoint generalResult = - GeneralResultSubmechanismIllustrationPointConverter.CreateGeneralResultSubmechanismIllustrationPoint(hydraGeneralResult); - hydraulicBoundaryLocationOutput.SetIllustrationPoints(generalResult); + throw new HydraRingCalculationException(Resources.DesignWaterLevelCalculationService_SetIllustrationPointsResult_No_general_result_found); } + GeneralResultSubMechanismIllustrationPoint generalResult = + GeneralResultSubmechanismIllustrationPointConverter.CreateGeneralResultSubmechanismIllustrationPoint(hydraRingGeneralResult); + hydraulicBoundaryLocationOutput.SetIllustrationPoints(generalResult); } /// Index: Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.Designer.cs =================================================================== diff -u -r92210258706d0f57e05552037b676bd941a6fe19 -r211ed9d209b72a515105428e9ad08ec6972ad95d --- Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 92210258706d0f57e05552037b676bd941a6fe19) +++ Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 211ed9d209b72a515105428e9ad08ec6972ad95d) @@ -159,6 +159,16 @@ } /// + /// Looks up a localized string similar to Er konden geen illustratiepunten worden uitgelezen.. + /// + public static string DesignWaterLevelCalculationService_SetIllustrationPointsResult_No_general_result_found { + get { + return ResourceManager.GetString("DesignWaterLevelCalculationService_SetIllustrationPointsResult_No_general_result_" + + "found", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Validatie mislukt: {0}. /// public static string Error_in_validation_0 { Index: Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.resx =================================================================== diff -u -r92210258706d0f57e05552037b676bd941a6fe19 -r211ed9d209b72a515105428e9ad08ec6972ad95d --- Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.resx (.../Resources.resx) (revision 92210258706d0f57e05552037b676bd941a6fe19) +++ Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.resx (.../Resources.resx) (revision 211ed9d209b72a515105428e9ad08ec6972ad95d) @@ -206,4 +206,7 @@ Golfcondities berekenen voor '{0}' + + Er konden geen illustratiepunten worden uitgelezen. + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationService.cs =================================================================== diff -u -ra5cd9b063d07cb1205e7691b7ff38fc393005210 -r211ed9d209b72a515105428e9ad08ec6972ad95d --- Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationService.cs (.../WaveHeightCalculationService.cs) (revision a5cd9b063d07cb1205e7691b7ff38fc393005210) +++ Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationService.cs (.../WaveHeightCalculationService.cs) (revision 211ed9d209b72a515105428e9ad08ec6972ad95d) @@ -36,7 +36,7 @@ using Ringtoets.HydraRing.Calculation.Calculator.Factory; using Ringtoets.HydraRing.Calculation.Data.Input.Hydraulics; using Ringtoets.HydraRing.Calculation.Exceptions; -using HydraGeneralResult = Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints.GeneralResult; +using HydraRingGeneralResult = Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints.GeneralResult; namespace Ringtoets.Common.Service { @@ -206,15 +206,26 @@ waveHeightCalculation.Output = hydraulicBoundaryLocationOutput; } + /// + /// Sets a based on the information + /// of to the . + /// + /// The + /// to set the . + /// The to base the + /// to create on. + /// Thrown when + /// is null. private static void SetIllustrationPointsResult(HydraulicBoundaryLocationOutput hydraulicBoundaryLocationOutput, - HydraGeneralResult hydraGeneralResult) + HydraRingGeneralResult hydraRingGeneralResult) { - if (hydraGeneralResult != null) + if (hydraRingGeneralResult == null) { - GeneralResultSubMechanismIllustrationPoint generalResult = - GeneralResultSubmechanismIllustrationPointConverter.CreateGeneralResultSubmechanismIllustrationPoint(hydraGeneralResult); - hydraulicBoundaryLocationOutput.SetIllustrationPoints(generalResult); + throw new HydraRingCalculationException(Resources.DesignWaterLevelCalculationService_SetIllustrationPointsResult_No_general_result_found); } + GeneralResultSubMechanismIllustrationPoint generalResult = + GeneralResultSubmechanismIllustrationPointConverter.CreateGeneralResultSubmechanismIllustrationPoint(hydraRingGeneralResult); + hydraulicBoundaryLocationOutput.SetIllustrationPoints(generalResult); } /// Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationActivityTest.cs =================================================================== diff -u -ra5c551a343fee7ea3d7e46dd36c82cf180a1b597 -r211ed9d209b72a515105428e9ad08ec6972ad95d --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationActivityTest.cs (.../DesignWaterLevelCalculationActivityTest.cs) (revision a5c551a343fee7ea3d7e46dd36c82cf180a1b597) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationActivityTest.cs (.../DesignWaterLevelCalculationActivityTest.cs) (revision 211ed9d209b72a515105428e9ad08ec6972ad95d) @@ -37,6 +37,7 @@ using Ringtoets.HydraRing.Calculation.Calculator.Factory; using Ringtoets.HydraRing.Calculation.Data.Input.Hydraulics; using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; +using Ringtoets.HydraRing.Calculation.TestUtil.IllustrationPoints; namespace Ringtoets.Common.Service.Test { @@ -287,6 +288,11 @@ Converged = true }; + if (hydraulicBoundaryLocation.DesignWaterLevelCalculation.InputParameters.ShouldIllustrationPointsBeCalculated) + { + calculator.IllustrationPointsResult = new TestGeneralResult(); + } + var calculatorFactory = mockRepository.StrictMock(); calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath)).Return(calculator); var calculationMessageProvider = mockRepository.StrictMock(); @@ -383,7 +389,8 @@ var calculator = new TestDesignWaterLevelCalculator { - Converged = false + Converged = false, + IllustrationPointsResult = new TestGeneralResult() }; var calculatorFactory = mockRepository.StrictMock(); Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs =================================================================== diff -u -ref3fadb8742f1c2e60d2278a9d9a4639e1a4f44d -r211ed9d209b72a515105428e9ad08ec6972ad95d --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs (.../DesignWaterLevelCalculationServiceTest.cs) (revision ef3fadb8742f1c2e60d2278a9d9a4639e1a4f44d) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs (.../DesignWaterLevelCalculationServiceTest.cs) (revision 211ed9d209b72a515105428e9ad08ec6972ad95d) @@ -239,6 +239,49 @@ } [Test] + public void Calculate_ValidDesignWaterLevelCalculationWithIllustrationPointsButIsNull_ThrowsHydraRingCalculationException() + { + // Setup + string validFilePath = Path.Combine(testDataPath, validFile); + + const string locationName = "punt_flw_ 1"; + + var mockRepository = new MockRepository(); + var calculator = new TestDesignWaterLevelCalculator(); + + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath)).Return(calculator); + + var calculation = mockRepository.Stub(); + calculation.Stub(c => c.Name).Return(locationName); + calculation.Expect(c => c.Id).Return(100); + calculation.Expect(c => c.CalculateIllustrationPoints).Return(true); + + var calculationMessageProvider = mockRepository.StrictMock(); + calculationMessageProvider.Stub(calc => calc.GetCalculationName(locationName)).Return(string.Empty); + calculationMessageProvider.Stub(calc => calc.GetCalculatedNotConvergedMessage(locationName)).Return(string.Empty); + calculationMessageProvider.Stub(calc => calc.GetCalculationFailedMessage( + locationName, "Er konden geen illustratiepunten worden uitgelezen.")) + .Return(string.Empty); + mockRepository.ReplayAll(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + TestDelegate call = () => new DesignWaterLevelCalculationService() + .Calculate(calculation, + validFilePath, + 1.0 / 30, + calculationMessageProvider); + + // Assert + var thrownException = Assert.Throws(call); + Assert.AreEqual("Er konden geen illustratiepunten worden uitgelezen.", thrownException.Message); + } + mockRepository.VerifyAll(); + } + + [Test] public void Calculate_ValidDesignWaterLevelCalculationWithIllustrationPoints_StartsCalculationWithRightParameters() { // Setup Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationActivityTest.cs =================================================================== diff -u -ra5c551a343fee7ea3d7e46dd36c82cf180a1b597 -r211ed9d209b72a515105428e9ad08ec6972ad95d --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationActivityTest.cs (.../WaveHeightCalculationActivityTest.cs) (revision a5c551a343fee7ea3d7e46dd36c82cf180a1b597) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationActivityTest.cs (.../WaveHeightCalculationActivityTest.cs) (revision 211ed9d209b72a515105428e9ad08ec6972ad95d) @@ -36,6 +36,7 @@ using Ringtoets.HydraRing.Calculation.Calculator.Factory; using Ringtoets.HydraRing.Calculation.Data.Input.Hydraulics; using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; +using Ringtoets.HydraRing.Calculation.TestUtil.IllustrationPoints; namespace Ringtoets.Common.Service.Test { @@ -52,7 +53,7 @@ { yield return new TestCaseData(new TestHydraulicBoundaryLocation("WithOutputWithoutIllustrationPoints") { - DesignWaterLevelCalculation = + WaveHeightCalculation = { InputParameters = { @@ -273,6 +274,11 @@ WaveHeight = expectedWaveHeight }; + if (hydraulicBoundaryLocation.WaveHeightCalculation.InputParameters.ShouldIllustrationPointsBeCalculated) + { + calculator.IllustrationPointsResult = new TestGeneralResult(); + } + var calculatorFactory = mockRepository.StrictMock(); calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath)).Return(calculator); var calculationMessageProvider = mockRepository.Stub(); @@ -370,7 +376,8 @@ var calculator = new TestWaveHeightCalculator { - Converged = false + Converged = false, + IllustrationPointsResult = new TestGeneralResult() }; var calculatorFactory = mockRepository.StrictMock(); Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationServiceTest.cs =================================================================== diff -u -ref3fadb8742f1c2e60d2278a9d9a4639e1a4f44d -r211ed9d209b72a515105428e9ad08ec6972ad95d --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationServiceTest.cs (.../WaveHeightCalculationServiceTest.cs) (revision ef3fadb8742f1c2e60d2278a9d9a4639e1a4f44d) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationServiceTest.cs (.../WaveHeightCalculationServiceTest.cs) (revision 211ed9d209b72a515105428e9ad08ec6972ad95d) @@ -238,6 +238,49 @@ } [Test] + public void Calculate_ValidWaveHeightCalculationWithIllustrationPointsButIsNull_ThrowsHydraRingCalculationException() + { + // Setup + string validFilePath = Path.Combine(testDataPath, validFile); + + const string locationName = "punt_flw_ 1"; + + var mockRepository = new MockRepository(); + var calculator = new TestWaveHeightCalculator(); + + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath)).Return(calculator); + + var calculation = mockRepository.Stub(); + calculation.Stub(c => c.Name).Return(locationName); + calculation.Expect(c => c.Id).Return(100); + calculation.Expect(c => c.CalculateIllustrationPoints).Return(true); + + var calculationMessageProvider = mockRepository.StrictMock(); + calculationMessageProvider.Stub(calc => calc.GetCalculationName(locationName)).Return(string.Empty); + calculationMessageProvider.Stub(calc => calc.GetCalculatedNotConvergedMessage(locationName)).Return(string.Empty); + calculationMessageProvider.Stub(calc => calc.GetCalculationFailedMessage( + locationName, "Er konden geen illustratiepunten worden uitgelezen.")) + .Return(string.Empty); + mockRepository.ReplayAll(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + TestDelegate call = () => new WaveHeightCalculationService() + .Calculate(calculation, + validFilePath, + 1.0 / 30, + calculationMessageProvider); + + // Assert + var thrownException = Assert.Throws(call); + Assert.AreEqual("Er konden geen illustratiepunten worden uitgelezen.", thrownException.Message); + } + mockRepository.VerifyAll(); + } + + [Test] public void Calculate_ValidWaveHeightCalculationWithIllustrationPoints_StartsCalculationWithRightParameters() { // Setup