Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/ClosingStructuresCalculationService.cs =================================================================== diff -u -r36b96f02b3c5983419db8ca336a5ff00d9e7fdda -r440f228de8eb72ed5be40270b20a46113917333e --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/ClosingStructuresCalculationService.cs (.../ClosingStructuresCalculationService.cs) (revision 36b96f02b3c5983419db8ca336a5ff00d9e7fdda) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/ClosingStructuresCalculationService.cs (.../ClosingStructuresCalculationService.cs) (revision 440f228de8eb72ed5be40270b20a46113917333e) @@ -23,6 +23,7 @@ using System.ComponentModel; using System.IO; using System.Linq; +using Core.Common.Base.Data; using log4net; using Ringtoets.ClosingStructures.Data; using Ringtoets.ClosingStructures.Service.Properties; @@ -38,6 +39,8 @@ using Ringtoets.HydraRing.Calculation.Parsers; using Ringtoets.HydraRing.IO; using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; +using ClosingStructuresFormsResources = Ringtoets.ClosingStructures.Forms.Properties.Resources; namespace Ringtoets.ClosingStructures.Service { @@ -245,21 +248,87 @@ private static string[] ValidateInput(ClosingStructuresInput inputParameters, IAssessmentSection assessmentSection) { - var validationResult = new List(); + var validationResults = new List(); var validationProblem = HydraulicDatabaseHelper.ValidatePathForCalculation(assessmentSection.HydraulicBoundaryDatabase.FilePath); if (!string.IsNullOrEmpty(validationProblem)) { - validationResult.Add(validationProblem); - return validationResult.ToArray(); + validationResults.Add(validationProblem); + return validationResults.ToArray(); } if (inputParameters.HydraulicBoundaryLocation == null) { - validationResult.Add(RingtoetsCommonServiceResources.CalculationService_ValidateInput_No_hydraulic_boundary_location_selected); + validationResults.Add(RingtoetsCommonServiceResources.CalculationService_ValidateInput_No_hydraulic_boundary_location_selected); } //TODO: Validate all the input parameters here, see WTI-926 - return validationResult.ToArray(); + + if (inputParameters.Structure == null) + { + validationResults.Add("Er is geen kunstwerk sluiten geselecteerd."); + } + else + { + switch (inputParameters.InflowModelType) + { + case ClosingStructureInflowModelType.VerticalWall: + validationResults.AddRange(ValidateVerticalWallCalculationInput(inputParameters)); + break; + default: + throw new InvalidEnumArgumentException("inputParameters", + (int) inputParameters.InflowModelType, + typeof(ClosingStructureInflowModelType)); + } + } + + return validationResults.ToArray(); } + + private static IEnumerable ValidateVerticalWallCalculationInput(ClosingStructuresInput input) + { + var validationResults = new List(); + + validationResults.AddRange(DistributionValidation.ValidateDistribution(input.StormDuration, + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StormDuration_DisplayName))); + if (IsInvalidNumber(input.DeviationWaveDirection)) + { + validationResults.Add(string.Format(RingtoetsCommonServiceResources.Validation_ValidateInput_No_value_entered_for_ParameterName_0_, + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_DeviationWaveDirection_DisplayName))); + } + + validationResults.AddRange(DistributionValidation.ValidateDistribution(input.ModelFactorSuperCriticalFlow, + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_ModelFactorSuperCriticalFlow_DisplayName))); + + if (IsInvalidNumber(input.FactorStormDurationOpenStructure)) + { + validationResults.Add(string.Format(RingtoetsCommonServiceResources.Validation_ValidateInput_No_value_entered_for_ParameterName_0_, + ParameterNameExtractor.GetFromDisplayName(ClosingStructuresFormsResources.FactorStormDurationOpenStructure_DisplayName))); + } + + validationResults.AddRange(DistributionValidation.ValidateDistribution(input.WidthFlowApertures, + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_WidthFlowApertures_DisplayName))); + if (IsInvalidNumber(input.StructureNormalOrientation)) + { + validationResults.Add(string.Format(RingtoetsCommonServiceResources.Validation_ValidateInput_No_value_entered_for_ParameterName_0_, + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StructureNormalOrientation_DisplayName))); + } + + validationResults.AddRange(DistributionValidation.ValidateDistribution(input.FlowWidthAtBottomProtection, + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_FlowWidthAtBottomProtection_DisplayName))); + validationResults.AddRange(DistributionValidation.ValidateDistribution(input.StorageStructureArea, + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StorageStructureArea_DisplayName))); + validationResults.AddRange(DistributionValidation.ValidateDistribution(input.AllowedLevelIncreaseStorage, + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_AllowedLevelIncreaseStorage_DisplayName))); + validationResults.AddRange(DistributionValidation.ValidateDistribution(input.LevelCrestStructureNotClosing, + ParameterNameExtractor.GetFromDisplayName(ClosingStructuresFormsResources.LevelCrestStructureNotClosing_DisplayName))); + validationResults.AddRange(DistributionValidation.ValidateDistribution(input.CriticalOvertoppingDischarge, + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_CriticalOvertoppingDischarge_DisplayName))); + return validationResults; + } + + private static bool IsInvalidNumber(RoundedDouble value) + { + return double.IsNaN(value) || double.IsInfinity(value); + } } } \ No newline at end of file Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/Ringtoets.ClosingStructures.Service.csproj =================================================================== diff -u -re4e785f127ce9a2d0d1734c1b51e02d910a31bbe -r440f228de8eb72ed5be40270b20a46113917333e --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/Ringtoets.ClosingStructures.Service.csproj (.../Ringtoets.ClosingStructures.Service.csproj) (revision e4e785f127ce9a2d0d1734c1b51e02d910a31bbe) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/Ringtoets.ClosingStructures.Service.csproj (.../Ringtoets.ClosingStructures.Service.csproj) (revision 440f228de8eb72ed5be40270b20a46113917333e) @@ -75,6 +75,11 @@ Ringtoets.Common.Data False + + {4d840673-3812-4338-a352-84854e32b8a0} + Ringtoets.Common.Forms + False + {D951D6DA-FE83-4920-9FDB-63BF96480B54} Ringtoets.Common.Service @@ -105,6 +110,11 @@ Ringtoets.ClosingStructures.Data False + + {22e191f2-b2e3-413c-9511-4c2cdedb2eff} + Ringtoets.ClosingStructures.Forms + False + Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Integration.Test/ClosingStructuresCalculationActivityIntegrationTest.cs =================================================================== diff -u -rc308077fce571dad955fafc21577c2a99dc5b221 -r440f228de8eb72ed5be40270b20a46113917333e --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Integration.Test/ClosingStructuresCalculationActivityIntegrationTest.cs (.../ClosingStructuresCalculationActivityIntegrationTest.cs) (revision c308077fce571dad955fafc21577c2a99dc5b221) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Integration.Test/ClosingStructuresCalculationActivityIntegrationTest.cs (.../ClosingStructuresCalculationActivityIntegrationTest.cs) (revision 440f228de8eb72ed5be40270b20a46113917333e) @@ -112,6 +112,7 @@ } }; calculation.InputParameters.DeviationWaveDirection = (RoundedDouble) 0; + calculation.InputParameters.FactorStormDurationOpenStructure = (RoundedDouble) 1.0; var activity = new ClosingStructuresCalculationActivity(calculation, "", failureMechanism, assessmentSection); Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Service.Test/ClosingStructuresCalculationServiceTest.cs =================================================================== diff -u -r36b96f02b3c5983419db8ca336a5ff00d9e7fdda -r440f228de8eb72ed5be40270b20a46113917333e --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Service.Test/ClosingStructuresCalculationServiceTest.cs (.../ClosingStructuresCalculationServiceTest.cs) (revision 36b96f02b3c5983419db8ca336a5ff00d9e7fdda) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Service.Test/ClosingStructuresCalculationServiceTest.cs (.../ClosingStructuresCalculationServiceTest.cs) (revision 440f228de8eb72ed5be40270b20a46113917333e) @@ -20,9 +20,11 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; +using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; @@ -50,6 +52,60 @@ private static readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); private static readonly string validDataFilepath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); + #region Parameter name mappings + private static readonly Dictionary parameterNames = new Dictionary() + { + { + "insideWaterLevel", "binnenwaterstand" + }, + { + "stormDuration", "stormduur" + }, + { + "deviationWaveDirection", "afwijking golfrichting" + }, + { + "factorStormDurationOpenStructure", "factor voor stormduur hoogwater" + }, + { + "modelFactorSuperCriticalFlow", "modelfactor overloopdebiet volkomen overlaat" + }, + { + "drainCoefficient", "afvoercoëfficient" + }, + { + "structureNormalOrientation", "oriëntatie" + }, + { + "identicalApertures", "aantal identieke doorstroomopeningen" + }, + { + "thresholdHeightOpenWeir", "drempelhoogte" + }, + { + "areaFlowApertures", "doorstroomoppervlak" + }, + { + "levelCrestStructureNotClosing", "kruinhoogte niet gesloten kering" + }, + { + "allowedLevelIncreaseStorage", "toegestane peilverhoging komberging" + }, + { + "storageStructureArea", "kombergend oppervlak" + }, + { + "flowWidthAtBottomProtection", "stroomvoerende breedte bodembescherming" + }, + { + "criticalOvertoppingDischarge", "kritiek instromend debiet" + }, + { + "widthFlowApertures", "breedte van doorstroomopening" + } + }; + #endregion + [Test] public void Validate_ValidCalculationInvalidHydraulicBoundaryDatabase_ReturnsFalse() { @@ -131,6 +187,185 @@ } [Test] + public void Validate_CalculationInputWithoutStructure_LogsErrorAndReturnsFalse() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSectionStub = CreateAssessmentSectionStub(new ClosingStructuresFailureMechanism(), mockRepository); + mockRepository.ReplayAll(); + + assessmentSectionStub.HydraulicBoundaryDatabase.FilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); + + const string name = ""; + + var calculation = new TestClosingStructuresCalculation() + { + Name = name, + InputParameters = + { + Structure = null + } + }; + + // Call + bool isValid = false; + Action call = () => isValid = ClosingStructuresCalculationService.Validate(calculation, assessmentSectionStub); + + // 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 kunstwerk sluiten geselecteerd.", msgs[1]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", name), msgs[2]); + }); + Assert.IsFalse(isValid); + + mockRepository.VerifyAll(); + } + + [Test] + [TestCase(double.NaN)] + [TestCase(double.PositiveInfinity)] + [TestCase(double.NegativeInfinity)] + public void Validate_InvalidVerticalWallCalculation_LogsErrorAndReturnsFalse(double value) + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSectionStub = CreateAssessmentSectionStub(new ClosingStructuresFailureMechanism(), mockRepository); + mockRepository.ReplayAll(); + + assessmentSectionStub.HydraulicBoundaryDatabase.FilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); + + const string name = ""; + + var calculation = new TestClosingStructuresCalculation() + { + Name = name + }; + + calculation.InputParameters.DeviationWaveDirection = RoundedDouble.NaN; + calculation.InputParameters.FactorStormDurationOpenStructure = (RoundedDouble) value; + calculation.InputParameters.ModelFactorSuperCriticalFlow.Mean = (RoundedDouble) value; + calculation.InputParameters.StructureNormalOrientation = RoundedDouble.NaN; + + calculation.InputParameters.LevelCrestStructureNotClosing.Mean = (RoundedDouble) value; + calculation.InputParameters.WidthFlowApertures.Mean = (RoundedDouble) value; + + if (double.IsNegativeInfinity(value)) + { + calculation.InputParameters.StormDuration.Mean = RoundedDouble.NaN; + calculation.InputParameters.StormDuration.CoefficientOfVariation = RoundedDouble.NaN; + calculation.InputParameters.ModelFactorSuperCriticalFlow.StandardDeviation = RoundedDouble.NaN; + calculation.InputParameters.LevelCrestStructureNotClosing.StandardDeviation = RoundedDouble.NaN; + + calculation.InputParameters.AllowedLevelIncreaseStorage.Mean = RoundedDouble.NaN; + calculation.InputParameters.AllowedLevelIncreaseStorage.StandardDeviation = RoundedDouble.NaN; + + calculation.InputParameters.StorageStructureArea.Mean = RoundedDouble.NaN; + calculation.InputParameters.StorageStructureArea.CoefficientOfVariation = RoundedDouble.NaN; + + calculation.InputParameters.FlowWidthAtBottomProtection.Mean = RoundedDouble.NaN; + calculation.InputParameters.FlowWidthAtBottomProtection.StandardDeviation = RoundedDouble.NaN; + + calculation.InputParameters.CriticalOvertoppingDischarge.Mean = RoundedDouble.NaN; + calculation.InputParameters.CriticalOvertoppingDischarge.CoefficientOfVariation = RoundedDouble.NaN; + + calculation.InputParameters.WidthFlowApertures.CoefficientOfVariation = RoundedDouble.NaN; + } + else + { + calculation.InputParameters.StormDuration.Mean = (RoundedDouble) value; + calculation.InputParameters.StormDuration.CoefficientOfVariation = (RoundedDouble) value; + + calculation.InputParameters.ModelFactorSuperCriticalFlow.StandardDeviation = (RoundedDouble) value; + calculation.InputParameters.LevelCrestStructureNotClosing.StandardDeviation = (RoundedDouble) value; + + calculation.InputParameters.AllowedLevelIncreaseStorage.Mean = (RoundedDouble) value; + calculation.InputParameters.AllowedLevelIncreaseStorage.StandardDeviation = (RoundedDouble) value; + + calculation.InputParameters.StorageStructureArea.Mean = (RoundedDouble) value; + calculation.InputParameters.StorageStructureArea.CoefficientOfVariation = (RoundedDouble) value; + + calculation.InputParameters.FlowWidthAtBottomProtection.Mean = (RoundedDouble) value; + calculation.InputParameters.FlowWidthAtBottomProtection.StandardDeviation = (RoundedDouble) value; + + calculation.InputParameters.CriticalOvertoppingDischarge.Mean = (RoundedDouble) value; + calculation.InputParameters.CriticalOvertoppingDischarge.CoefficientOfVariation = (RoundedDouble) value; + + calculation.InputParameters.WidthFlowApertures.CoefficientOfVariation = (RoundedDouble) value; + } + + // Call + bool isValid = false; + Action call = () => isValid = ClosingStructuresCalculationService.Validate(calculation, assessmentSectionStub); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(21, msgs.Length); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", name), msgs[0]); + StringAssert.StartsWith(string.Format("Validatie mislukt: De verwachtingswaarde voor '{0}' moet een positief getal zijn.", parameterNames["stormDuration"]), msgs[1]); + StringAssert.StartsWith(string.Format("Validatie mislukt: De variatiecoëfficient voor '{0}' moet groter zijn dan of gelijk zijn aan 0.", parameterNames["stormDuration"]), msgs[2]); + StringAssert.StartsWith(string.Format("Validatie mislukt: Er is geen concreet getal ingevoerd voor '{0}'.", parameterNames["deviationWaveDirection"]), msgs[3]); + StringAssert.StartsWith(string.Format("Validatie mislukt: De verwachtingswaarde voor '{0}' moet een concreet getal zijn.", parameterNames["modelFactorSuperCriticalFlow"]), msgs[4]); + StringAssert.StartsWith(string.Format("Validatie mislukt: De standaard afwijking voor '{0}' moet groter zijn dan of gelijk zijn aan 0.", parameterNames["modelFactorSuperCriticalFlow"]), msgs[5]); + StringAssert.StartsWith(string.Format("Validatie mislukt: Er is geen concreet getal ingevoerd voor '{0}'.", parameterNames["factorStormDurationOpenStructure"]), msgs[6]); + StringAssert.StartsWith(string.Format("Validatie mislukt: De verwachtingswaarde voor '{0}' moet een concreet getal zijn.", parameterNames["widthFlowApertures"]), msgs[7]); + StringAssert.StartsWith(string.Format("Validatie mislukt: De variatiecoëfficient voor '{0}' moet groter zijn dan of gelijk zijn aan 0.", parameterNames["widthFlowApertures"]), msgs[8]); + StringAssert.StartsWith(string.Format("Validatie mislukt: Er is geen concreet getal ingevoerd voor '{0}'.", parameterNames["structureNormalOrientation"]), msgs[9]); + StringAssert.StartsWith(string.Format("Validatie mislukt: De verwachtingswaarde voor '{0}' moet een positief getal zijn.", parameterNames["flowWidthAtBottomProtection"]), msgs[10]); + StringAssert.StartsWith(string.Format("Validatie mislukt: De standaard afwijking voor '{0}' moet groter zijn dan of gelijk zijn aan 0.", parameterNames["flowWidthAtBottomProtection"]), msgs[11]); + StringAssert.StartsWith(string.Format("Validatie mislukt: De verwachtingswaarde voor '{0}' moet een positief getal zijn.", parameterNames["storageStructureArea"]), msgs[12]); + StringAssert.StartsWith(string.Format("Validatie mislukt: De variatiecoëfficient voor '{0}' moet groter zijn dan of gelijk zijn aan 0.", parameterNames["storageStructureArea"]), msgs[13]); + StringAssert.StartsWith(string.Format("Validatie mislukt: De verwachtingswaarde voor '{0}' moet een positief getal zijn.", parameterNames["allowedLevelIncreaseStorage"]), msgs[14]); + StringAssert.StartsWith(string.Format("Validatie mislukt: De standaard afwijking voor '{0}' moet groter zijn dan of gelijk zijn aan 0.", parameterNames["allowedLevelIncreaseStorage"]), msgs[15]); + StringAssert.StartsWith(string.Format("Validatie mislukt: De verwachtingswaarde voor '{0}' moet een concreet getal zijn.", parameterNames["levelCrestStructureNotClosing"]), msgs[16]); + StringAssert.StartsWith(string.Format("Validatie mislukt: De standaard afwijking voor '{0}' moet groter zijn dan of gelijk zijn aan 0.", parameterNames["levelCrestStructureNotClosing"]), msgs[17]); + StringAssert.StartsWith(string.Format("Validatie mislukt: De verwachtingswaarde voor '{0}' moet een positief getal zijn.", parameterNames["criticalOvertoppingDischarge"]), msgs[18]); + StringAssert.StartsWith(string.Format("Validatie mislukt: De variatiecoëfficient voor '{0}' moet groter zijn dan of gelijk zijn aan 0.", parameterNames["criticalOvertoppingDischarge"]), msgs[19]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", name), msgs[20]); + }); + Assert.IsFalse(isValid); + + mockRepository.VerifyAll(); + } + + [Test] + public void Validate_InvalidInFlowModelType_ThrowsNotSupportedException() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSectionStub = CreateAssessmentSectionStub(new ClosingStructuresFailureMechanism(), mockRepository); + mockRepository.ReplayAll(); + + assessmentSectionStub.HydraulicBoundaryDatabase.FilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); + + const string name = ""; + + var calculation = new TestClosingStructuresCalculation() + { + Name = name, + InputParameters = + { + InflowModelType = (ClosingStructureInflowModelType) 9001 + } + }; + + // Call + bool isValid = false; + TestDelegate call = () => isValid = ClosingStructuresCalculationService.Validate(calculation, assessmentSectionStub); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("inputParameters", exception.ParamName); + Assert.IsFalse(isValid); + mockRepository.VerifyAll(); + } + + [Test] public void Calculate_InvalidInFlowModelType_ThrowsNotSupportedException() { // Setup Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs =================================================================== diff -u -r86984ca293c30b4f9b47da7825cbae1404fffe08 -r440f228de8eb72ed5be40270b20a46113917333e --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs (.../HeightStructuresCalculationService.cs) (revision 86984ca293c30b4f9b47da7825cbae1404fffe08) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs (.../HeightStructuresCalculationService.cs) (revision 440f228de8eb72ed5be40270b20a46113917333e) @@ -101,7 +101,7 @@ var calculationName = calculation.Name; FailureMechanismSection failureMechanismSection = StructuresHelper.FailureMechanismSectionForCalculation(failureMechanism.Sections, - calculation); + calculation); StructuresOvertoppingCalculationInput input = CreateInput(calculation, failureMechanismSection, failureMechanism.GeneralInput); @@ -184,46 +184,40 @@ else { validationResults.AddRange(DistributionValidation.ValidateDistribution(inputParameters.StormDuration, - GenerateParameterNameWithoutUnits(RingtoetsCommonFormsResources.Structure_StormDuration_DisplayName))); + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StormDuration_DisplayName))); if (IsInvalidNumber(inputParameters.DeviationWaveDirection)) { validationResults.Add(string.Format(RingtoetsCommonServiceResources.Validation_ValidateInput_No_value_entered_for_ParameterName_0_, - GenerateParameterNameWithoutUnits(RingtoetsCommonFormsResources.Structure_DeviationWaveDirection_DisplayName))); + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_DeviationWaveDirection_DisplayName))); } validationResults.AddRange(DistributionValidation.ValidateDistribution(inputParameters.ModelFactorSuperCriticalFlow, - GenerateParameterNameWithoutUnits(RingtoetsCommonFormsResources.Structure_ModelFactorSuperCriticalFlow_DisplayName))); + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_ModelFactorSuperCriticalFlow_DisplayName))); if (IsInvalidNumber(inputParameters.StructureNormalOrientation)) { validationResults.Add(string.Format(RingtoetsCommonServiceResources.Validation_ValidateInput_No_value_entered_for_ParameterName_0_, - GenerateParameterNameWithoutUnits(RingtoetsCommonFormsResources.Orientation_DisplayName))); + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Orientation_DisplayName))); } validationResults.AddRange(DistributionValidation.ValidateDistribution(inputParameters.FlowWidthAtBottomProtection, - GenerateParameterNameWithoutUnits(RingtoetsCommonFormsResources.Structure_FlowWidthAtBottomProtection_DisplayName))); + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_FlowWidthAtBottomProtection_DisplayName))); validationResults.AddRange(DistributionValidation.ValidateDistribution(inputParameters.WidthFlowApertures, - GenerateParameterNameWithoutUnits(RingtoetsCommonFormsResources.Structure_WidthFlowApertures_DisplayName))); + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_WidthFlowApertures_DisplayName))); validationResults.AddRange(DistributionValidation.ValidateDistribution(inputParameters.StorageStructureArea, - GenerateParameterNameWithoutUnits(RingtoetsCommonFormsResources.Structure_StorageStructureArea_DisplayName))); + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StorageStructureArea_DisplayName))); validationResults.AddRange(DistributionValidation.ValidateDistribution(inputParameters.AllowedLevelIncreaseStorage, - GenerateParameterNameWithoutUnits(RingtoetsCommonFormsResources.Structure_AllowedLevelIncreaseStorage_DisplayName))); + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_AllowedLevelIncreaseStorage_DisplayName))); validationResults.AddRange(DistributionValidation.ValidateDistribution(inputParameters.LevelCrestStructure, - GenerateParameterNameWithoutUnits(RingtoetsCommonFormsResources.Structure_LevelCrestStructure_DisplayName))); + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_LevelCrestStructure_DisplayName))); validationResults.AddRange(DistributionValidation.ValidateDistribution(inputParameters.CriticalOvertoppingDischarge, - GenerateParameterNameWithoutUnits(RingtoetsCommonFormsResources.Structure_CriticalOvertoppingDischarge_DisplayName))); + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_CriticalOvertoppingDischarge_DisplayName))); } return validationResults.ToArray(); } - private static string GenerateParameterNameWithoutUnits(string parameterDescription) - { - string[] splitString = parameterDescription.Split('['); - return splitString.Length != 0 ? splitString[0].ToLower().Trim() : string.Empty; - } - private static bool IsInvalidNumber(RoundedDouble value) { return double.IsNaN(value) || double.IsInfinity(value);