Index: Core/Common/test/Core.Common.TestUtil/TestDataPath.cs =================================================================== diff -u -r9102a2e0e7257b746bbc884be57d5b8dce3dab57 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Core/Common/test/Core.Common.TestUtil/TestDataPath.cs (.../TestDataPath.cs) (revision 9102a2e0e7257b746bbc884be57d5b8dce3dab57) +++ Core/Common/test/Core.Common.TestUtil/TestDataPath.cs (.../TestDataPath.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -48,11 +48,6 @@ public static readonly TestDataPath IO = System.IO.Path.Combine("Ringtoets", "Common", "test", "Ringtoets.Common.IO.Test"); } - public static class HeightStructures - { - public static readonly TestDataPath Integration = System.IO.Path.Combine("Ringtoets", "HeightStructures", "test", "Ringtoets.HeightStructures.Integration.Test"); - } - public static class HydraRing { public static readonly TestDataPath IO = System.IO.Path.Combine("Ringtoets", "HydraRing", "test", "Ringtoets.HydraRing.IO.Test"); @@ -62,6 +57,7 @@ public static class Integration { public static readonly TestDataPath Forms = System.IO.Path.Combine("Ringtoets", "Integration", "test", "Ringtoets.Integration.Forms.Test"); + public static readonly TestDataPath Service = System.IO.Path.Combine("Ringtoets", "Integration", "test", "Ringtoets.Integration.Service.Test"); } public static class GrassCoverErosionInwards Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -rf5ed0a2ad860787e42f81146b5b5d768d99adace -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision f5ed0a2ad860787e42f81146b5b5d768d99adace) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -687,10 +687,9 @@ /// /// Looks up a localized string similar to Herstellen van de verbinding met de hydraulische randvoorwaarden database is mislukt. {0}. /// - public static string GuiPlugin_VerifyHydraulicBoundaryDatabasePath_Hydraulic_boundary_database_connection_failed_0_ { + public static string Hydraulic_boundary_database_connection_failed_0_ { get { - return ResourceManager.GetString("GuiPlugin_VerifyHydraulicBoundaryDatabasePath_Hydraulic_boundary_database_connect" + - "ion_failed_0_", resourceCulture); + return ResourceManager.GetString("Hydraulic_boundary_database_connection_failed_0_", resourceCulture); } } Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx =================================================================== diff -u -rf5ed0a2ad860787e42f81146b5b5d768d99adace -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision f5ed0a2ad860787e42f81146b5b5d768d99adace) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -319,7 +319,7 @@ Er zijn geen berekeningen om te valideren. - + Herstellen van de verbinding met de hydraulische randvoorwaarden database is mislukt. {0} Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/Ringtoets.GrassCoverErosionInwards.Data.csproj =================================================================== diff -u -rc65d19779f30d0192ec94761faa85521f1070b53 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/Ringtoets.GrassCoverErosionInwards.Data.csproj (.../Ringtoets.GrassCoverErosionInwards.Data.csproj) (revision c65d19779f30d0192ec94761faa85521f1070b53) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/Ringtoets.GrassCoverErosionInwards.Data.csproj (.../Ringtoets.GrassCoverErosionInwards.Data.csproj) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -85,6 +85,7 @@ {70F8CC9C-5BC8-4FB2-B201-EAE7FA8088C2} Ringtoets.HydraRing.Data + False Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs =================================================================== diff -u -r6952c1fa40cd233e974abf1a31867bcd49b5795e -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs (.../GrassCoverErosionInwardsGuiPlugin.cs) (revision 6952c1fa40cd233e974abf1a31867bcd49b5795e) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs (.../GrassCoverErosionInwardsGuiPlugin.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -191,7 +191,7 @@ var validationProblem = HydraulicDatabaseHelper.ValidatePathForCalculation(assessmentSection.HydraulicBoundaryDatabase.FilePath); if (!string.IsNullOrEmpty(validationProblem)) { - return string.Format(RingtoetsCommonFormsResources.GuiPlugin_VerifyHydraulicBoundaryDatabasePath_Hydraulic_boundary_database_connection_failed_0_, validationProblem); + return string.Format(RingtoetsCommonFormsResources.Hydraulic_boundary_database_connection_failed_0_, validationProblem); } return null; Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Ringtoets.GrassCoverErosionInwards.Plugin.csproj =================================================================== diff -u -r0209ecd38a9cb1e7224ceabe8b13e0697346abb9 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Ringtoets.GrassCoverErosionInwards.Plugin.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.csproj) (revision 0209ecd38a9cb1e7224ceabe8b13e0697346abb9) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Ringtoets.GrassCoverErosionInwards.Plugin.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.csproj) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -93,6 +93,7 @@ {D951D6DA-FE83-4920-9FDB-63BF96480B54} Ringtoets.Common.Service + False {888D4097-8BC2-4703-9FB1-8744C94D525E} @@ -107,6 +108,7 @@ {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70} Ringtoets.HydraRing.IO + False {90de728e-48ef-4665-ab38-3d88e41d9f4d} @@ -121,6 +123,7 @@ {5D158D8E-A5EB-489C-A885-87E13BC0D3B3} Ringtoets.GrassCoverErosionInwards.Service + False Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationActivity.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationActivity.cs (.../GrassCoverErosionInwardsCalculationActivity.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationActivity.cs (.../GrassCoverErosionInwardsCalculationActivity.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -67,7 +67,7 @@ protected override void OnRun() { - if (!GrassCoverErosionInwardsCalculationService.Validate(calculation)) + if (!GrassCoverErosionInwardsCalculationService.Validate(calculation, assessmentSection)) { State = ActivityState.Failed; return; Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs (.../GrassCoverErosionInwardsCalculationService.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs (.../GrassCoverErosionInwardsCalculationService.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -23,13 +23,15 @@ using System.Linq; using Core.Common.Base.Properties; using log4net; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Service; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.HydraRing.Calculation.Data; using Ringtoets.HydraRing.Calculation.Data.Input.Overtopping; using Ringtoets.HydraRing.Calculation.Data.Output; using Ringtoets.HydraRing.Calculation.Services; +using Ringtoets.HydraRing.IO; using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources; namespace Ringtoets.GrassCoverErosionInwards.Service @@ -46,13 +48,14 @@ /// the execution of the operation. /// /// The for which to validate the values. + /// The for which to validate the values. /// False if contains validation errors; True otherwise. - internal static bool Validate(GrassCoverErosionInwardsCalculation calculation) + internal static bool Validate(GrassCoverErosionInwardsCalculation calculation, IAssessmentSection assessmentSection) { grassCoverErosionInwardsCalculationLogger.Info(string.Format(RingtoetsCommonServiceResources.Validation_Subject_0_started_Time_1_, calculation.Name, DateTimeService.CurrentTimeAsString)); - var inputValidationResults = ValidateInput(calculation.InputParameters); + var inputValidationResults = ValidateInput(calculation.InputParameters, assessmentSection); if (inputValidationResults.Count > 0) { @@ -155,7 +158,7 @@ } } - private static List ValidateInput(GrassCoverErosionInwardsInput inputParameters) + private static List ValidateInput(GrassCoverErosionInwardsInput inputParameters, IAssessmentSection assessmentSection) { List validationResult = new List(); @@ -164,6 +167,13 @@ validationResult.Add(RingtoetsCommonServiceResources.CalculationService_ValidateInput_No_hydraulic_boundary_location_selected); } + var validationProblem = HydraulicDatabaseHelper.ValidatePathForCalculation(assessmentSection.HydraulicBoundaryDatabase.FilePath); + + if (!string.IsNullOrEmpty(validationProblem)) + { + validationResult.Add(validationProblem); + } + return validationResult; } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Ringtoets.GrassCoverErosionInwards.Service.csproj =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Ringtoets.GrassCoverErosionInwards.Service.csproj (.../Ringtoets.GrassCoverErosionInwards.Service.csproj) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Ringtoets.GrassCoverErosionInwards.Service.csproj (.../Ringtoets.GrassCoverErosionInwards.Service.csproj) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -51,10 +51,12 @@ {3BBFD65B-B277-4E50-AE6D-BD24C3434609} Core.Common.Base + False {c90b77da-e421-43cc-b82e-529651bc21ac} Core.Common.Version + False {d4200f43-3f72-4f42-af0a-8ced416a38ec} @@ -64,19 +66,27 @@ {D951D6DA-FE83-4920-9FDB-63BF96480B54} Ringtoets.Common.Service + False {888D4097-8BC2-4703-9FB1-8744C94D525E} Ringtoets.HydraRing.Calculation + False {70f8cc9c-5bc8-4fb2-b201-eae7fa8088c2} Ringtoets.HydraRing.Data False + + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70} + Ringtoets.HydraRing.IO + False + {90DE728E-48EF-4665-AB38-3D88E41D9F4D} Ringtoets.GrassCoverErosionInwards.Data + False Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -352,7 +352,7 @@ ToolStripItem contextMenuItem = contextMenu.Items[contextMenuCalculateIndex]; Assert.AreEqual(RingtoetsCommonFormsResources.Calculate, contextMenuItem.Text); - StringAssert.Contains(String.Format(RingtoetsCommonFormsResources.GuiPlugin_VerifyHydraulicBoundaryDatabasePath_Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); + StringAssert.Contains(String.Format(RingtoetsCommonFormsResources.Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculateIcon, contextMenuItem.Image); Assert.IsFalse(contextMenuItem.Enabled); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -477,7 +477,7 @@ ToolStripItem contextMenuItem = contextMenu.Items[contextMenuClearAllIndexRootGroup]; Assert.AreEqual(RingtoetsFormsResources.Calculate_all, contextMenuItem.Text); - StringAssert.Contains(string.Format(RingtoetsFormsResources.GuiPlugin_VerifyHydraulicBoundaryDatabasePath_Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); + StringAssert.Contains(string.Format(RingtoetsFormsResources.Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.CalculateAllIcon, contextMenuItem.Image); Assert.IsFalse(contextMenuItem.Enabled); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -477,7 +477,7 @@ ToolStripItem contextMenuItem = contextMenu.Items[contextMenuCalculateAllIndex]; Assert.AreEqual(RingtoetsFormsResources.Calculate_all, contextMenuItem.Text); - StringAssert.Contains(string.Format(RingtoetsFormsResources.GuiPlugin_VerifyHydraulicBoundaryDatabasePath_Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); + StringAssert.Contains(string.Format(RingtoetsFormsResources.Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.CalculateAllIcon, contextMenuItem.Image); Assert.IsFalse(contextMenuItem.Enabled); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -41,9 +41,74 @@ [TestFixture] public class GrassCoverErosionInwardsCalculationActivityIntegrationTest { - private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HeightStructures.Integration, "HeightStructuresCalculation"); + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); [Test] + public void Run_InvalidGrassCoverErosionInwardsCalculation_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 GrassCoverErosionInwardsFailureMechanism(); + var calculation = new GrassCoverErosionInwardsCalculation(); + + var activity = new GrassCoverErosionInwardsCalculationActivity(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 randvoorwaarde locatie 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_InvalidHeightStructuresCalculationInvalidHydraulicBoundaryDatabase_LogValidationStartAndEndWithError() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = Path.Combine(testDataPath, "notexisting.sqlite") + } + }; + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var calculation = new GrassCoverErosionInwardsCalculation(); + + var activity = new GrassCoverErosionInwardsCalculationActivity(calculation, "", failureMechanism, assessmentSection); + + // Call + Action call = () => activity.Run(); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(4, msgs.Length); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]); + StringAssert.StartsWith("Validatie mislukt: Er is geen hydraulische randvoorwaarde locatie geselecteerd.", msgs[1]); + StringAssert.StartsWith("Validatie mislukt: Fout bij het lezen van bestand", msgs[2]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[3]); + }); + Assert.AreEqual(ActivityState.Failed, activity.State); + } + + [Test] public void Run_ValidHeightStructuresCalculation_PerformHeightStructuresValidationAndCalculationAndLogStartAndEnd() { // Setup Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationServiceIntegrationTest.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationServiceIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationServiceIntegrationTest.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationServiceIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationServiceIntegrationTest.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -39,9 +39,122 @@ [TestFixture] public class GrassCoverErosionInwardsCalculationServiceIntegrationTest { - private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HeightStructures.Integration, "HeightStructuresCalculation"); + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); [Test] + public void Validate_InvalidCalculationInputValidHydraulicBoundaryDatabase_LogsErrorAndReturnsFalse() + { + // 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); + } + + const string name = ""; + + GrassCoverErosionInwardsCalculation calculation = new GrassCoverErosionInwardsCalculation + { + Name = name + }; + + + // Call + bool isValid = false; + Action call = () => isValid = GrassCoverErosionInwardsCalculationService.Validate(calculation, assessmentSection); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(3, msgs.Length); + StringAssert.StartsWith(String.Format("Validatie van '{0}' gestart om: ", name), msgs[0]); + StringAssert.StartsWith("Validatie mislukt: Er is geen hydraulische randvoorwaarde locatie geselecteerd.", msgs[1]); + StringAssert.StartsWith(String.Format("Validatie van '{0}' beëindigd om: ", name), msgs[2]); + }); + Assert.IsFalse(isValid); + } + + [Test] + public void Validate_ValidCalculationInputAndInvalidHydraulicBoundaryDatabase_ReturnsFalse() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = Path.Combine(testDataPath, "notexisting.sqlite") + } + }; + + const string name = ""; + + GrassCoverErosionInwardsCalculation calculation = new GrassCoverErosionInwardsCalculation + { + Name = name, + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "name", 2, 2) + } + }; + + + // Call + bool isValid = false; + Action call = () => isValid = GrassCoverErosionInwardsCalculationService.Validate(calculation, assessmentSection); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(3, msgs.Length); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", 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: ", name), msgs[2]); + }); + Assert.IsFalse(isValid); + } + + [Test] + public void Validate_ValidCalculationInputAndHydraulicBoundaryDatabase_ReturnsTrue() + { + // 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); + } + + const string name = ""; + + GrassCoverErosionInwardsCalculation calculation = new GrassCoverErosionInwardsCalculation + { + Name = name, + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "name", 2, 2) + } + }; + + + // Call + bool isValid = false; + Action call = () => isValid = GrassCoverErosionInwardsCalculationService.Validate(calculation, assessmentSection); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(2, msgs.Length); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", name), msgs[0]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", name), msgs[1]); + }); + Assert.IsTrue(isValid); + } + + [Test] public void Calculate_ValidCalculation_LogStartAndEndAndReturnOutput() { // Setup Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/GrassCoverErosionInwardsCalculationActivityTest.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/GrassCoverErosionInwardsCalculationActivityTest.cs (.../GrassCoverErosionInwardsCalculationActivityTest.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/GrassCoverErosionInwardsCalculationActivityTest.cs (.../GrassCoverErosionInwardsCalculationActivityTest.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -19,10 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; -using System.Linq; using Core.Common.Base.Service; -using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; @@ -55,34 +52,5 @@ mocks.VerifyAll(); } - - [Test] - public void Run_InvalidGrassCoverErosionInwardsCalculation_LogValidationStartAndEndWithError() - { - // Setup - var mocks = new MockRepository(); - var assessmentSectionMock = mocks.StrictMock(); - mocks.ReplayAll(); - - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var calculation = new GrassCoverErosionInwardsCalculation(); - - var activity = new GrassCoverErosionInwardsCalculationActivity(calculation, "", failureMechanism, assessmentSectionMock); - - // 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: ", msgs[1]); - StringAssert.StartsWith(String.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[2]); - }); - Assert.AreEqual(ActivityState.Failed, activity.State); - mocks.VerifyAll(); - } } } \ No newline at end of file Fisheye: Tag 0a51f20ac93373a43f79bb4c6327bce1d46545c6 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/GrassCoverErosionInwardsCalculationServiceTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/Ringtoets.GrassCoverErosionInwards.Service.Test.csproj =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/Ringtoets.GrassCoverErosionInwards.Service.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Service.Test.csproj) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/Ringtoets.GrassCoverErosionInwards.Service.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Service.Test.csproj) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -50,7 +50,6 @@ - Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/Ringtoets.HeightStructures.Data.csproj =================================================================== diff -u -r14de3deecd2cff7f6abe41ed6dc5dc016c4c81e0 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/Ringtoets.HeightStructures.Data.csproj (.../Ringtoets.HeightStructures.Data.csproj) (revision 14de3deecd2cff7f6abe41ed6dc5dc016c4c81e0) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/Ringtoets.HeightStructures.Data.csproj (.../Ringtoets.HeightStructures.Data.csproj) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -55,6 +55,7 @@ {3BBFD65B-B277-4E50-AE6D-BD24C3434609} Core.Common.Base + False {c90b77da-e421-43cc-b82e-529651bc21ac} Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj =================================================================== diff -u -r5150f97d1c5e019d39723b22ff200e48b2112e71 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision 5150f97d1c5e019d39723b22ff200e48b2112e71) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -94,6 +94,7 @@ {4D840673-3812-4338-A352-84854E32B8A0} Ringtoets.Common.Forms + False {70F8CC9C-5BC8-4FB2-B201-EAE7FA8088C2} Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresGuiPlugin.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresGuiPlugin.cs (.../HeightStructuresGuiPlugin.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresGuiPlugin.cs (.../HeightStructuresGuiPlugin.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -154,7 +154,7 @@ var validationProblem = HydraulicDatabaseHelper.ValidatePathForCalculation(assessmentSection.HydraulicBoundaryDatabase.FilePath); if (!string.IsNullOrEmpty(validationProblem)) { - return string.Format(RingtoetsCommonFormsResources.GuiPlugin_VerifyHydraulicBoundaryDatabasePath_Hydraulic_boundary_database_connection_failed_0_, + return string.Format(RingtoetsCommonFormsResources.Hydraulic_boundary_database_connection_failed_0_, validationProblem); } Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/Ringtoets.HeightStructures.Plugin.csproj =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/Ringtoets.HeightStructures.Plugin.csproj (.../Ringtoets.HeightStructures.Plugin.csproj) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/Ringtoets.HeightStructures.Plugin.csproj (.../Ringtoets.HeightStructures.Plugin.csproj) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -88,14 +88,17 @@ {888D4097-8BC2-4703-9FB1-8744C94D525E} Ringtoets.HydraRing.Calculation + False {70f8cc9c-5bc8-4fb2-b201-eae7fa8088c2} Ringtoets.HydraRing.Data + False {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70} Ringtoets.HydraRing.IO + False {1C0017D8-35B5-4CA0-8FC7-A83F46DBDC99} @@ -110,6 +113,7 @@ {20DD96D3-001E-407A-AE2E-432887088F1F} Ringtoets.HeightStructures.Service + False Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationActivity.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationActivity.cs (.../HeightStructuresCalculationActivity.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationActivity.cs (.../HeightStructuresCalculationActivity.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -67,7 +67,7 @@ protected override void OnRun() { - if (!HeightStructuresCalculationService.Validate(calculation)) + if (!HeightStructuresCalculationService.Validate(calculation, assessmentSection)) { State = ActivityState.Failed; return; Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs (.../HeightStructuresCalculationService.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs (.../HeightStructuresCalculationService.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -21,6 +21,7 @@ using System.Collections.Generic; using log4net; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Service; @@ -29,6 +30,7 @@ using Ringtoets.HydraRing.Calculation.Data.Input.Structures; using Ringtoets.HydraRing.Calculation.Data.Output; using Ringtoets.HydraRing.Calculation.Services; +using Ringtoets.HydraRing.IO; using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources; namespace Ringtoets.HeightStructures.Service @@ -45,13 +47,14 @@ /// the execution of the operation. /// /// The for which to validate the values. + /// The for which to validate the values. /// False if contains validation errors; True otherwise. - internal static bool Validate(HeightStructuresCalculation calculation) + internal static bool Validate(HeightStructuresCalculation calculation, IAssessmentSection assessmentSection) { heightStructuresCalculationLogger.Info(string.Format(RingtoetsCommonServiceResources.Validation_Subject_0_started_Time_1_, calculation.Name, DateTimeService.CurrentTimeAsString)); - var inputValidationResults = ValidateInput(calculation.InputParameters); + var inputValidationResults = ValidateInput(calculation.InputParameters, assessmentSection); if (inputValidationResults.Count > 0) { @@ -87,7 +90,7 @@ if (output == null) { - heightStructuresCalculationLogger.ErrorFormat(Resources.HeightStructuresCalculationService_Calculate_Error_in_height_structures_0_calculation, calculation.Name); + LogMessagesAsError(Resources.HeightStructuresCalculationService_Calculate_Error_in_height_structures_0_calculation, calculation.Name); } return output; @@ -121,7 +124,7 @@ calculation.InputParameters.StormDuration.Mean, calculation.InputParameters.StormDuration.GetVariationCoefficient()); } - private static List ValidateInput(HeightStructuresInput inputParameters) + private static List ValidateInput(HeightStructuresInput inputParameters, IAssessmentSection assessmentSection) { List validationResult = new List(); @@ -130,6 +133,13 @@ validationResult.Add(RingtoetsCommonServiceResources.CalculationService_ValidateInput_No_hydraulic_boundary_location_selected); } + var validationProblem = HydraulicDatabaseHelper.ValidatePathForCalculation(assessmentSection.HydraulicBoundaryDatabase.FilePath); + + if (!string.IsNullOrEmpty(validationProblem)) + { + validationResult.Add(validationProblem); + } + return validationResult; } Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/Ringtoets.HeightStructures.Service.csproj =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/Ringtoets.HeightStructures.Service.csproj (.../Ringtoets.HeightStructures.Service.csproj) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/Ringtoets.HeightStructures.Service.csproj (.../Ringtoets.HeightStructures.Service.csproj) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -66,23 +66,32 @@ {D4200F43-3F72-4F42-AF0A-8CED416A38EC} Ringtoets.Common.Data + False {D951D6DA-FE83-4920-9FDB-63BF96480B54} Ringtoets.Common.Service + False {888D4097-8BC2-4703-9FB1-8744C94D525E} Ringtoets.HydraRing.Calculation + False {70f8cc9c-5bc8-4fb2-b201-eae7fa8088c2} Ringtoets.HydraRing.Data False + + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70} + Ringtoets.HydraRing.IO + False + {1C0017D8-35B5-4CA0-8FC7-A83F46DBDC99} Ringtoets.HeightStructures.Data + False Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj =================================================================== diff -u -r9f9e6d0ed59b60fd6b686989f028fc588df8e4ea -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision 9f9e6d0ed59b60fd6b686989f028fc588df8e4ea) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -100,6 +100,11 @@ {30e4c2ae-719e-4d70-9fa9-668a9767fbfa} Core.Common.Gui + + {f49bd8b2-332a-4c91-a196-8cce0a2c7d98} + Core.Common.Utils + True + {26214BD0-DAFB-4CFC-8EB2-80C5D53C859E} Core.Common.Gui.TestUtil @@ -120,6 +125,11 @@ {4843D6E5-066F-4795-94F5-1D53932DD03C} Ringtoets.Common.Data.TestUtil + + {888d4097-8bc2-4703-9fb1-8744c94d525e} + Ringtoets.HydraRing.Calculation + True + {70F8CC9C-5BC8-4FB2-B201-EAE7FA8088C2} Ringtoets.HydraRing.Data Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationContextTreeNodeInfoTest.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationContextTreeNodeInfoTest.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -343,7 +343,7 @@ ToolStripItem contextMenuItem = contextMenu.Items[contextMenuCalculateIndex]; Assert.AreEqual(RingtoetsCommonFormsResources.Calculate, contextMenuItem.Text); - StringAssert.Contains(String.Format(RingtoetsCommonFormsResources.GuiPlugin_VerifyHydraulicBoundaryDatabasePath_Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); + StringAssert.Contains(String.Format(RingtoetsCommonFormsResources.Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculateIcon, contextMenuItem.Image); Assert.IsFalse(contextMenuItem.Enabled); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -475,7 +475,7 @@ ToolStripItem contextMenuItem = contextMenu.Items[contextMenuClearAllIndexRootGroup]; Assert.AreEqual(RingtoetsFormsResources.Calculate_all, contextMenuItem.Text); - StringAssert.Contains(string.Format(RingtoetsFormsResources.GuiPlugin_VerifyHydraulicBoundaryDatabasePath_Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); + StringAssert.Contains(string.Format(RingtoetsFormsResources.Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.CalculateAllIcon, contextMenuItem.Image); Assert.IsFalse(contextMenuItem.Enabled); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -472,7 +472,7 @@ ToolStripItem contextMenuItem = contextMenu.Items[contextMenuCalculateAllIndex]; Assert.AreEqual(RingtoetsFormsResources.Calculate_all, contextMenuItem.Text); - StringAssert.Contains(string.Format(RingtoetsFormsResources.GuiPlugin_VerifyHydraulicBoundaryDatabasePath_Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); + StringAssert.Contains(string.Format(RingtoetsFormsResources.Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.CalculateAllIcon, contextMenuItem.Image); Assert.IsFalse(contextMenuItem.Enabled); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/HeightStructuresCalculationActivityIntegrationTest.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/HeightStructuresCalculationActivityIntegrationTest.cs (.../HeightStructuresCalculationActivityIntegrationTest.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/HeightStructuresCalculationActivityIntegrationTest.cs (.../HeightStructuresCalculationActivityIntegrationTest.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -41,9 +41,74 @@ [TestFixture] public class HeightStructuresCalculationActivityIntegrationTest { - private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HeightStructures.Integration, "HeightStructuresCalculation"); + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); [Test] + public void Run_InvalidHeightStructuresCalculation_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 HeightStructuresFailureMechanism(); + 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: Er is geen hydraulische randvoorwaarde locatie 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_InvalidHeightStructuresCalculationInvalidHydraulicBoundaryDatabase_LogValidationStartAndEndWithError() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = Path.Combine(testDataPath, "notexisting.sqlite") + } + }; + + var failureMechanism = new HeightStructuresFailureMechanism(); + 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(4, msgs.Length); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]); + StringAssert.StartsWith("Validatie mislukt: Er is geen hydraulische randvoorwaarde locatie geselecteerd.", msgs[1]); + StringAssert.StartsWith("Validatie mislukt: Fout bij het lezen van bestand", msgs[2]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[3]); + }); + Assert.AreEqual(ActivityState.Failed, activity.State); + } + + [Test] public void Run_ValidHeightStructuresCalculation_PerformHeightStructuresValidationAndCalculationAndLogStartAndEnd() { // Setup @@ -81,10 +146,10 @@ { var msgs = messages.ToArray(); Assert.AreEqual(4, msgs.Length); - StringAssert.StartsWith(String.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]); - StringAssert.StartsWith(String.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[1]); - StringAssert.StartsWith(String.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[2]); - StringAssert.StartsWith(String.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[3]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[1]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[2]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[3]); }); Assert.AreEqual(ActivityState.Executed, activity.State); } @@ -93,10 +158,6 @@ public void Run_InValidHeightStructuresCalculationAndRan_PerformHeightStructuresValidationAndCalculationAndLogStartAndEndAndError() { // Setup - var mocks = new MockRepository(); - var observerMock = mocks.StrictMock(); - mocks.ReplayAll(); - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); @@ -121,8 +182,6 @@ } }; - calculation.Attach(observerMock); - var activity = new HeightStructuresCalculationActivity(calculation, testDataPath, failureMechanism, assessmentSection); // Call @@ -133,14 +192,13 @@ { var msgs = messages.ToArray(); Assert.AreEqual(5, msgs.Length); - StringAssert.StartsWith(String.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]); - StringAssert.StartsWith(String.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[1]); - StringAssert.StartsWith(String.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[2]); - StringAssert.StartsWith(String.Format("Hoogte kunstwerk '{0}' niet gelukt.", calculation.Name), msgs[3]); - StringAssert.StartsWith(String.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[4]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[1]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[2]); + StringAssert.StartsWith(string.Format("Hoogte kunstwerk '{0}' niet gelukt.", calculation.Name), msgs[3]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[4]); }); Assert.AreEqual(ActivityState.Failed, activity.State); - mocks.VerifyAll(); } [Test] Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/HeightStructuresCalculationServiceIntegrationTest.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/HeightStructuresCalculationServiceIntegrationTest.cs (.../HeightStructuresCalculationServiceIntegrationTest.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/HeightStructuresCalculationServiceIntegrationTest.cs (.../HeightStructuresCalculationServiceIntegrationTest.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -39,9 +39,122 @@ [TestFixture] public class HeightStructuresCalculationServiceIntegrationTest { - private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HeightStructures.Integration, "HeightStructuresCalculation"); + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); [Test] + public void Validate_InvalidCalculationInputValidHydraulicBoundaryDatabase_LogsErrorAndReturnsFalse() + { + // 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); + } + + const string name = ""; + + HeightStructuresCalculation calculation = new HeightStructuresCalculation + { + Name = name + }; + + + // Call + bool isValid = false; + Action call = () => isValid = HeightStructuresCalculationService.Validate(calculation, assessmentSection); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(3, msgs.Length); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", name), msgs[0]); + StringAssert.StartsWith("Validatie mislukt: Er is geen hydraulische randvoorwaarde locatie geselecteerd.", msgs[1]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", name), msgs[2]); + }); + Assert.IsFalse(isValid); + } + + [Test] + public void Validate_ValidCalculationInputAndInvalidHydraulicBoundaryDatabase_ReturnsFalse() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = Path.Combine(testDataPath, "notexisting.sqlite") + } + }; + + const string name = ""; + + HeightStructuresCalculation calculation = new HeightStructuresCalculation + { + Name = name, + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "name", 2, 2) + } + }; + + + // Call + bool isValid = false; + Action call = () => isValid = HeightStructuresCalculationService.Validate(calculation, assessmentSection); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(3, msgs.Length); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", 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: ", name), msgs[2]); + }); + Assert.IsFalse(isValid); + } + + [Test] + public void Validate_ValidCalculationInputAndHydraulicBoundaryDatabase_ReturnsTrue() + { + // 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); + } + + const string name = ""; + + HeightStructuresCalculation calculation = new HeightStructuresCalculation + { + Name = name, + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "name", 2, 2) + } + }; + + + // Call + bool isValid = false; + Action call = () => isValid = HeightStructuresCalculationService.Validate(calculation, assessmentSection); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(2, msgs.Length); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", name), msgs[0]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", name), msgs[1]); + }); + Assert.IsTrue(isValid); + } + + [Test] public void Calculate_ValidCalculation_LogStartAndEndAndReturnOutput() { // Setup @@ -80,8 +193,8 @@ { var msgs = messages.ToArray(); Assert.AreEqual(2, msgs.Length); - StringAssert.StartsWith(String.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[0]); - StringAssert.StartsWith(String.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[1]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[0]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[1]); }); Assert.IsNotNull(output); } @@ -125,9 +238,9 @@ { var msgs = messages.ToArray(); Assert.AreEqual(3, msgs.Length); - StringAssert.StartsWith(String.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[0]); - StringAssert.StartsWith(String.Format("Hoogte kunstwerk '{0}' niet gelukt.", calculation.Name), msgs[1]); - StringAssert.StartsWith(String.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[2]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[0]); + StringAssert.StartsWith(string.Format("Hoogte kunstwerk '{0}' niet gelukt.", calculation.Name), msgs[1]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[2]); }); Assert.IsNull(output); } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/test-data/HeightStructuresCalculation/HLCD.sqlite =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 Binary files differ Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/test-data/HeightStructuresCalculation/HRD dutch coast south.sqlite =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 Binary files differ Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Service.Test/HeightStructuresCalculationActivityTest.cs =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Service.Test/HeightStructuresCalculationActivityTest.cs (.../HeightStructuresCalculationActivityTest.cs) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Service.Test/HeightStructuresCalculationActivityTest.cs (.../HeightStructuresCalculationActivityTest.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -19,10 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; -using System.Linq; using Core.Common.Base.Service; -using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; @@ -55,34 +52,5 @@ mocks.VerifyAll(); } - - [Test] - public void Run_InvalidHeightStructuresCalculation_LogValidationStartAndEndWithError() - { - // Setup - var mocks = new MockRepository(); - var assessmentSectionMock = mocks.StrictMock(); - mocks.ReplayAll(); - - var failureMechanism = new HeightStructuresFailureMechanism(); - var calculation = new HeightStructuresCalculation(); - - var activity = new HeightStructuresCalculationActivity(calculation, "", failureMechanism, assessmentSectionMock); - - // 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: ", msgs[1]); - StringAssert.StartsWith(String.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[2]); - }); - Assert.AreEqual(ActivityState.Failed, activity.State); - mocks.VerifyAll(); - } } } \ No newline at end of file Fisheye: Tag 0a51f20ac93373a43f79bb4c6327bce1d46545c6 refers to a dead (removed) revision in file `Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Service.Test/HeightStructuresCalculationServiceTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Service.Test/Ringtoets.HeightStructures.Service.Test.csproj =================================================================== diff -u -re568165b751acf8d72cdf0d128f76d7792dadb56 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Service.Test/Ringtoets.HeightStructures.Service.Test.csproj (.../Ringtoets.HeightStructures.Service.Test.csproj) (revision e568165b751acf8d72cdf0d128f76d7792dadb56) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Service.Test/Ringtoets.HeightStructures.Service.Test.csproj (.../Ringtoets.HeightStructures.Service.Test.csproj) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -48,7 +48,6 @@ - Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs =================================================================== diff -u -ra3357275af675af3714fc89b99c554c288759ae2 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision a3357275af675af3714fc89b99c554c288759ae2) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -190,24 +190,6 @@ } /// - /// Looks up a localized string similar to Toetspeil berekenen voor locatie '{0}'. - /// - public static string RingtoetsGuiPlugin_Calculate_assessment_level_for_location_0_ { - get { - return ResourceManager.GetString("RingtoetsGuiPlugin_Calculate_assessment_level_for_location_0_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Er is een fout opgetreden tijdens de berekening: inspecteer het logbestand.. - /// - public static string RingtoetsGuiPlugin_Error_during_assessment_level_calculation { - get { - return ResourceManager.GetString("RingtoetsGuiPlugin_Error_during_assessment_level_calculation", resourceCulture); - } - } - - /// /// Looks up a localized string similar to Berekeningen konden niet worden gestart. {0}. /// public static string RingtoetsGuiPlugin_HydraulicBoundaryDatabaseContextMenuStrip_Start_calculation_failed_0_ { Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx =================================================================== diff -u -ra3357275af675af3714fc89b99c554c288759ae2 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx (.../Resources.resx) (revision a3357275af675af3714fc89b99c554c288759ae2) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -157,12 +157,6 @@ Het bijbehorende HLCD bestand is niet gevonden in dezelfde map als het HRD bestand. - - Toetspeil berekenen voor locatie '{0}' - - - Er is een fout opgetreden tijdens de berekening: inspecteer het logbestand. - Berekeningen konden niet worden gestart. {0} Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj =================================================================== diff -u -rd01d386b22e750008cc95bd8a35983a13cdb18b1 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj (.../Ringtoets.Integration.Plugin.csproj) (revision d01d386b22e750008cc95bd8a35983a13cdb18b1) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj (.../Ringtoets.Integration.Plugin.csproj) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -179,6 +179,11 @@ Ringtoets.Integration.Forms False + + {28811c4a-6c18-42c1-88b2-a03a3784e2d0} + Ringtoets.Integration.Service + False + Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs =================================================================== diff -u -r7e462ac960dbcb49cc597a7331b1470cd72031d5 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 7e462ac960dbcb49cc597a7331b1470cd72031d5) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -64,6 +64,7 @@ using Ringtoets.Integration.Forms.Views.SectionResultViews; using Ringtoets.Integration.Plugin.FileImporters; using Ringtoets.Integration.Plugin.Properties; +using Ringtoets.Integration.Service; using Ringtoets.Piping.Data; using Ringtoets.Piping.Forms.PresentationObjects; using RingtoetsDataResources = Ringtoets.Integration.Data.Properties.Resources; @@ -483,7 +484,7 @@ if (validationProblem != null) { log.WarnFormat( - RingtoetsCommonFormsResources.GuiPlugin_VerifyHydraulicBoundaryDatabasePath_Hydraulic_boundary_database_connection_failed_0_, + RingtoetsCommonFormsResources.Hydraulic_boundary_database_connection_failed_0_, validationProblem); } } @@ -892,8 +893,7 @@ var validationProblem = HydraulicDatabaseHelper.ValidatePathForCalculation(hrdFile); if (validationProblem == null) { - var hlcdDirectory = Path.GetDirectoryName(hrdFile); - var activities = nodeData.WrappedData.HydraulicBoundaryDatabase.Locations.Select(hbl => CreateHydraRingTargetProbabilityCalculationActivity(nodeData.WrappedData, hbl, hlcdDirectory)).ToList(); + var activities = nodeData.WrappedData.HydraulicBoundaryDatabase.Locations.Select(hbl => new DesignWaterLevelCalculationActivity(nodeData.WrappedData, hbl)).ToList(); ActivityProgressDialogRunner.Run(Gui.MainWindow, activities); @@ -982,32 +982,6 @@ } } - private static TargetProbabilityCalculationActivity CreateHydraRingTargetProbabilityCalculationActivity(IAssessmentSection assessmentSection, - HydraulicBoundaryLocation hydraulicBoundaryLocation, string hlcdDirectory) - { - return HydraRingActivityFactory.Create( - string.Format(Resources.RingtoetsGuiPlugin_Calculate_assessment_level_for_location_0_, hydraulicBoundaryLocation.Id), - hlcdDirectory, - assessmentSection.Name, // TODO: Provide name of reference line instead - HydraRingTimeIntegrationSchemeType.FBC, - HydraRingUncertaintiesType.All, - new AssessmentLevelCalculationInput((int) hydraulicBoundaryLocation.Id, assessmentSection.FailureMechanismContribution.Norm), - () => { hydraulicBoundaryLocation.DesignWaterLevel = double.NaN; }, - output => { ParseHydraRingOutput(hydraulicBoundaryLocation, output); }); - } - - private static void ParseHydraRingOutput(HydraulicBoundaryLocation hydraulicBoundaryLocation, TargetProbabilityCalculationOutput output) - { - if (output != null) - { - hydraulicBoundaryLocation.DesignWaterLevel = output.Result; - } - else - { - throw new InvalidOperationException(Resources.RingtoetsGuiPlugin_Error_during_assessment_level_calculation); - } - } - private static bool IsClearCalculationConfirmationGiven() { var confirmation = MessageBox.Show( Index: Ringtoets/Integration/src/Ringtoets.Integration.Service/DesignWaterLevelCalculationActivity.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Service/DesignWaterLevelCalculationActivity.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Service/DesignWaterLevelCalculationActivity.cs (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -0,0 +1,95 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using Core.Common.Base.Service; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HydraRing.Calculation.Data.Output; +using Ringtoets.HydraRing.Calculation.Services; +using Ringtoets.HydraRing.Data; +using Ringtoets.Integration.Service.Properties; + +namespace Ringtoets.Integration.Service +{ + /// + /// for running a design water level calculation. + /// + public class DesignWaterLevelCalculationActivity : Activity + { + private readonly IAssessmentSection assessmentSection; + private readonly HydraulicBoundaryLocation hydraulicBoundaryLocation; + private TargetProbabilityCalculationOutput output; + + public override string Name + { + get + { + return string.Format(Resources.DesignWaterLevelCalculationService_Name_Calculate_assessment_level_for_location_0_, hydraulicBoundaryLocation.Id); + } + } + + /// + /// Creates a new instance of . + /// + /// The data which is used for the calculation. + /// The to perform the calculation for. + public DesignWaterLevelCalculationActivity(IAssessmentSection assessmentSection, HydraulicBoundaryLocation hydraulicBoundaryLocation) + { + this.assessmentSection = assessmentSection; + this.hydraulicBoundaryLocation = hydraulicBoundaryLocation; + } + + protected override void OnRun() + { + if (!DesignWaterLevelCalculationService.Validate(assessmentSection.HydraulicBoundaryDatabase, hydraulicBoundaryLocation)) + { + State = ActivityState.Failed; + return; + } + + LogMessages.Clear(); + hydraulicBoundaryLocation.DesignWaterLevel = double.NaN; + + output = DesignWaterLevelCalculationService.Calculate(assessmentSection, + assessmentSection.HydraulicBoundaryDatabase, + hydraulicBoundaryLocation, + assessmentSection.Name); // TODO: Provide name of reference line instead + + if (output == null) + { + State = ActivityState.Failed; + } + } + + protected override void OnCancel() + { + HydraRingCalculationService.CancelRunningCalculation(); + } + + protected override void OnFinish() + { + if (State == ActivityState.Executed) + { + hydraulicBoundaryLocation.DesignWaterLevel = output.Result; + hydraulicBoundaryLocation.NotifyObservers(); + } + } + } +} Index: Ringtoets/Integration/src/Ringtoets.Integration.Service/DesignWaterLevelCalculationService.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Service/DesignWaterLevelCalculationService.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Service/DesignWaterLevelCalculationService.cs (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -0,0 +1,127 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.IO; +using log4net; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Service; +using Ringtoets.HydraRing.Calculation.Data; +using Ringtoets.HydraRing.Calculation.Data.Input.Hydraulics; +using Ringtoets.HydraRing.Calculation.Data.Output; +using Ringtoets.HydraRing.Calculation.Services; +using Ringtoets.HydraRing.Data; +using Ringtoets.HydraRing.IO; +using Ringtoets.Integration.Service.Properties; + +using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Service +{ + /// + /// Service that provides methods for performing Hydra-Ring calculations for design water level. + /// + internal static class DesignWaterLevelCalculationService + { + private static readonly ILog designWaterLevelCalculationLogger = LogManager.GetLogger(typeof(DesignWaterLevelCalculationService)); + + /// + /// Performs validation over the values on the given . Error information is logged during + /// the execution of the operation. + /// + /// The for which to validate the values. + /// The for which to validate the values. + /// False if contains validation errors; True otherwise. + internal static bool Validate(HydraulicBoundaryDatabase hydraulicBoundaryDatabase, HydraulicBoundaryLocation hydraulicBoundaryLocation) + { + designWaterLevelCalculationLogger.Info(string.Format(RingtoetsCommonServiceResources.Validation_Subject_0_started_Time_1_, + hydraulicBoundaryLocation.Id, DateTimeService.CurrentTimeAsString)); + + var validationProblem = HydraulicDatabaseHelper.ValidatePathForCalculation(hydraulicBoundaryDatabase.FilePath); + var hasErrors = string.IsNullOrEmpty(validationProblem); + + if (!hasErrors) + { + LogMessagesAsError(RingtoetsCommonFormsResources.Hydraulic_boundary_database_connection_failed_0_, + validationProblem); + } + + LogValidationEndTime(hydraulicBoundaryLocation); + + return hasErrors; + } + + /// + /// Performs a design water level calculation based on the supplied and sets + /// if the calculation was successful. Error and status information is logged during the execution of the operation. + /// + /// The to base the input for the calculation upon. + /// The to base the input for the calculation upon. + /// The to perform the calculation for. + /// The id of the ring to perform the calculation for. + /// A on a successful calculation, null otherwise. + internal static TargetProbabilityCalculationOutput Calculate(IAssessmentSection assessmentSection, HydraulicBoundaryDatabase hydraulicBoundaryDatabase, + HydraulicBoundaryLocation hydraulicBoundaryLocation, string ringId) + { + designWaterLevelCalculationLogger.Info(string.Format(RingtoetsCommonServiceResources.Calculation_Subject_0_started_Time_1_, + hydraulicBoundaryLocation.Id, DateTimeService.CurrentTimeAsString)); + + try + { + var hlcdDirectory = Path.GetDirectoryName(hydraulicBoundaryDatabase.FilePath); + var input = CreateInput(assessmentSection, hydraulicBoundaryLocation); + + var output = HydraRingCalculationService.PerformCalculation(hlcdDirectory, ringId, HydraRingTimeIntegrationSchemeType.FBC, HydraRingUncertaintiesType.All, input); + + if (output == null) + { + LogMessagesAsError(Resources.DesignWaterLevelCalculationService_Calculate_Error_in_design_water_level_0_calculation, hydraulicBoundaryLocation.Id.ToString()); + } + + return output; + } + finally + { + designWaterLevelCalculationLogger.Info(string.Format(RingtoetsCommonServiceResources.Calculation_Subject_0_ended_Time_1_, + hydraulicBoundaryLocation.Id, DateTimeService.CurrentTimeAsString)); + } + } + + private static AssessmentLevelCalculationInput CreateInput(IAssessmentSection assessmentSection, HydraulicBoundaryLocation hydraulicBoundaryLocation) + { + return new AssessmentLevelCalculationInput((int) hydraulicBoundaryLocation.Id, assessmentSection.FailureMechanismContribution.Norm); + } + + private static void LogMessagesAsError(string format, params string[] errorMessages) + { + foreach (var errorMessage in errorMessages) + { + designWaterLevelCalculationLogger.ErrorFormat(format, errorMessage); + } + } + + private static void LogValidationEndTime(HydraulicBoundaryLocation hydraulicBoundaryLocation) + { + designWaterLevelCalculationLogger.Info(string.Format(RingtoetsCommonServiceResources.Validation_Subject_0_ended_Time_1_, + hydraulicBoundaryLocation.Id, DateTimeService.CurrentTimeAsString)); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Service/Properties/AssemblyInfo.cs =================================================================== diff -u -rd01d386b22e750008cc95bd8a35983a13cdb18b1 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/Integration/src/Ringtoets.Integration.Service/Properties/AssemblyInfo.cs (.../AssemblyInfo.cs) (revision d01d386b22e750008cc95bd8a35983a13cdb18b1) +++ Ringtoets/Integration/src/Ringtoets.Integration.Service/Properties/AssemblyInfo.cs (.../AssemblyInfo.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -20,8 +20,10 @@ // All rights reserved. using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [assembly: AssemblyTitle("Ringtoets.Integration.Service")] [assembly: AssemblyProduct("Ringtoets.Integration.Service")] [assembly: Guid("8793e349-2549-4fee-9814-51184268b6f6")] +[assembly: InternalsVisibleTo("Ringtoets.Integration.Service.Test")] \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Service/Properties/Resources.Designer.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Service/Properties/Resources.Designer.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Service/Properties/Resources.Designer.cs (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -0,0 +1,83 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.17929 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Ringtoets.Integration.Service.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Ringtoets.Integration.Service.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Er is een fout opgetreden tijdens de toetspeil berekening '{0}': inspecteer het logbestand.. + /// + internal static string DesignWaterLevelCalculationService_Calculate_Error_in_design_water_level_0_calculation { + get { + return ResourceManager.GetString("DesignWaterLevelCalculationService_Calculate_Error_in_design_water_level_0_calcul" + + "ation", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Toetspeil berekenen voor locatie '{0}'. + /// + internal static string DesignWaterLevelCalculationService_Name_Calculate_assessment_level_for_location_0_ { + get { + return ResourceManager.GetString("DesignWaterLevelCalculationService_Name_Calculate_assessment_level_for_location_0" + + "_", resourceCulture); + } + } + } +} Index: Ringtoets/Integration/src/Ringtoets.Integration.Service/Properties/Resources.resx =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Service/Properties/Resources.resx (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Service/Properties/Resources.resx (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Er is een fout opgetreden tijdens de toetspeil berekening '{0}': inspecteer het logbestand. + + + Toetspeil berekenen voor locatie '{0}' + + \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Service/Ringtoets.Integration.Service.csproj =================================================================== diff -u -rd01d386b22e750008cc95bd8a35983a13cdb18b1 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/Integration/src/Ringtoets.Integration.Service/Ringtoets.Integration.Service.csproj (.../Ringtoets.Integration.Service.csproj) (revision d01d386b22e750008cc95bd8a35983a13cdb18b1) +++ Ringtoets/Integration/src/Ringtoets.Integration.Service/Ringtoets.Integration.Service.csproj (.../Ringtoets.Integration.Service.csproj) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -32,28 +32,93 @@ MinimumRecommendedRules.ruleset + + ..\..\..\..\packages\log4net.2.0.4\lib\net40-full\log4net.dll + True + + + ..\..\..\..\packages\System.Data.SQLite.Core.1.0.99.0\lib\net40\System.Data.SQLite.dll + True + Properties\GlobalAssembly.cs + + + + True + True + Resources.resx + + + {3BBFD65B-B277-4E50-AE6D-BD24C3434609} + Core.Common.Base + False + {c90b77da-e421-43cc-b82e-529651bc21ac} Core.Common.Version False + + {D4200F43-3F72-4F42-AF0A-8CED416A38EC} + Ringtoets.Common.Data + False + + + {4d840673-3812-4338-a352-84854e32b8a0} + Ringtoets.Common.Forms + False + + + {d951d6da-fe83-4920-9fdb-63bf96480b54} + Ringtoets.Common.Service + False + + + {888D4097-8BC2-4703-9FB1-8744C94D525E} + Ringtoets.HydraRing.Calculation + False + + + {70F8CC9C-5BC8-4FB2-B201-EAE7FA8088C2} + Ringtoets.HydraRing.Data + False + + + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70} + Ringtoets.HydraRing.IO + False + Copying.licenseheader + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs =================================================================== diff -u -rf906ba10d1763e14a608bb2629b15893f37e9deb -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision f906ba10d1763e14a608bb2629b15893f37e9deb) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -174,7 +174,7 @@ // Assert var fileMissingMessage = string.Format("Fout bij het lezen van bestand '{0}': Het bestand bestaat niet.", notExistingFile); string message = string.Format( - RingtoetsCommonFormsResources.GuiPlugin_VerifyHydraulicBoundaryDatabasePath_Hydraulic_boundary_database_connection_failed_0_, + RingtoetsCommonFormsResources.Hydraulic_boundary_database_connection_failed_0_, fileMissingMessage); TestHelper.AssertLogMessageWithLevelIsGenerated(action, Tuple.Create(message, LogLevelConstant.Warn)); } Index: Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/DesignWaterLevelCalculationActivityTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/DesignWaterLevelCalculationActivityTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/DesignWaterLevelCalculationActivityTest.cs (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -0,0 +1,228 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.IO; +using System.Linq; +using Core.Common.Base; +using Core.Common.Base.Service; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HydraRing.Data; +using Ringtoets.Integration.Data; +using Ringtoets.Integration.Plugin.FileImporters; +using Ringtoets.Integration.Service.Properties; + +namespace Ringtoets.Integration.Service.Test +{ + [TestFixture] + public class DesignWaterLevelCalculationActivityTest + { + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); + + [Test] + public void ParameteredConstructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSectionMock = mocks.StrictMock(); + mocks.ReplayAll(); + + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 0, 0); + + // Call + var activity = new DesignWaterLevelCalculationActivity(assessmentSectionMock, hydraulicBoundaryLocation); + + // Assert + Assert.IsInstanceOf(activity); + Assert.AreEqual(string.Format(Resources.DesignWaterLevelCalculationService_Name_Calculate_assessment_level_for_location_0_, hydraulicBoundaryLocation.Id), activity.Name); + Assert.IsNull(activity.ProgressText); + Assert.AreEqual(ActivityState.None, activity.State); + + mocks.VerifyAll(); + } + + [Test] + public void Run_InvalidHydraulicBoundaryDatabase_PerformValidationAndLogStartAndEndAndError() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = Path.Combine(testDataPath, "notexisting.sqlite") + } + }; + + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 0, 0); + var activity = new DesignWaterLevelCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + + // 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: ", hydraulicBoundaryLocation.Id), msgs[0]); + StringAssert.StartsWith("Herstellen van de verbinding met de hydraulische randvoorwaarden database is mislukt. Fout bij het lezen van bestand", msgs[1]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", hydraulicBoundaryLocation.Id), msgs[2]); + }); + Assert.AreEqual(ActivityState.Failed, activity.State); + } + + [Test] + public void Run_ValidHydraulicBoundaryDatabaseAndHydraulicBoundaryLocation_PerformValidationAndCalculationAndLogStartAndEnd() + { + // 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 hydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(loc => loc.Id == 1300001); + + var activity = new DesignWaterLevelCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + + // Call + Action call = () => activity.Run(); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(4, msgs.Length); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", hydraulicBoundaryLocation.Id), msgs[0]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", hydraulicBoundaryLocation.Id), msgs[1]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", hydraulicBoundaryLocation.Id), msgs[2]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", hydraulicBoundaryLocation.Id), msgs[3]); + }); + Assert.AreEqual(ActivityState.Executed, activity.State); + } + + [Test] + public void Run_ValidHydraulicBoundaryDatabaseInvalidHydraulicBoundaryLocation_PerformValidationAndCalculationAndLogStartAndEndAndError() + { + // 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 hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 1, 1); + + var activity = new DesignWaterLevelCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + + // Call + Action call = () => activity.Run(); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(5, msgs.Length); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", hydraulicBoundaryLocation.Id), msgs[0]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", hydraulicBoundaryLocation.Id), msgs[1]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", hydraulicBoundaryLocation.Id), msgs[2]); + StringAssert.StartsWith(string.Format("Er is een fout opgetreden tijdens de toetspeil berekening '{0}': inspecteer het logbestand.", hydraulicBoundaryLocation.Id), msgs[3]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", hydraulicBoundaryLocation.Id), msgs[4]); + }); + Assert.AreEqual(ActivityState.Failed, activity.State); + Assert.IsNaN(hydraulicBoundaryLocation.DesignWaterLevel); + } + + [Test] + public void Finish_ValidCalculationAndRun_SetsDesignWaterLevelAndNotifyObservers() + { + // Setup + var mocks = new MockRepository(); + var observerMock = mocks.StrictMock(); + observerMock.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + 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 hydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(loc => loc.Id == 1300001); + hydraulicBoundaryLocation.Attach(observerMock); + + var activity = new DesignWaterLevelCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + + activity.Run(); + + // Call + activity.Finish(); + + // Assert + Assert.IsFalse(double.IsNaN(hydraulicBoundaryLocation.DesignWaterLevel)); + mocks.VerifyAll(); + } + + [Test] + public void Finish_InvalidCalculationAndRun_DoesNotSetDesignWaterlevelAndDoesNotNotifyObservers() + { + // Setup + var mocks = new MockRepository(); + var observerMock = mocks.StrictMock(); + mocks.ReplayAll(); + + 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 hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 1, 1); + hydraulicBoundaryLocation.Attach(observerMock); + + var activity = new DesignWaterLevelCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + + activity.Run(); + + // Call + activity.Finish(); + + // Assert + Assert.IsNaN(hydraulicBoundaryLocation.DesignWaterLevel); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/DesignWaterLevelCalculationServiceTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/DesignWaterLevelCalculationServiceTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/DesignWaterLevelCalculationServiceTest.cs (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -0,0 +1,160 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.IO; +using System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HydraRing.Calculation.Data.Output; +using Ringtoets.HydraRing.Data; +using Ringtoets.Integration.Data; +using Ringtoets.Integration.Plugin.FileImporters; + +namespace Ringtoets.Integration.Service.Test +{ + [TestFixture] + public class DesignWaterLevelCalculationServiceTest + { + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); + + [Test] + public void Validate_ValidHydraulicBoundaryDatabase_ReturnsTrue() + { + // 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); + } + + bool valid = false; + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 1, 1); + + // Call + Action call = () => valid = DesignWaterLevelCalculationService.Validate(assessmentSection.HydraulicBoundaryDatabase, hydraulicBoundaryLocation); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(2, msgs.Length); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", hydraulicBoundaryLocation.Id), msgs[0]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", hydraulicBoundaryLocation.Id), msgs[1]); + }); + Assert.IsTrue(valid); + } + + [Test] + public void Validate_InvalidHydraulicBoundaryDatabase_LogsErrorAndReturnsFalse() + { + // Setup + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = Path.Combine(testDataPath, "notexisting.sqlite") + }; + + bool valid = false; + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 1, 1); + + // Call + Action call = () => valid = DesignWaterLevelCalculationService.Validate(hydraulicBoundaryDatabase, hydraulicBoundaryLocation); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(3, msgs.Length); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", hydraulicBoundaryLocation.Id), msgs[0]); + StringAssert.StartsWith("Herstellen van de verbinding met de hydraulische randvoorwaarden database is mislukt. Fout bij het lezen van bestand", msgs[1]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", hydraulicBoundaryLocation.Id), msgs[2]); + }); + Assert.IsFalse(valid); + } + + [Test] + public void Calculate_ValidHydraulicBoundaryDatabaseAndLocation_LogStartAndEndAndReturnOutput() + { + // 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 hydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001); + + TargetProbabilityCalculationOutput output = null; + + // Call + Action call = () => output = DesignWaterLevelCalculationService.Calculate(assessmentSection, assessmentSection.HydraulicBoundaryDatabase, hydraulicBoundaryLocation, assessmentSection.Name); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(2, msgs.Length); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", hydraulicBoundaryLocation.Id), msgs[0]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", hydraulicBoundaryLocation.Id), msgs[1]); + }); + Assert.IsNotNull(output); + } + + [Test] + public void Calculate_ValidHydraulicBoundaryDatabaseInvalidHydraulicBoundaryLocation_LogStartAndEndAndErrorMessageAndReturnNull() + { + // 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 hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 1, 1); + + TargetProbabilityCalculationOutput output = null; + + // Call + Action call = () => output = DesignWaterLevelCalculationService.Calculate(assessmentSection, assessmentSection.HydraulicBoundaryDatabase, hydraulicBoundaryLocation, assessmentSection.Name); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(3, msgs.Length); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", hydraulicBoundaryLocation.Id), msgs[0]); + StringAssert.StartsWith(string.Format("Er is een fout opgetreden tijdens de toetspeil berekening '{0}': inspecteer het logbestand.", hydraulicBoundaryLocation.Id), msgs[1]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", hydraulicBoundaryLocation.Id), msgs[2]); + }); + Assert.IsNull(output); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/Ringtoets.Integration.Service.Test.csproj =================================================================== diff -u -rd01d386b22e750008cc95bd8a35983a13cdb18b1 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/Ringtoets.Integration.Service.Test.csproj (.../Ringtoets.Integration.Service.Test.csproj) (revision d01d386b22e750008cc95bd8a35983a13cdb18b1) +++ Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/Ringtoets.Integration.Service.Test.csproj (.../Ringtoets.Integration.Service.Test.csproj) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -44,10 +44,16 @@ ..\..\..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll True + + ..\..\..\..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll + True + + + @@ -56,6 +62,40 @@ + + + {3bbfd65b-b277-4e50-ae6d-bd24c3434609} + Core.Common.Base + + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + + + {D4200F43-3F72-4F42-AF0A-8CED416A38EC} + Ringtoets.Common.Data + + + {888D4097-8BC2-4703-9FB1-8744C94D525E} + Ringtoets.HydraRing.Calculation + + + {70F8CC9C-5BC8-4FB2-B201-EAE7FA8088C2} + Ringtoets.HydraRing.Data + + + {11F1F874-45AF-43E4-8AE5-15A5C9593E28} + Ringtoets.Integration.Data + + + {C8383B76-B3F1-4E6E-B56C-527B469FA20A} + Ringtoets.Integration.Plugin + + + {28811C4A-6C18-42C1-88B2-A03A3784E2D0} + Ringtoets.Integration.Service + + + \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/test-data/HydraRingCalculation/HLCD.sqlite =================================================================== diff -u Binary files differ Index: Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/test-data/HydraRingCalculation/HRD dutch coast south.sqlite =================================================================== diff -u Binary files differ Index: Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/Ringtoets.Piping.Integration.Test.csproj =================================================================== diff -u -r1f622b4c6f58e22a752097c0375fe68f370a3fb2 -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 --- Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/Ringtoets.Piping.Integration.Test.csproj (.../Ringtoets.Piping.Integration.Test.csproj) (revision 1f622b4c6f58e22a752097c0375fe68f370a3fb2) +++ Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/Ringtoets.Piping.Integration.Test.csproj (.../Ringtoets.Piping.Integration.Test.csproj) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) @@ -55,10 +55,6 @@ - - ..\..\..\..\packages\System.Data.SQLite.Core.1.0.99.0\lib\net40\System.Data.SQLite.dll - True - ..\..\..\..\lib\Plugins\Wti\WTIPiping.dll @@ -173,13 +169,6 @@ - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - -