Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Service.Test/StabilityStoneCoverWaveConditionsCalculationServiceTest.cs =================================================================== diff -u -r3370d752e150391d16ebfb96533921d777f4580c -r5a312956919605087a6b402de1c8307680f9701f --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Service.Test/StabilityStoneCoverWaveConditionsCalculationServiceTest.cs (.../StabilityStoneCoverWaveConditionsCalculationServiceTest.cs) (revision 3370d752e150391d16ebfb96533921d777f4580c) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Service.Test/StabilityStoneCoverWaveConditionsCalculationServiceTest.cs (.../StabilityStoneCoverWaveConditionsCalculationServiceTest.cs) (revision 5a312956919605087a6b402de1c8307680f9701f) @@ -69,8 +69,7 @@ // Call TestDelegate test = () => StabilityStoneCoverWaveConditionsCalculationService.Validate(null, GetValidAssessmentLevel(), - validFilePath, - validPreprocessorDirectory, + GetValidHydraulicBoundaryDatabase(), validNorm); // Assert @@ -96,8 +95,12 @@ // Call Action call = () => isValid = StabilityStoneCoverWaveConditionsCalculationService.Validate(calculation, GetValidAssessmentLevel(), - testFilePath, - validPreprocessorDirectory, + new HydraulicBoundaryDatabase + { + FilePath = testFilePath, + CanUsePreprocessor = true, + PreprocessorDirectory = validPreprocessorDirectory + }, validNorm); // Assert @@ -106,7 +109,8 @@ string[] msgs = messages.ToArray(); Assert.AreEqual(3, msgs.Length); CalculationServiceTestHelper.AssertValidationStartMessage(msgs[0]); - Assert.AreEqual($"Fout bij het lezen van bestand '{testFilePath}': het bestand bestaat niet.", msgs[1]); + Assert.AreEqual("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. " + + $"Fout bij het lezen van bestand '{testFilePath}': het bestand bestaat niet.", msgs[1]); CalculationServiceTestHelper.AssertValidationEndMessage(msgs[2]); }); Assert.IsFalse(isValid); @@ -133,8 +137,12 @@ // Call Action call = () => isValid = StabilityStoneCoverWaveConditionsCalculationService.Validate(calculation, GetValidAssessmentLevel(), - invalidFilePath, - validPreprocessorDirectory, + new HydraulicBoundaryDatabase + { + FilePath = invalidFilePath, + CanUsePreprocessor = true, + PreprocessorDirectory = validPreprocessorDirectory + }, validNorm); // Assert @@ -143,7 +151,8 @@ string[] msgs = messages.ToArray(); Assert.AreEqual(3, msgs.Length); CalculationServiceTestHelper.AssertValidationStartMessage(msgs[0]); - Assert.AreEqual($"Fout bij het lezen van bestand '{invalidFilePath}': kon geen locaties verkrijgen van de database.", msgs[1]); + Assert.AreEqual("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. " + + $"Fout bij het lezen van bestand '{invalidFilePath}': kon geen locaties verkrijgen van de database.", msgs[1]); CalculationServiceTestHelper.AssertValidationEndMessage(msgs[2]); }); Assert.IsFalse(isValid); @@ -170,8 +179,13 @@ // Call Action call = () => isValid = StabilityStoneCoverWaveConditionsCalculationService.Validate(calculation, GetValidAssessmentLevel(), - validFilePath, - invalidPreprocessorDirectory, + new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + CanUsePreprocessor = true, + UsePreprocessor = true, + PreprocessorDirectory = invalidPreprocessorDirectory + }, validNorm); // Assert @@ -207,8 +221,12 @@ // Call Action call = () => isValid = StabilityStoneCoverWaveConditionsCalculationService.Validate(calculation, GetValidAssessmentLevel(), - testFilePath, - validPreprocessorDirectory, + new HydraulicBoundaryDatabase + { + FilePath = testFilePath, + CanUsePreprocessor = true, + PreprocessorDirectory = validPreprocessorDirectory + }, validNorm); // Assert @@ -217,7 +235,8 @@ string[] msgs = messages.ToArray(); Assert.AreEqual(3, msgs.Length); CalculationServiceTestHelper.AssertValidationStartMessage(msgs[0]); - StringAssert.StartsWith("Fout bij het lezen van bestand", msgs[1]); + StringAssert.StartsWith("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. " + + "Fout bij het lezen van bestand", msgs[1]); CalculationServiceTestHelper.AssertValidationEndMessage(msgs[2]); }); Assert.IsFalse(isValid); @@ -227,6 +246,41 @@ } [Test] + public void Validate_WithoutImportedHydraulicBoundaryDatabase_LogValidationMessageAndReturnFalse() + { + // Setup + var mockRepository = new MockRepository(); + var calculatorFactory = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + StabilityStoneCoverWaveConditionsCalculation calculation = GetDefaultCalculation(new TestHydraulicBoundaryLocation()); + + var isValid = true; + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + Action call = () => isValid = StabilityStoneCoverWaveConditionsCalculationService.Validate(calculation, + GetValidAssessmentLevel(), + new HydraulicBoundaryDatabase(), + validNorm); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + string[] msgs = messages.ToArray(); + Assert.AreEqual(3, msgs.Length); + CalculationServiceTestHelper.AssertValidationStartMessage(msgs[0]); + Assert.AreEqual("Er is geen hydraulische randvoorwaardendatabase geïmporteerd.", msgs[1]); + CalculationServiceTestHelper.AssertValidationEndMessage(msgs[2]); + }); + Assert.IsFalse(isValid); + } + + mockRepository.VerifyAll(); + } + + [Test] public void Validate_NoHydraulicBoundaryLocation_LogsValidationMessageAndReturnFalse() { // Setup @@ -243,8 +297,7 @@ // Call Action call = () => isValid = StabilityStoneCoverWaveConditionsCalculationService.Validate(calculation, GetValidAssessmentLevel(), - validFilePath, - validPreprocessorDirectory, + GetValidHydraulicBoundaryDatabase(), validNorm); // Assert @@ -279,8 +332,7 @@ // Call Action call = () => isValid = StabilityStoneCoverWaveConditionsCalculationService.Validate(calculation, RoundedDouble.NaN, - validFilePath, - validPreprocessorDirectory, + GetValidHydraulicBoundaryDatabase(), validNorm); // Assert @@ -319,8 +371,7 @@ // Call Action call = () => isValid = StabilityStoneCoverWaveConditionsCalculationService.Validate(calculation, GetValidAssessmentLevel(), - validFilePath, - validPreprocessorDirectory, + GetValidHydraulicBoundaryDatabase(), validNorm); // Assert @@ -361,8 +412,7 @@ // Call Action call = () => isValid = StabilityStoneCoverWaveConditionsCalculationService.Validate(calculation, GetValidAssessmentLevel(), - validFilePath, - validPreprocessorDirectory, + GetValidHydraulicBoundaryDatabase(), validNorm); // Assert @@ -1246,6 +1296,16 @@ return (RoundedDouble) 9.3; } + private static HydraulicBoundaryDatabase GetValidHydraulicBoundaryDatabase() + { + return new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + CanUsePreprocessor = true, + PreprocessorDirectory = validPreprocessorDirectory + }; + } + private static IEnumerable GetWaterLevels(StabilityStoneCoverWaveConditionsCalculation calculation, IAssessmentSection assessmentSection) { return calculation.InputParameters.GetWaterLevels(assessmentSection.GetAssessmentLevel(