Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/HeightStructuresCalculationActivityIntegrationTest.cs =================================================================== diff -u -r00a81cf63e2bee520315ebd8ce9795d0920a97da -ra5f2f2b83d30f57bbeacdc77a431b67c28a1ebde --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/HeightStructuresCalculationActivityIntegrationTest.cs (.../HeightStructuresCalculationActivityIntegrationTest.cs) (revision 00a81cf63e2bee520315ebd8ce9795d0920a97da) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/HeightStructuresCalculationActivityIntegrationTest.cs (.../HeightStructuresCalculationActivityIntegrationTest.cs) (revision a5f2f2b83d30f57bbeacdc77a431b67c28a1ebde) @@ -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; @@ -46,9 +47,47 @@ private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); [Test] - public void Run_InvalidHeightStructuresCalculation_LogValidationStartAndEndWithError() + public void Run_HeightStructuresCalculationInvalidHydraulicBoundaryDatabase_LogValidationStartAndEndWithError() { // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = Path.Combine(testDataPath, "notexisting.sqlite") + } + }; + + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("test section", new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + })); + + var calculation = new HeightStructuresCalculation(); + + var activity = new HeightStructuresCalculationActivity(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_HeightStructuresWithoutHydraulicBoundaryLocationCalculation_LogValidationStartAndEndWithError() + { + // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); @@ -64,7 +103,14 @@ new Point2D(1, 1) })); - var calculation = new HeightStructuresCalculation(); + var calculation = new HeightStructuresCalculation() + { + InputParameters = + { + Structure = new TestHeightStructure() + } + }; + calculation.InputParameters.DeviationWaveDirection = (RoundedDouble) 0; var activity = new HeightStructuresCalculationActivity(calculation, "", failureMechanism, assessmentSection); @@ -75,26 +121,25 @@ TestHelper.AssertLogMessages(call, messages => { var msgs = messages.ToArray(); - Assert.AreEqual(4, msgs.Length); + 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("Validatie mislukt: Er is geen kunstwerk geselecteerd.", msgs[2]); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[3]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[2]); }); Assert.AreEqual(ActivityState.Failed, activity.State); } [Test] - public void Run_InvalidHeightStructuresCalculationInvalidHydraulicBoundaryDatabase_LogValidationStartAndEndWithError() + public void Run_HeightStructuresWithoutStructureCalculation_LogValidationStartAndEndWithError() { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); + + using (var importer = new HydraulicBoundaryDatabaseImporter()) { - HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - { - FilePath = Path.Combine(testDataPath, "notexisting.sqlite") - } - }; + importer.Import(assessmentSection, validFilePath); + } var failureMechanism = new HeightStructuresFailureMechanism(); failureMechanism.AddSection(new FailureMechanismSection("test section", new[] @@ -103,7 +148,13 @@ new Point2D(1, 1) })); - var calculation = new HeightStructuresCalculation(); + var calculation = new HeightStructuresCalculation() + { + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1234, "location", 0, 0) + } + }; var activity = new HeightStructuresCalculationActivity(calculation, "", failureMechanism, assessmentSection); @@ -116,7 +167,7 @@ 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("Validatie mislukt: Er is geen kunstwerk geselecteerd.", msgs[1]); StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[2]); }); Assert.AreEqual(ActivityState.Failed, activity.State);