Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Integration.Test/ClosingStructuresCalculationActivityIntegrationTest.cs =================================================================== diff -u -rf80835301ae973b5439593e81fb640b7ab044340 -r8245c9add5586e4e544ab41195fb0af2b2a459e9 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Integration.Test/ClosingStructuresCalculationActivityIntegrationTest.cs (.../ClosingStructuresCalculationActivityIntegrationTest.cs) (revision f80835301ae973b5439593e81fb640b7ab044340) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Integration.Test/ClosingStructuresCalculationActivityIntegrationTest.cs (.../ClosingStructuresCalculationActivityIntegrationTest.cs) (revision 8245c9add5586e4e544ab41195fb0af2b2a459e9) @@ -23,6 +23,7 @@ using System.IO; using System.Linq; using Core.Common.Base; +using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Base.Service; using Core.Common.TestUtil; @@ -45,7 +46,91 @@ { private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); + [Test] + public void Run_ClosingStructuresCalculationInvalidHydraulicBoundaryDatabase_LogValidationStartAndEndWithError() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = Path.Combine(testDataPath, "notexisting.sqlite") + } + }; + + var failureMechanism = new ClosingStructuresFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("test section", new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + })); + + var calculation = new ClosingStructuresCalculation(); + + var activity = new ClosingStructuresCalculationActivity(calculation, "", failureMechanism, assessmentSection); + + // Call + Action call = () => activity.Run(); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(3, msgs.Length); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]); + StringAssert.StartsWith("Validatie mislukt: Fout bij het lezen van bestand", msgs[1]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beƫindigd om: ", calculation.Name), msgs[2]); + }); + Assert.AreEqual(ActivityState.Failed, activity.State); + } + + [Test] + public void Run_ClosingStructuresCalculationWithoutHydraulicBoundaryLocation_LogValidationStartAndEndWithError() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); + + using (var importer = new HydraulicBoundaryDatabaseImporter()) + { + importer.Import(assessmentSection, validFilePath); + } + + var failureMechanism = new ClosingStructuresFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("test section", new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + })); + + var calculation = new ClosingStructuresCalculation() + { + InputParameters = + { + Structure = new TestClosingStructure() + } + }; + calculation.InputParameters.DeviationWaveDirection = (RoundedDouble)0; + + var activity = new ClosingStructuresCalculationActivity(calculation, "", failureMechanism, assessmentSection); + + // Call + Action call = () => activity.Run(); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(3, msgs.Length); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]); + StringAssert.StartsWith("Validatie mislukt: Er is geen hydraulische randvoorwaardenlocatie geselecteerd.", msgs[1]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beƫindigd om: ", calculation.Name), msgs[2]); + }); + Assert.AreEqual(ActivityState.Failed, activity.State); + } + + [Test] public void Run_ValidClosingStructuresCalculation_PerformClosingStructuresValidationAndCalculationAndLogStartAndEnd() { // Setup