Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Service/DuneLocationCalculationService.cs =================================================================== diff -u -r6623626c6fafb2d2f1b2b88f766dd8a45a67fe63 -rd8d8428e2723f189605f0065a2cddcc3f9f9eaef --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Service/DuneLocationCalculationService.cs (.../DuneLocationCalculationService.cs) (revision 6623626c6fafb2d2f1b2b88f766dd8a45a67fe63) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Service/DuneLocationCalculationService.cs (.../DuneLocationCalculationService.cs) (revision d8d8428e2723f189605f0065a2cddcc3f9f9eaef) @@ -137,7 +137,7 @@ bool hasErrorOccurred = CalculationServiceHelper.HasErrorOccurred(canceled, exceptionThrown, lastErrorFileContent); if (hasErrorOccurred) { - messageProvider.GetCalculationFailedWithErrorReportMessage(duneLocationName, lastErrorFileContent); + log.Error(messageProvider.GetCalculationFailedWithErrorReportMessage(duneLocationName, lastErrorFileContent)); } log.InfoFormat(Resources.DuneLocationCalculationService_Calculate_Calculation_temporary_directory_can_be_found_on_location_0, Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Service.Test/DuneLocationCalculationServiceTest.cs =================================================================== diff -u -r4dc143747911c0acb569c03b4ea6070489afa56a -rd8d8428e2723f189605f0065a2cddcc3f9f9eaef --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Service.Test/DuneLocationCalculationServiceTest.cs (.../DuneLocationCalculationServiceTest.cs) (revision 4dc143747911c0acb569c03b4ea6070489afa56a) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Service.Test/DuneLocationCalculationServiceTest.cs (.../DuneLocationCalculationServiceTest.cs) (revision d8d8428e2723f189605f0065a2cddcc3f9f9eaef) @@ -105,7 +105,10 @@ ? validPreprocessorDirectory : string.Empty; - var calculator = new TestDunesBoundaryConditionsCalculator(); + var calculator = new TestDunesBoundaryConditionsCalculator + { + Converged = true + }; var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock(); @@ -211,6 +214,9 @@ { // Setup const double norm = 1.0 / 30; + const string locationName = "locationName"; + const string failedConvergenceMessage = "failedConvergenceMessage"; + var calculator = new TestDunesBoundaryConditionsCalculator { ReliabilityIndex = 0.01 @@ -221,9 +227,10 @@ calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(testDataPath, validPreprocessorDirectory)) .Return(calculator); var calculationMessageProvider = mockRepository.StrictMock(); + calculationMessageProvider.Expect(c => c.GetCalculatedNotConvergedMessage(locationName)).Return(failedConvergenceMessage); mockRepository.ReplayAll(); - var duneLocation = new TestDuneLocation("Name"); + var duneLocation = new TestDuneLocation(locationName); var duneLocationCalculation = new DuneLocationCalculation(duneLocation); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) @@ -244,7 +251,7 @@ Assert.AreEqual(4, msgs.Length); CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); - Assert.AreEqual($"Hydraulische randvoorwaarden berekening voor locatie '{duneLocation.Name}' is niet geconvergeerd.", msgs[1]); + Assert.AreEqual(failedConvergenceMessage, msgs[1]); StringAssert.StartsWith("Hydraulische randvoorwaarden berekening is uitgevoerd op de tijdelijke locatie", msgs[2]); CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[3]); }); @@ -258,7 +265,10 @@ { // Setup const double norm = 1.0 / 30; - var calculator = new TestDunesBoundaryConditionsCalculator(); + var calculator = new TestDunesBoundaryConditionsCalculator + { + Converged = true + }; var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock(); @@ -293,9 +303,13 @@ { // Setup const double norm = 1.0 / 30; + const string locationName = "locationName"; + const string errorReport = "errorReport"; + const string errorMessage = "errorMessage"; + var calculator = new TestDunesBoundaryConditionsCalculator { - LastErrorFileContent = "An error occurred", + LastErrorFileContent = errorReport, EndInFailure = true }; @@ -304,9 +318,10 @@ calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(testDataPath, validPreprocessorDirectory)) .Return(calculator); var calculationMessageProvider = mockRepository.StrictMock(); + calculationMessageProvider.Expect(c => c.GetCalculationFailedWithErrorReportMessage(locationName, errorReport)).Return(errorMessage); mockRepository.ReplayAll(); - var duneLocation = new TestDuneLocation("Name"); + var duneLocation = new TestDuneLocation(locationName); var duneLocationCalculation = new DuneLocationCalculation(duneLocation); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) @@ -339,7 +354,7 @@ Assert.AreEqual(4, msgs.Length); CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); - StringAssert.StartsWith($"Hydraulische randvoorwaarden berekening voor locatie '{duneLocation.Name}' is mislukt. Bekijk het foutrapport door op details te klikken.", msgs[1]); + Assert.AreEqual(errorMessage, msgs[1]); StringAssert.StartsWith("Hydraulische randvoorwaarden berekening is uitgevoerd op de tijdelijke locatie", msgs[2]); CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[3]); }); @@ -355,6 +370,9 @@ { // Setup const double norm = 1.0 / 30; + const string locationName = "locationName"; + const string errorMessage = "errorMessage"; + var calculator = new TestDunesBoundaryConditionsCalculator { EndInFailure = true @@ -365,9 +383,10 @@ calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(testDataPath, validPreprocessorDirectory)) .Return(calculator); var calculationMessageProvider = mockRepository.StrictMock(); + calculationMessageProvider.Expect(c => c.GetCalculationFailedMessage(locationName)).Return(errorMessage); mockRepository.ReplayAll(); - var duneLocation = new TestDuneLocation("Name"); + var duneLocation = new TestDuneLocation(locationName); var duneLocationCalculation = new DuneLocationCalculation(duneLocation); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) @@ -400,7 +419,7 @@ Assert.AreEqual(4, msgs.Length); CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); - Assert.AreEqual($"Hydraulische randvoorwaarden berekening voor locatie '{duneLocation.Name}' is mislukt. Er is geen foutrapport beschikbaar.", msgs[1]); + Assert.AreEqual(errorMessage, msgs[1]); StringAssert.StartsWith("Hydraulische randvoorwaarden berekening is uitgevoerd op de tijdelijke locatie", msgs[2]); CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[3]); }); @@ -416,20 +435,25 @@ { // Setup const double norm = 1.0 / 30; + const string locationName = "locationName"; + const string errorMessage = "errorMessage"; + const string lastErrorFileContent = "lastErrorFileContent"; + var calculator = new TestDunesBoundaryConditionsCalculator { EndInFailure = false, - LastErrorFileContent = "An error occurred" + LastErrorFileContent = lastErrorFileContent }; var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock(); calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(testDataPath, validPreprocessorDirectory)) .Return(calculator); var calculationMessageProvider = mockRepository.StrictMock(); + calculationMessageProvider.Expect(c => c.GetCalculationFailedWithErrorReportMessage(locationName, lastErrorFileContent)).Return(errorMessage); mockRepository.ReplayAll(); - var duneLocation = new TestDuneLocation("Name"); + var duneLocation = new TestDuneLocation(locationName); var duneLocationCalculation = new DuneLocationCalculation(duneLocation); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) @@ -464,7 +488,7 @@ Assert.AreEqual(4, msgs.Length); CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); - StringAssert.StartsWith($"Hydraulische randvoorwaarden berekening voor locatie '{duneLocation.Name}' is mislukt. Bekijk het foutrapport door op details te klikken.", msgs[1]); + Assert.AreEqual(errorMessage, msgs[1]); StringAssert.StartsWith("Hydraulische randvoorwaarden berekening is uitgevoerd op de tijdelijke locatie", msgs[2]); CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[3]); });