Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Service.Test/WaveImpactAsphaltCoverWaveConditionsCalculationServiceTest.cs =================================================================== diff -u -r3370d752e150391d16ebfb96533921d777f4580c -rc7b83164bc8b8843272a439d9237f011f4284a1c --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Service.Test/WaveImpactAsphaltCoverWaveConditionsCalculationServiceTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationServiceTest.cs) (revision 3370d752e150391d16ebfb96533921d777f4580c) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Service.Test/WaveImpactAsphaltCoverWaveConditionsCalculationServiceTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationServiceTest.cs) (revision c7b83164bc8b8843272a439d9237f011f4284a1c) @@ -69,8 +69,7 @@ // Call TestDelegate test = () => WaveImpactAsphaltCoverWaveConditionsCalculationService.Validate(null, GetValidAssessmentLevel(), - validFilePath, - validPreprocessorDirectory, + GetValidHydraulicBoundaryDatabase(), validNorm); // Assert @@ -96,8 +95,12 @@ // Call Action call = () => isValid = WaveImpactAsphaltCoverWaveConditionsCalculationService.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 = WaveImpactAsphaltCoverWaveConditionsCalculationService.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 = WaveImpactAsphaltCoverWaveConditionsCalculationService.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 = WaveImpactAsphaltCoverWaveConditionsCalculationService.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(); + + WaveImpactAsphaltCoverWaveConditionsCalculation calculation = GetDefaultCalculation(new TestHydraulicBoundaryLocation()); + + var isValid = true; + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + Action call = () => isValid = WaveImpactAsphaltCoverWaveConditionsCalculationService.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 = WaveImpactAsphaltCoverWaveConditionsCalculationService.Validate(calculation, GetValidAssessmentLevel(), - validFilePath, - validPreprocessorDirectory, + GetValidHydraulicBoundaryDatabase(), validNorm); // Assert @@ -279,8 +332,7 @@ // Call Action call = () => isValid = WaveImpactAsphaltCoverWaveConditionsCalculationService.Validate(calculation, RoundedDouble.NaN, - validFilePath, - validPreprocessorDirectory, + GetValidHydraulicBoundaryDatabase(), validNorm); // Assert @@ -319,8 +371,7 @@ // Call Action call = () => isValid = WaveImpactAsphaltCoverWaveConditionsCalculationService.Validate(calculation, GetValidAssessmentLevel(), - validFilePath, - validPreprocessorDirectory, + GetValidHydraulicBoundaryDatabase(), validNorm); // Assert @@ -361,8 +412,7 @@ // Call Action call = () => isValid = WaveImpactAsphaltCoverWaveConditionsCalculationService.Validate(calculation, GetValidAssessmentLevel(), - validFilePath, - validPreprocessorDirectory, + GetValidHydraulicBoundaryDatabase(), validNorm); // Assert @@ -1056,6 +1106,16 @@ return (RoundedDouble) 9.3; } + private static HydraulicBoundaryDatabase GetValidHydraulicBoundaryDatabase() + { + return new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + CanUsePreprocessor = true, + PreprocessorDirectory = validPreprocessorDirectory + }; + } + private static IEnumerable GetWaterLevels(WaveImpactAsphaltCoverWaveConditionsCalculation calculation, IAssessmentSection assessmentSection) { return calculation.InputParameters.GetWaterLevels(assessmentSection.GetAssessmentLevel(