Index: Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.Designer.cs =================================================================== diff -u -r915001caffacbbee15c0e3bf449072245bc5f509 -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 915001caffacbbee15c0e3bf449072245bc5f509) +++ Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -22,7 +22,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. Index: Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationService.cs =================================================================== diff -u -r669abaf20f73e5b35a7ce4c0e78690097da77ef7 -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationService.cs (.../PipingCalculationService.cs) (revision 669abaf20f73e5b35a7ce4c0e78690097da77ef7) +++ Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationService.cs (.../PipingCalculationService.cs) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -51,13 +51,13 @@ var inputValidationResults = ValidateInput(calculation.InputParameters); if (inputValidationResults.Count > 0) { - CalculationServiceHelper.LogMessagesAsError(Resources.Error_in_piping_validation_0, inputValidationResults.ToArray()); + CalculationServiceHelper.LogMessagesAsError(RingtoetsCommonServiceResources.Error_in_validation_0, inputValidationResults.ToArray()); CalculationServiceHelper.LogValidationEndTime(calculation.Name); return false; } var validationResults = new PipingCalculator(CreateInputFromData(calculation.InputParameters), PipingSubCalculatorFactory.Instance).Validate(); - CalculationServiceHelper.LogMessagesAsError(Resources.Error_in_piping_validation_0, validationResults.ToArray()); + CalculationServiceHelper.LogMessagesAsError(RingtoetsCommonServiceResources.Error_in_validation_0, validationResults.ToArray()); CalculationServiceHelper.LogValidationEndTime(calculation.Name); Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Service/IWaveConditionsCalculationService.cs =================================================================== diff -u -r6c3a074511922fb175a1aa7f20168bbb6d63a688 -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Service/IWaveConditionsCalculationService.cs (.../IWaveConditionsCalculationService.cs) (revision 6c3a074511922fb175a1aa7f20168bbb6d63a688) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Service/IWaveConditionsCalculationService.cs (.../IWaveConditionsCalculationService.cs) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -20,6 +20,7 @@ // All rights reserved. using Core.Common.Base.Data; +using Ringtoets.HydraRing.Data; using Ringtoets.Revetment.Data; namespace Ringtoets.Revetment.Service @@ -33,10 +34,13 @@ /// Performs validation of the values of the given calculation. /// Error and status information is logged during the execution of the operation. /// + /// The that holds the information required to perform a calculation. + /// The to determine the if a hydraulic boundary + /// database was loaded, and the validity of the database connection /// The name of the calculation to validate. /// False if given parameters result in validation errors; /// True otherwise. - bool Validate(string name); + bool Validate(WaveConditionsInput input, HydraulicBoundaryDatabase hydraulicBoundaryDatabase, string name); /// /// Performs a wave conditions cosine calculation based on the supplied Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Service/Properties/Resources.Designer.cs =================================================================== diff -u -rae04c23f970bb96e54adbfb8c2fe1aaf95d13326 -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ae04c23f970bb96e54adbfb8c2fe1aaf95d13326) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -22,7 +22,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.17929 +// Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -82,6 +82,34 @@ } /// + /// Looks up a localized string similar to Kan geen waterstanden afleiden op basis van de invoer. Controleer de opgegeven boven- en ondergrenzen.. + /// + internal static string WaveConditionsCalculationService_ValidateInput_No_derived_waterlevels { + get { + return ResourceManager.GetString("WaveConditionsCalculationService_ValidateInput_No_derived_waterlevels", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Kan het toetspeil niet afleiden op basis van de invoer.. + /// + internal static string WaveConditionsCalculationService_ValidateInput_No_designwaterlevel_selected { + get { + return ResourceManager.GetString("WaveConditionsCalculationService_ValidateInput_No_designwaterlevel_selected", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Er is geen hydraulische randvoorwaardenlocatie geselecteerd.. + /// + internal static string WaveConditionsCalculationService_ValidateInput_No_hydraulic_boundary_location_selected { + get { + return ResourceManager.GetString("WaveConditionsCalculationService_ValidateInput_No_hydraulic_boundary_location_sel" + + "ected", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Berekening '{0}' voor waterstand '{1}' is niet gelukt.. /// internal static string WaveConditionsCalculationService_VerifyWaveConditionsCalculationOutput_Error_in_wave_conditions_calculation_0_for_waterlevel_1 { Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Service/Properties/Resources.resx =================================================================== diff -u -r5b3041efe0fd2d334984d6c730815242b30229aa -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Service/Properties/Resources.resx (.../Resources.resx) (revision 5b3041efe0fd2d334984d6c730815242b30229aa) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Service/Properties/Resources.resx (.../Resources.resx) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -120,4 +120,13 @@ Berekening '{0}' voor waterstand '{1}' is niet gelukt. + + Er is geen hydraulische randvoorwaardenlocatie geselecteerd. + + + Kan het toetspeil niet afleiden op basis van de invoer. + + + Kan geen waterstanden afleiden op basis van de invoer. Controleer de opgegeven boven- en ondergrenzen. + \ No newline at end of file Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Service/Ringtoets.Revetment.Service.csproj =================================================================== diff -u -r6c3a074511922fb175a1aa7f20168bbb6d63a688 -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Service/Ringtoets.Revetment.Service.csproj (.../Ringtoets.Revetment.Service.csproj) (revision 6c3a074511922fb175a1aa7f20168bbb6d63a688) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Service/Ringtoets.Revetment.Service.csproj (.../Ringtoets.Revetment.Service.csproj) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -69,6 +69,11 @@ Ringtoets.Common.Data False + + {4d840673-3812-4338-a352-84854e32b8a0} + Ringtoets.Common.Forms + False + {D951D6DA-FE83-4920-9FDB-63BF96480B54} Ringtoets.Common.Service @@ -84,6 +89,11 @@ Ringtoets.HydraRing.Data False + + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70} + Ringtoets.HydraRing.IO + False + {87C2C553-C0BC-40BF-B1EA-B83BFF357F27} Ringtoets.Revetment.Data Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Service/WaveConditionsCalculationService.cs =================================================================== diff -u -rdd84b844a388b0dc3f721bd40674c4ed513b3231 -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Service/WaveConditionsCalculationService.cs (.../WaveConditionsCalculationService.cs) (revision dd84b844a388b0dc3f721bd40674c4ed513b3231) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Service/WaveConditionsCalculationService.cs (.../WaveConditionsCalculationService.cs) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -30,9 +30,14 @@ using Ringtoets.HydraRing.Calculation.Data.Output; using Ringtoets.HydraRing.Calculation.Parsers; using Ringtoets.HydraRing.Calculation.Services; +using Ringtoets.HydraRing.Data; +using Ringtoets.HydraRing.IO; using Ringtoets.Revetment.Data; using Ringtoets.Revetment.Service.Properties; +using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + namespace Ringtoets.Revetment.Service { /// @@ -60,11 +65,28 @@ } } - public bool Validate(string name) + public bool Validate(WaveConditionsInput input, HydraulicBoundaryDatabase hydraulicBoundaryDatabase, string name) { - // TODO: Implement validation with WTI-826 - return CalculationServiceHelper.PerformValidation(name, - () => new string[0]); + CalculationServiceHelper.LogValidationBeginTime(name); + + string databaseValidationErrorMessage = ValidateHydraulicBoundaryDatabase(hydraulicBoundaryDatabase); + if (!string.IsNullOrEmpty(databaseValidationErrorMessage)) + { + CalculationServiceHelper.LogMessagesAsError(RingtoetsCommonServiceResources.Error_in_validation_0, databaseValidationErrorMessage); + CalculationServiceHelper.LogValidationEndTime(name); + return false; + } + + string validationErrorMessage = ValidateWaveConditionsInput(input); + if (!string.IsNullOrEmpty(validationErrorMessage)) + { + CalculationServiceHelper.LogMessagesAsError(RingtoetsCommonServiceResources.Error_in_validation_0, validationErrorMessage); + CalculationServiceHelper.LogValidationEndTime(name); + return false; + } + + CalculationServiceHelper.LogValidationEndTime(name); + return true; } public WaveConditionsOutput Calculate(RoundedDouble waterLevel, @@ -135,5 +157,43 @@ { return input.UseForeshore ? input.ForeshoreGeometry.Select(c => new HydraRingForelandPoint(c.X, c.Y)) : new HydraRingForelandPoint[0]; } + + + private static string ValidateHydraulicBoundaryDatabase(HydraulicBoundaryDatabase hydraulicBoundaryDatabase) + { + if (hydraulicBoundaryDatabase == null) + { + return RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_hydraulic_boundary_database_imported; + } + + string validationProblem = HydraulicDatabaseHelper.ValidatePathForCalculation(hydraulicBoundaryDatabase.FilePath); + if (!string.IsNullOrEmpty(validationProblem)) + { + return string.Format(RingtoetsCommonServiceResources.Hydraulic_boundary_database_connection_failed_0_, + validationProblem); + } + + return null; + } + + private static string ValidateWaveConditionsInput(WaveConditionsInput input) + { + if (input.HydraulicBoundaryLocation == null) + { + return Resources.WaveConditionsCalculationService_ValidateInput_No_hydraulic_boundary_location_selected; + } + + if (double.IsNaN(input.HydraulicBoundaryLocation.DesignWaterLevel)) + { + return Resources.WaveConditionsCalculationService_ValidateInput_No_designwaterlevel_selected; + } + + if (!input.WaterLevels.Any()) + { + return Resources.WaveConditionsCalculationService_ValidateInput_No_derived_waterlevels; + } + + return null; + } } } \ No newline at end of file Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Service.Test/WaveConditionsCalculationServiceTest.cs =================================================================== diff -u -rdd84b844a388b0dc3f721bd40674c4ed513b3231 -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Service.Test/WaveConditionsCalculationServiceTest.cs (.../WaveConditionsCalculationServiceTest.cs) (revision dd84b844a388b0dc3f721bd40674c4ed513b3231) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Service.Test/WaveConditionsCalculationServiceTest.cs (.../WaveConditionsCalculationServiceTest.cs) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.IO; using System.Linq; using Core.Common.Base.Data; using Core.Common.Base.Geometry; @@ -40,7 +41,206 @@ [TestFixture] public class WaveConditionsCalculationServiceTest { + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); + [Test] + public void Validate_NoHydraulicBoundaryDatabase_ReturnsFalseAndLogsValidationError() + { + // Setup + string name = "test"; + bool isValid = false; + + // Call + Action action = () => isValid = WaveConditionsCalculationService.Instance.Validate(null, null, name); + + // Assert + TestHelper.AssertLogMessages(action, 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 randvoorwaardendatabase geïmporteerd.", msgs[1]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", name), msgs[2]); + }); + + Assert.IsFalse(isValid); + } + + [Test] + public void Validate_InvalidHydraulicBoundaryDatabaseFileLocation_ReturnsFalseAndLogsError() + { + // Setup + string name = "test"; + bool isValid = false; + + HydraulicBoundaryDatabase database = new HydraulicBoundaryDatabase() + { + FilePath = Path.Combine(testDataPath, "NonExisting.sqlite") + }; + + // Call + Action action = () => isValid = WaveConditionsCalculationService.Instance.Validate(null, database, name); + + // Assert + TestHelper.AssertLogMessages(action, 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: Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt", msgs[1]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", name), msgs[2]); + }); + + Assert.IsFalse(isValid); + } + + [Test] + public void Validate_NoHydraulicBoundaryLocation_ReturnsFalseAndLogsValidationError() + { + // Setup + string name = "test"; + bool isValid = false; + + HydraulicBoundaryDatabase database = new HydraulicBoundaryDatabase() + { + FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") + }; + + var input = new WaveConditionsInput(); + + // Call + Action action = () => isValid = WaveConditionsCalculationService.Instance.Validate(input, database, name); + + // Assert + TestHelper.AssertLogMessages(action, 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 randvoorwaardenlocatie geselecteerd.", msgs[1]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", name), msgs[2]); + }); + + Assert.IsFalse(isValid); + } + + [Test] + public void Validate_NoHydraulicBoundaryLocationDesignWaterLevel_ReturnsFalseAndLogsValidationError() + { + // Setup + string name = "test"; + bool isValid = false; + + HydraulicBoundaryDatabase database = new HydraulicBoundaryDatabase() + { + FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") + }; + + var input = new WaveConditionsInput() + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) + }; + + // Call + Action action = () => isValid = WaveConditionsCalculationService.Instance.Validate(input, database, name); + + // Assert + TestHelper.AssertLogMessages(action, 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: Kan het toetspeil niet afleiden op basis van de invoer.", msgs[1]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", name), msgs[2]); + }); + + Assert.IsFalse(isValid); + } + + [Test] + [TestCase(double.NaN, 10.0, 12.0)] + [TestCase(1.0, double.NaN, 12.0)] + public void Validate_NoWaterLevels_ReturnsFalseAndLogsValidationError(double lowerBoundaryRevetments, double upperBoundaryRevetments, double designWaterLevel) + { + // Setup + string name = "test"; + bool isValid = false; + + HydraulicBoundaryDatabase database = new HydraulicBoundaryDatabase() + { + FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") + }; + + var input = new WaveConditionsInput + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) + { + DesignWaterLevel = (RoundedDouble)designWaterLevel + }, + LowerBoundaryRevetment = (RoundedDouble)lowerBoundaryRevetments, + UpperBoundaryRevetment = (RoundedDouble)upperBoundaryRevetments, + StepSize = WaveConditionsInputStepSize.One, + LowerBoundaryWaterLevels = (RoundedDouble)1.0, + UpperBoundaryWaterLevels = (RoundedDouble)10.0 + }; + + // Call + Action action = () => isValid = WaveConditionsCalculationService.Instance.Validate(input, database, name); + + // Assert + TestHelper.AssertLogMessages(action, 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: Kan geen waterstanden afleiden op basis van de invoer. Controleer de opgegeven boven- en ondergrenzen.", msgs[1]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", name), msgs[2]); + }); + + Assert.IsFalse(isValid); + } + + [Test] + public void Validate_AllInputConditionsSatisfied_ReturnsTrueAndLogsValidationMessages() + { + // Setup + string name = "test"; + bool isValid = false; + + HydraulicBoundaryDatabase database = new HydraulicBoundaryDatabase() + { + FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") + }; + + var input = new WaveConditionsInput + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) + { + DesignWaterLevel = (RoundedDouble)12.0 + }, + LowerBoundaryRevetment = (RoundedDouble)1.0, + UpperBoundaryRevetment = (RoundedDouble)10.0, + StepSize = WaveConditionsInputStepSize.One, + LowerBoundaryWaterLevels = (RoundedDouble)1.0, + UpperBoundaryWaterLevels = (RoundedDouble)10.0 + }; + + // Call + Action action = () => isValid = WaveConditionsCalculationService.Instance.Validate(input, database, name); + + // Assert + TestHelper.AssertLogMessages(action, 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] [Combinatorial] public void Calculate_Always_StartsCalculationWithRightParameters( [Values(true, false)] bool useForeshore, Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Service.TestUtil.Test/Ringtoets.Revetment.Service.TestUtil.Test.csproj =================================================================== diff -u -rdd84b844a388b0dc3f721bd40674c4ed513b3231 -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Service.TestUtil.Test/Ringtoets.Revetment.Service.TestUtil.Test.csproj (.../Ringtoets.Revetment.Service.TestUtil.Test.csproj) (revision dd84b844a388b0dc3f721bd40674c4ed513b3231) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Service.TestUtil.Test/Ringtoets.Revetment.Service.TestUtil.Test.csproj (.../Ringtoets.Revetment.Service.TestUtil.Test.csproj) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -75,6 +75,10 @@ {4843D6E5-066F-4795-94F5-1D53932DD03C} Ringtoets.Common.Data.TestUtil + + {70f8cc9c-5bc8-4fb2-b201-eae7fa8088c2} + Ringtoets.HydraRing.Data + {87C2C553-C0BC-40BF-B1EA-B83BFF357F27} Ringtoets.Revetment.Data Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Service.TestUtil.Test/TestWaveConditionsCalculationServiceTest.cs =================================================================== diff -u -r7ac7d2230eac8ce6eb3233596157002c9cb7bc19 -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Service.TestUtil.Test/TestWaveConditionsCalculationServiceTest.cs (.../TestWaveConditionsCalculationServiceTest.cs) (revision 7ac7d2230eac8ce6eb3233596157002c9cb7bc19) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Service.TestUtil.Test/TestWaveConditionsCalculationServiceTest.cs (.../TestWaveConditionsCalculationServiceTest.cs) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -47,7 +47,7 @@ var testService = new TestWaveConditionsCalculationService(); // Call - var valid = testService.Validate(string.Empty); + var valid = testService.Validate(null, null, string.Empty); // Assert Assert.IsTrue(valid); Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Service.TestUtil/Ringtoets.Revetment.Service.TestUtil.csproj =================================================================== diff -u -rd58a7ff7f54c83dfe5d1ef28417c43a83346b5ba -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Service.TestUtil/Ringtoets.Revetment.Service.TestUtil.csproj (.../Ringtoets.Revetment.Service.TestUtil.csproj) (revision d58a7ff7f54c83dfe5d1ef28417c43a83346b5ba) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Service.TestUtil/Ringtoets.Revetment.Service.TestUtil.csproj (.../Ringtoets.Revetment.Service.TestUtil.csproj) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -66,6 +66,10 @@ {d4200f43-3f72-4f42-af0a-8ced416a38ec} Ringtoets.Common.Data + + {70F8CC9C-5BC8-4FB2-B201-EAE7FA8088C2} + Ringtoets.HydraRing.Data + {87C2C553-C0BC-40BF-B1EA-B83BFF357F27} Ringtoets.Revetment.Data Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Service.TestUtil/TestWaveConditionsCalculationService.cs =================================================================== diff -u -rdd84b844a388b0dc3f721bd40674c4ed513b3231 -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Service.TestUtil/TestWaveConditionsCalculationService.cs (.../TestWaveConditionsCalculationService.cs) (revision dd84b844a388b0dc3f721bd40674c4ed513b3231) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Service.TestUtil/TestWaveConditionsCalculationService.cs (.../TestWaveConditionsCalculationService.cs) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -21,6 +21,7 @@ using System.Collections.Generic; using Core.Common.Base.Data; +using Ringtoets.HydraRing.Data; using Ringtoets.Revetment.Data; namespace Ringtoets.Revetment.Service.TestUtil @@ -52,7 +53,7 @@ } } - public bool Validate(string name) + public bool Validate(WaveConditionsInput input, HydraulicBoundaryDatabase hydraulicBoundaryDatabase, string name) { return true; } Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs =================================================================== diff -u -rce190360da30edf73fb464cc0fea1d9a795aa5d4 -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision ce190360da30edf73fb464cc0fea1d9a795aa5d4) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -425,7 +425,7 @@ { foreach (StabilityStoneCoverWaveConditionsCalculation calculation in calculations) { - WaveConditionsCalculationService.Instance.Validate(calculation.Name); + WaveConditionsCalculationService.Instance.Validate(calculation.InputParameters, database, calculation.Name); } } Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Service/StabilityStoneCoverWaveConditionsCalculationActivity.cs =================================================================== diff -u -r9bf880dc73a6626c77988dc2b5e3fa3763ce2329 -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Service/StabilityStoneCoverWaveConditionsCalculationActivity.cs (.../StabilityStoneCoverWaveConditionsCalculationActivity.cs) (revision 9bf880dc73a6626c77988dc2b5e3fa3763ce2329) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Service/StabilityStoneCoverWaveConditionsCalculationActivity.cs (.../StabilityStoneCoverWaveConditionsCalculationActivity.cs) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -83,7 +83,7 @@ protected override void OnRun() { - PerformRun(() => WaveConditionsCalculationService.Instance.Validate(calculation.Name), + PerformRun(() => WaveConditionsCalculationService.Instance.Validate(calculation.InputParameters, assessmentSection.HydraulicBoundaryDatabase, calculation.Name), () => StabilityStoneCoverDataSynchronizationService.ClearWaveConditionsCalculationOutput(calculation), () => { Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rae04c23f970bb96e54adbfb8c2fe1aaf95d13326 -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision ae04c23f970bb96e54adbfb8c2fe1aaf95d13326) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -643,8 +643,21 @@ var calculation = new StabilityStoneCoverWaveConditionsCalculation { - Name = "A" + Name = "A", + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "", 1, 1) + { + DesignWaterLevel = (RoundedDouble) 12.0 + }, + LowerBoundaryRevetment = (RoundedDouble) 1.0, + UpperBoundaryRevetment = (RoundedDouble) 10.0, + StepSize = WaveConditionsInputStepSize.One, + LowerBoundaryWaterLevels = (RoundedDouble) 1.0, + UpperBoundaryWaterLevels = (RoundedDouble) 10.0 + } }; + var context = new StabilityStoneCoverWaveConditionsCalculationContext(calculation, failureMechanism, assessmentSection); @@ -695,6 +708,83 @@ } [Test] + public void GivenInValidCalculation_WhenValidating_ThenCalculationFailsValidation() + { + // Given + string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, + Path.Combine("HydraulicBoundaryLocationReader", "complete.sqlite")); + + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("A", new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + })); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validHydroDatabasePath + }; + assessmentSection.Stub(a => a.Id).Return("someId"); + assessmentSection.Stub(a => a.FailureMechanismContribution).Return( + new FailureMechanismContribution(Enumerable.Empty(), 100, 20)); + + var calculation = new StabilityStoneCoverWaveConditionsCalculation + { + Name = "A" + }; + + var context = new StabilityStoneCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var appFeatureCommandHandler = mocks.Stub(); + var importHandler = mocks.Stub(); + var exportHandler = mocks.Stub(); + var viewCommands = mocks.Stub(); + var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + importHandler, + exportHandler, + viewCommands, + context, + treeViewControl); + + var gui = mocks.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Precondition + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + validateMenuItemIndex, + "&Valideren", + "Valideer de invoer voor deze berekening.", + RingtoetsCommonFormsResources.ValidateIcon); + + // When + ToolStripItem validateMenuItem = contextMenu.Items[validateMenuItemIndex]; + Action call = () => validateMenuItem.PerformClick(); + + // Then + TestHelper.AssertLogMessages(call, logMessages => + { + var messages = logMessages.ToArray(); + Assert.AreEqual(3, messages.Length); + StringAssert.StartsWith("Validatie van 'A' gestart om: ", messages[0]); + StringAssert.StartsWith("Validatie mislukt: Er is geen hydraulische randvoorwaardenlocatie geselecteerd.", messages[1]); + StringAssert.StartsWith("Validatie van 'A' beëindigd om: ", messages[2]); + }); + } + } + } + + [Test] public void GivenAnyCalculation_ThenCalculateItemEnabled() { // Given @@ -1003,13 +1093,13 @@ UseForeshore = true, UseBreakWater = true, StepSize = WaveConditionsInputStepSize.Half, - LowerBoundaryRevetment = (RoundedDouble)4, - UpperBoundaryRevetment = (RoundedDouble)10, - UpperBoundaryWaterLevels = (RoundedDouble)8, - LowerBoundaryWaterLevels = (RoundedDouble)7.1 + LowerBoundaryRevetment = (RoundedDouble) 4, + UpperBoundaryRevetment = (RoundedDouble) 10, + UpperBoundaryWaterLevels = (RoundedDouble) 8, + LowerBoundaryWaterLevels = (RoundedDouble) 7.1 } }; - calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble)9.3; + calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble) 9.3; return calculation; } Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r2f6fac0619d2cc96b21babebed750f1ff68a2215 -r3a89e41054c6cfe6babdc150e8282cbe4a6dc672 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 2f6fac0619d2cc96b21babebed750f1ff68a2215) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 3a89e41054c6cfe6babdc150e8282cbe4a6dc672) @@ -714,9 +714,25 @@ assessmentSection.Stub(a => a.FailureMechanismContribution).Return( new FailureMechanismContribution(Enumerable.Empty(), 30, 2)); + var calculation = new StabilityStoneCoverWaveConditionsCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "", 1, 1) + { + DesignWaterLevel = (RoundedDouble)12.0 + }, + LowerBoundaryRevetment = (RoundedDouble)1.0, + UpperBoundaryRevetment = (RoundedDouble)10.0, + StepSize = WaveConditionsInputStepSize.One, + LowerBoundaryWaterLevels = (RoundedDouble)1.0, + UpperBoundaryWaterLevels = (RoundedDouble)10.0 + } + }; + var group = new CalculationGroup(); - group.Children.Add(new StabilityStoneCoverWaveConditionsCalculation()); - group.Children.Add(new StabilityStoneCoverWaveConditionsCalculation()); + group.Children.Add(calculation); + group.Children.Add(calculation); var failureMechanism = new StabilityStoneCoverFailureMechanism(); failureMechanism.AddSection(new FailureMechanismSection("", new[] @@ -1335,7 +1351,7 @@ Assert.NotNull(dialog); Assert.NotNull(grid); } - } + } [Test] public void GivenDialogGenerateCalculationButtonClicked_WhenCancelButtonClickedAndDialogClosed_ThenCalculationGroupNotUpdated() @@ -1542,13 +1558,13 @@ UseForeshore = true, UseBreakWater = true, StepSize = WaveConditionsInputStepSize.Half, - LowerBoundaryRevetment = (RoundedDouble)4, - UpperBoundaryRevetment = (RoundedDouble)10, - UpperBoundaryWaterLevels = (RoundedDouble)8, - LowerBoundaryWaterLevels = (RoundedDouble)7.1 + LowerBoundaryRevetment = (RoundedDouble) 4, + UpperBoundaryRevetment = (RoundedDouble) 10, + UpperBoundaryWaterLevels = (RoundedDouble) 8, + LowerBoundaryWaterLevels = (RoundedDouble) 7.1 } }; - calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble)9.3; + calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble) 9.3; return calculation; }