Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Configurations/ClosingStructuresCalculationConfigurationReader.cs =================================================================== diff -u -r9f8c8ff1cd49a1764ff3dde12eea6be35d9c34a7 -rb1fd20384e0835b604bb68d94e16e8ead46ed93e --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Configurations/ClosingStructuresCalculationConfigurationReader.cs (.../ClosingStructuresCalculationConfigurationReader.cs) (revision 9f8c8ff1cd49a1764ff3dde12eea6be35d9c34a7) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Configurations/ClosingStructuresCalculationConfigurationReader.cs (.../ClosingStructuresCalculationConfigurationReader.cs) (revision b1fd20384e0835b604bb68d94e16e8ead46ed93e) @@ -108,7 +108,7 @@ ForeshoreProfileId = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.ForeshoreProfileNameElement), HydraulicBoundaryLocationName = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement), StructureId = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.StructureElement), - WaveReduction = GetWaveReductionParameters(calculationElement), + WaveReduction = calculationElement.GetWaveReductionParameters(), AreaFlowApertures = calculationElement.GetStochastConfiguration(ClosingStructuresConfigurationSchemaIdentifiers.AreaFlowAperturesStochastName), DrainCoefficient = calculationElement.GetStochastConfiguration(ClosingStructuresConfigurationSchemaIdentifiers.DrainCoefficientStochastName), InsideWaterLevel = calculationElement.GetStochastConfiguration(ClosingStructuresConfigurationSchemaIdentifiers.InsideWaterLevelStochastName), @@ -125,21 +125,5 @@ return configuration; } - - private static WaveReductionConfiguration GetWaveReductionParameters(XElement calculationElement) - { - XElement waveReduction = calculationElement.GetDescendantElement(ConfigurationSchemaIdentifiers.WaveReduction); - if (waveReduction != null) - { - return new WaveReductionConfiguration - { - BreakWaterType = (ConfigurationBreakWaterType?) calculationElement.GetConvertedValueFromDescendantStringElement(ConfigurationSchemaIdentifiers.BreakWaterType), - BreakWaterHeight = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.BreakWaterHeight), - UseBreakWater = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseBreakWater), - UseForeshoreProfile = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseForeshore) - }; - } - return null; - } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/Helpers/XElementExtensions.cs =================================================================== diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -rb1fd20384e0835b604bb68d94e16e8ead46ed93e --- Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/Helpers/XElementExtensions.cs (.../XElementExtensions.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/Helpers/XElementExtensions.cs (.../XElementExtensions.cs) (revision b1fd20384e0835b604bb68d94e16e8ead46ed93e) @@ -203,7 +203,7 @@ } /// - /// Gets a configuration based on the values found in the . + /// Gets a stochast configuration based on the values found in the . /// /// The element containing values for stochast parameters. /// The name of the stochast to find the parameter values for. @@ -235,5 +235,31 @@ } return null; } + + /// + /// Gets a wave reduction configuration based on the values found in the . + /// + /// The element containing values for wave reduction parameters. + /// Thrown when any parameter is null. + /// Thrown when the value for break water type isn't valid. + /// Thrown when the value for break water height, use foreshore profile or + /// use breakwater isn't in the correct format to convert to a value. + /// Thrown when the value for a break water height represents a number less + /// than or greater than . + public static WaveReductionConfiguration GetWaveReductionParameters(this XElement calculationElement) + { + XElement waveReduction = calculationElement.GetDescendantElement(ConfigurationSchemaIdentifiers.WaveReduction); + if (waveReduction != null) + { + return new WaveReductionConfiguration + { + BreakWaterType = (ConfigurationBreakWaterType?) calculationElement.GetConvertedValueFromDescendantStringElement(ConfigurationSchemaIdentifiers.BreakWaterType), + BreakWaterHeight = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.BreakWaterHeight), + UseBreakWater = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseBreakWater), + UseForeshoreProfile = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseForeshore) + }; + } + return null; + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/Helpers/XElementExtensionsTest.cs =================================================================== diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -rb1fd20384e0835b604bb68d94e16e8ead46ed93e --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/Helpers/XElementExtensionsTest.cs (.../XElementExtensionsTest.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/Helpers/XElementExtensionsTest.cs (.../XElementExtensionsTest.cs) (revision b1fd20384e0835b604bb68d94e16e8ead46ed93e) @@ -837,6 +837,202 @@ Assert.AreEqual(standardDeviation, stochast.VariationCoefficient); } + [Test] + public void GetWaveReductionParameters_WithBreakWaterHeight_ReturnsConfiguration() + { + // Setup + const double height = 2.1; + + var breakWaterHeightElement = new XElement("damhoogte", height); + var waveReductionElement = new XElement("golfreductie", breakWaterHeightElement); + var xElement = new XElement("root", new XElement("root", waveReductionElement)); + + // Call + WaveReductionConfiguration waveReduction = xElement.GetWaveReductionParameters(); + + // Assert + Assert.AreEqual(height, waveReduction.BreakWaterHeight); + Assert.IsNull(waveReduction.BreakWaterType); + Assert.IsNull(waveReduction.UseForeshoreProfile); + Assert.IsNull(waveReduction.UseBreakWater); + } + + [Test] + public void GetWaveReductionParameters_WithTooLargeBreakWaterHeight_ThrowsOverflowException() + { + // Setup + string height = string.Format(CultureInfo.InvariantCulture, "1{0}", double.MaxValue); + + var breakWaterHeightElement = new XElement("damhoogte", height); + var waveReductionElement = new XElement("golfreductie", breakWaterHeightElement); + var xElement = new XElement("root", new XElement("root", waveReductionElement)); + + // Call + TestDelegate test = () => xElement.GetWaveReductionParameters(); + + // Assert + Assert.Throws(test); + } + + [Test] + public void GetWaveReductionParameters_WithInvalidBreakWaterHeight_ThrowsFormatException() + { + // Setup + const string height = "very tall"; + + var breakWaterHeightElement = new XElement("damhoogte", height); + var waveReductionElement = new XElement("golfreductie", breakWaterHeightElement); + var xElement = new XElement("root", new XElement("root", waveReductionElement)); + + // Call + TestDelegate test = () => xElement.GetWaveReductionParameters(); + + // Assert + Assert.Throws(test); + } + + [Test] + public void GetWaveReductionParameters_WithBreakWaterType_ReturnsConfiguration() + { + // Setup + const string type = "havendam"; + + var breakWaterTypeElement = new XElement("damtype", type); + var waveReductionElement = new XElement("golfreductie", breakWaterTypeElement); + var xElement = new XElement("root", new XElement("root", waveReductionElement)); + + // Call + WaveReductionConfiguration waveReduction = xElement.GetWaveReductionParameters(); + + // Assert + Assert.AreEqual(ConfigurationBreakWaterType.Dam, waveReduction.BreakWaterType); + Assert.IsNull(waveReduction.BreakWaterHeight); + Assert.IsNull(waveReduction.UseForeshoreProfile); + Assert.IsNull(waveReduction.UseBreakWater); + } + + [Test] + public void GetWaveReductionParameters_WithInvalidBreakWaterType_ThrowsNotSupportedException() + { + // Setup + const string type = "not really a type"; + + var breakWaterTypeElement = new XElement("damtype", type); + var waveReductionElement = new XElement("golfreductie", breakWaterTypeElement); + var xElement = new XElement("root", new XElement("root", waveReductionElement)); + + // Call + TestDelegate test = () => xElement.GetWaveReductionParameters(); + + // Assert + Assert.Throws(test); + } + + [Test] + public void GetWaveReductionParameters_WithUseForeshoreProfile_ReturnsConfiguration() + { + // Setup + const string useForeshoreProfile = "true"; + + var useForeshoreProfileElement = new XElement("voorlandgebruiken", useForeshoreProfile); + var waveReductionElement = new XElement("golfreductie", useForeshoreProfileElement); + var xElement = new XElement("root", new XElement("root", waveReductionElement)); + + // Call + WaveReductionConfiguration waveReduction = xElement.GetWaveReductionParameters(); + + // Assert + Assert.IsTrue(waveReduction.UseForeshoreProfile); + Assert.IsNull(waveReduction.BreakWaterHeight); + Assert.IsNull(waveReduction.BreakWaterType); + Assert.IsNull(waveReduction.UseBreakWater); + } + + [Test] + public void GetWaveReductionParameters_WithInvalidUseForeshoreProfile_ThrowsFormatException() + { + // Setup + const string useForeshoreProfile = "only half true"; + + var useForeshoreProfileElement = new XElement("voorlandgebruiken", useForeshoreProfile); + var waveReductionElement = new XElement("golfreductie", useForeshoreProfileElement); + var xElement = new XElement("root", new XElement("root", waveReductionElement)); + + // Call + TestDelegate test = () => xElement.GetWaveReductionParameters(); + + // Assert + Assert.Throws(test); + } + + [Test] + public void GetWaveReductionParameters_WithUseBreakWater_ReturnsConfiguration() + { + // Setup + const string useBreakWater = "true"; + + var useBreakWaterElement = new XElement("damgebruiken", useBreakWater); + var waveReductionElement = new XElement("golfreductie", useBreakWaterElement); + var xElement = new XElement("root", new XElement("root", waveReductionElement)); + + // Call + WaveReductionConfiguration waveReduction = xElement.GetWaveReductionParameters(); + + // Assert + Assert.IsTrue(waveReduction.UseBreakWater); + Assert.IsNull(waveReduction.BreakWaterHeight); + Assert.IsNull(waveReduction.BreakWaterType); + Assert.IsNull(waveReduction.UseForeshoreProfile); + } + + [Test] + public void GetWaveReductionParameters_WithInvalidUseBreakWater_ThrowsFormatException() + { + // Setup + const string useBreakWater = "partially true"; + + var useBreakWaterElement = new XElement("damgebruiken", useBreakWater); + var waveReductionElement = new XElement("golfreductie", useBreakWaterElement); + var xElement = new XElement("root", new XElement("root", waveReductionElement)); + + // Call + TestDelegate test = () => xElement.GetWaveReductionParameters(); + + // Assert + Assert.Throws(test); + } + + [Test] + public void GetWaveReductionParameters_WithAllParameters_ReturnsConfiguration() + { + // Setup + const double height = 2.1; + const string type = "havendam"; + const string useForeshoreProfile = "true"; + const string useBreakWater = "true"; + + var breakWaterHeightElement = new XElement("damhoogte", height); + var breakWaterTypeElement = new XElement("damtype", type); + var useForeshoreProfileElement = new XElement("voorlandgebruiken", useForeshoreProfile); + var useBreakWaterElement = new XElement("damgebruiken", useBreakWater); + + var waveReductionElement = new XElement("golfreductie", + breakWaterHeightElement, + breakWaterTypeElement, + useForeshoreProfileElement, + useBreakWaterElement); + var xElement = new XElement("root", new XElement("root", waveReductionElement)); + + // Call + WaveReductionConfiguration waveReduction = xElement.GetWaveReductionParameters(); + + // Assert + Assert.AreEqual(height, waveReduction.BreakWaterHeight); + Assert.AreEqual(ConfigurationBreakWaterType.Dam, waveReduction.BreakWaterType); + Assert.IsTrue(waveReduction.UseForeshoreProfile); + Assert.IsTrue(waveReduction.UseBreakWater); + } + private class DoubleToBooleanConverter : TypeConverter { public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfiguration.cs =================================================================== diff -u -r8336ede0837d35257e8b85c3b0090b0774342d90 -rb1fd20384e0835b604bb68d94e16e8ead46ed93e --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfiguration.cs (.../GrassCoverErosionInwardsCalculationConfiguration.cs) (revision 8336ede0837d35257e8b85c3b0090b0774342d90) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfiguration.cs (.../GrassCoverErosionInwardsCalculationConfiguration.cs) (revision b1fd20384e0835b604bb68d94e16e8ead46ed93e) @@ -27,175 +27,83 @@ /// /// Configuration of a grass cover erosion inwards calculation. /// - public class ReadGrassCoverErosionInwardsCalculation : IConfigurationItem + public class GrassCoverErosionInwardsCalculationConfiguration : IConfigurationItem { + private string name; + /// - /// Creates a new instance of . + /// Creates a new instance of . /// - /// The container of the properties for the - /// . - /// Thrown when + /// The name of the . + /// + /// Thrown when /// is null. - public ReadGrassCoverErosionInwardsCalculation(ConstructionProperties constructionProperties) + public GrassCoverErosionInwardsCalculationConfiguration(string name) { - if (constructionProperties == null) - { - throw new ArgumentNullException(nameof(constructionProperties)); - } - - Name = constructionProperties.Name; - HydraulicBoundaryLocation = constructionProperties.HydraulicBoundaryLocation; - DikeProfileId = constructionProperties.DikeProfileId; - Orientation = constructionProperties.Orientation; - DikeHeight = constructionProperties.DikeHeight; - DikeHeightCalculationType = constructionProperties.DikeHeightCalculationType; - OvertoppingRateCalculationType = constructionProperties.OvertoppingRateCalculationType; - UseBreakWater = constructionProperties.UseBreakWater; - BreakWaterType = constructionProperties.BreakWaterType; - BreakWaterHeight = constructionProperties.BreakWaterHeight; - UseForeshore = constructionProperties.UseForeshore; - CriticalFlowRateMean = constructionProperties.CriticalFlowRateMean; - CriticalFlowRateStandardDeviation = constructionProperties.CriticalFlowRateStandardDeviation; + Name = name; } /// /// Gets the name of the hydraulic boundary location of the read grass cover erosion /// inwards calculation. /// - public string HydraulicBoundaryLocation { get; } + public string HydraulicBoundaryLocation { get; set; } /// /// Gets the Id of the dike profile of the read grass cover erosion inwards calculation. /// - public string DikeProfileId { get; } + public string DikeProfileId { get; set; } /// /// Gets the orientation of the grass cover erosion inwards calculation. /// - public double? Orientation { get; } + public double? Orientation { get; set; } /// /// Gets the dike height of the grass cover erosion inwards calculation. /// - public double? DikeHeight { get; } + public double? DikeHeight { get; set; } /// /// Gets the value for how the dike height should be calculated for the grass cover /// erosion inwards calculation. /// - public ConfigurationHydraulicLoadsCalculationType? DikeHeightCalculationType { get; } + public ConfigurationHydraulicLoadsCalculationType? DikeHeightCalculationType { get; set; } /// /// Gets the value for how the overtopping rate should be calculated for the grass cover /// erosion inwards calculation. /// - public ConfigurationHydraulicLoadsCalculationType? OvertoppingRateCalculationType { get; } - + public ConfigurationHydraulicLoadsCalculationType? OvertoppingRateCalculationType { get; set; } + /// - /// Gets the value indicating if the break water for the grass cover erosion inwards - /// calculation should be used. + /// Gets or sets the wave reduction configuration. /// - public bool? UseBreakWater { get; } + public WaveReductionConfiguration WaveReduction { get; set; } /// - /// Gets the type of break water for the grass cover erosion inwards calculation. + /// Gets the critical flow distribution for the grass cover erosion inwards calculation. /// - public ConfigurationBreakWaterType? BreakWaterType { get; } + public StochastConfiguration CriticalFlowRate { get; set; } /// - /// Gets the height of the break water for the grass cover erosion inwards calculation. + /// Gets or sets the name of the grass cover erosion inwards calculation. /// - public double? BreakWaterHeight { get; } - - /// - /// Gets the value indicating if the foreshore for the grass cover erosion inwards - /// calculation should be used. - /// - public bool? UseForeshore { get; } - - /// - /// Gets the mean of the critical flow distribution for the grass cover erosion - /// inwards calculation. - /// - public double? CriticalFlowRateMean { get; } - - /// - /// Gets the standard deviation of the critical flow distribution for the grass - /// cover erosion inwards calculation. - /// - public double? CriticalFlowRateStandardDeviation { get; } - - public string Name { get; } - - /// - /// Class holding the various construction parameters for . - /// - public class ConstructionProperties + /// Thrown when is null. + public string Name { - /// - /// Gets or sets the value for . - /// - public string Name { get; set; } - - /// - /// Gets or sets the value for . - /// - public string HydraulicBoundaryLocation { get; set; } - - /// - /// Gets or sets the value for . - /// - public string DikeProfileId { get; set; } - - /// - /// Gets or sets the value for . - /// - public double? Orientation { get; set; } - - /// - /// Gets or sets the value for . - /// - public double? DikeHeight { get; set; } - - /// - /// Gets or sets the value for . - /// - public ConfigurationHydraulicLoadsCalculationType? DikeHeightCalculationType { get; set; } - - /// - /// Gets or sets the value for . - /// - public ConfigurationHydraulicLoadsCalculationType? OvertoppingRateCalculationType { get; set; } - - /// - /// Gets or sets the value for . - /// - public bool? UseBreakWater { get; set; } - - /// - /// Gets or sets the value for . - /// - public ConfigurationBreakWaterType? BreakWaterType { get; set; } - - /// - /// Gets or sets the value for . - /// - public double? BreakWaterHeight { get; set; } - - /// - /// Gets or sets the value for . - /// - public bool? UseForeshore { get; set; } - - /// - /// Gets or sets the value for . - /// - public double? CriticalFlowRateMean { get; set; } - - /// - /// Gets or sets the value for . - /// - public double? CriticalFlowRateStandardDeviation { get; set; } + get + { + return name; + } + set + { + if (value == null) + { + throw new ArgumentNullException(nameof(value), @"Name is required for a structure calculation configuration."); + } + name = value; + } } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfigurationImporter.cs =================================================================== diff -u -r237b9031d74382e26141395ff845d5e43f44981d -rb1fd20384e0835b604bb68d94e16e8ead46ed93e --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfigurationImporter.cs (.../GrassCoverErosionInwardsCalculationConfigurationImporter.cs) (revision 237b9031d74382e26141395ff845d5e43f44981d) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfigurationImporter.cs (.../GrassCoverErosionInwardsCalculationConfigurationImporter.cs) (revision b1fd20384e0835b604bb68d94e16e8ead46ed93e) @@ -23,10 +23,11 @@ using System.Collections.Generic; using System.Linq; using Core.Common.Base.Data; +using log4net; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.Hydraulics; -using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Configurations.Helpers; using Ringtoets.Common.IO.Configurations.Import; using Ringtoets.GrassCoverErosionInwards.Data; @@ -36,7 +37,7 @@ namespace Ringtoets.GrassCoverErosionInwards.IO.Configurations { public class GrassCoverErosionInwardsCalculationConfigurationImporter - : CalculationConfigurationImporter + : CalculationConfigurationImporter { private readonly IEnumerable availableHydraulicBoundaryLocations; private readonly IEnumerable availableDikeProfiles; @@ -93,22 +94,23 @@ return new GrassCoverErosionInwardsCalculationConfigurationReader(xmlFilePath); } - protected override ICalculation ParseReadCalculation(ReadGrassCoverErosionInwardsCalculation readCalculation) + protected override ICalculation ParseReadCalculation(GrassCoverErosionInwardsCalculationConfiguration calculationConfiguration) { var calculation = new GrassCoverErosionInwardsCalculation { - Name = readCalculation.Name + Name = calculationConfiguration.Name }; - ReadDikeHeightCalculationType(readCalculation, calculation); - ReadOvertoppingRateCalculationType(readCalculation, calculation); + ReadDikeHeightCalculationType(calculationConfiguration, calculation); + ReadOvertoppingRateCalculationType(calculationConfiguration, calculation); - if (TryReadCriticalWaveReduction(readCalculation, calculation) - && TryReadHydraulicBoundaryLocation(readCalculation.HydraulicBoundaryLocation, calculation) - && TryReadDikeProfile(readCalculation.DikeProfileId, calculation) - && TryReadOrientation(readCalculation, calculation) - && TryReadWaveReduction(readCalculation, calculation) - && TryReadDikeHeight(readCalculation, calculation)) + if (TryReadCriticalWaveReduction(calculationConfiguration, calculation) + && TryReadHydraulicBoundaryLocation(calculationConfiguration.HydraulicBoundaryLocation, calculation) + && TryReadDikeProfile(calculationConfiguration.DikeProfileId, calculation) + && TryReadOrientation(calculationConfiguration, calculation) + && TryReadDikeHeight(calculationConfiguration, calculation) + && ValidateWaveReduction(calculationConfiguration, calculation)) { + SetWaveReductionParameters(calculationConfiguration.WaveReduction, calculation.InputParameters); return calculation; } return null; @@ -152,13 +154,13 @@ /// /// Reads the orientation. /// - /// The calculation read from the imported file. + /// The calculation read from the imported file. /// The calculation to configure. /// false when the orientation is invalid or when there is an orientation but /// no dike profile defined, true otherwise. - private bool TryReadOrientation(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) + private bool TryReadOrientation(GrassCoverErosionInwardsCalculationConfiguration calculationConfiguration, GrassCoverErosionInwardsCalculation calculation) { - if (readCalculation.Orientation.HasValue) + if (calculationConfiguration.Orientation.HasValue) { if (calculation.InputParameters.DikeProfile == null) { @@ -168,7 +170,7 @@ return false; } - double orientation = readCalculation.Orientation.Value; + double orientation = calculationConfiguration.Orientation.Value; try { @@ -188,50 +190,14 @@ } /// - /// Reads the wave reduction parameters. - /// - /// The calculation read from the imported file. - /// The calculation to configure. - /// false when there is an invalid wave reduction parameter defined, true otherwise. - private bool TryReadWaveReduction(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) - { - if (!ValidateWaveReduction(readCalculation, calculation)) - { - return false; - } - - if (readCalculation.UseForeshore.HasValue) - { - calculation.InputParameters.UseForeshore = readCalculation.UseForeshore.Value; - } - - if (readCalculation.UseBreakWater.HasValue) - { - calculation.InputParameters.UseBreakWater = readCalculation.UseBreakWater.Value; - } - - if (readCalculation.BreakWaterType.HasValue) - { - calculation.InputParameters.BreakWater.Type = (BreakWaterType) readCalculation.BreakWaterType.Value; - } - - if (readCalculation.BreakWaterHeight.HasValue) - { - calculation.InputParameters.BreakWater.Height = (RoundedDouble) readCalculation.BreakWaterHeight; - } - - return true; - } - - /// /// Reads the dike height. /// - /// The calculation read from the imported file. + /// The calculation read from the imported file. /// The calculation to configure. /// false when there is a dike height but no dike profile defined, true otherwise. - private bool TryReadDikeHeight(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) + private bool TryReadDikeHeight(GrassCoverErosionInwardsCalculationConfiguration calculationConfiguration, GrassCoverErosionInwardsCalculation calculation) { - if (readCalculation.DikeHeight.HasValue) + if (calculationConfiguration.DikeHeight.HasValue) { if (calculation.InputParameters.DikeProfile == null) { @@ -240,74 +206,73 @@ return false; } - calculation.InputParameters.DikeHeight = (RoundedDouble) readCalculation.DikeHeight.Value; + calculation.InputParameters.DikeHeight = (RoundedDouble) calculationConfiguration.DikeHeight.Value; } return true; } /// /// Reads the dike height calculation type. /// - /// The calculation read from the imported file. + /// The calculation read from the imported file. /// The calculation to configure. - private static void ReadDikeHeightCalculationType(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) + private static void ReadDikeHeightCalculationType(GrassCoverErosionInwardsCalculationConfiguration calculationConfiguration, GrassCoverErosionInwardsCalculation calculation) { - if (readCalculation.DikeHeightCalculationType.HasValue) + if (calculationConfiguration.DikeHeightCalculationType.HasValue) { - calculation.InputParameters.DikeHeightCalculationType = (DikeHeightCalculationType) readCalculation.DikeHeightCalculationType.Value; + calculation.InputParameters.DikeHeightCalculationType = (DikeHeightCalculationType) calculationConfiguration.DikeHeightCalculationType.Value; } } /// /// Reads the overtopping rate calculation type. /// - /// The calculation read from the imported file. + /// The calculation read from the imported file. /// The calculation to configure. - private static void ReadOvertoppingRateCalculationType(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) + private static void ReadOvertoppingRateCalculationType(GrassCoverErosionInwardsCalculationConfiguration calculationConfiguration, GrassCoverErosionInwardsCalculation calculation) { - if (readCalculation.OvertoppingRateCalculationType.HasValue) + if (calculationConfiguration.OvertoppingRateCalculationType.HasValue) { - calculation.InputParameters.OvertoppingRateCalculationType = (OvertoppingRateCalculationType) readCalculation.OvertoppingRateCalculationType.Value; + calculation.InputParameters.OvertoppingRateCalculationType = (OvertoppingRateCalculationType) calculationConfiguration.OvertoppingRateCalculationType.Value; } } /// /// Reads the critical wave reduction. /// - /// The calculation read from the imported file. + /// The calculation read from the imported file. /// The calculation to configure. /// true if reading all required wave reduction parameters was successful, /// false otherwise. - private static bool TryReadCriticalWaveReduction(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) + private bool TryReadCriticalWaveReduction(GrassCoverErosionInwardsCalculationConfiguration calculationConfiguration, GrassCoverErosionInwardsCalculation calculation) { - var distribution = (LogNormalDistribution) calculation.InputParameters.CriticalFlowRate.Clone(); - - if (!distribution.TrySetDistributionProperties(readCalculation.CriticalFlowRateMean, - readCalculation.CriticalFlowRateStandardDeviation, - GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.CriticalFlowRateStochastName, - calculation.Name)) - { - return false; - } - - calculation.InputParameters.CriticalFlowRate = distribution; - return true; + return ConfigurationImportHelper.TrySetStandardDeviationStochast( + GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.CriticalFlowRateStochastName, + calculation.Name, + calculation.InputParameters, + calculationConfiguration.CriticalFlowRate, + i => i.CriticalFlowRate, + (i, s) => i.CriticalFlowRate = s, + Log); } /// /// Validation to check if the defined wave reduction parameters are valid. /// - /// The calculation read from the imported file. + /// The calculation read from the imported file. /// The calculation to configure. /// false when there is an invalid wave reduction parameter defined, true otherwise. - private bool ValidateWaveReduction(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) + private bool ValidateWaveReduction(GrassCoverErosionInwardsCalculationConfiguration calculationConfiguration, GrassCoverErosionInwardsCalculation calculation) { + WaveReductionConfiguration waveReductionConfiguration = calculationConfiguration.WaveReduction; + if (calculation.InputParameters.DikeProfile == null) { - if (readCalculation.UseBreakWater.HasValue - || readCalculation.UseForeshore.HasValue - || readCalculation.BreakWaterHeight != null - || readCalculation.BreakWaterType != null) + if (waveReductionConfiguration != null && + (waveReductionConfiguration.UseBreakWater.HasValue + || waveReductionConfiguration.UseForeshoreProfile.HasValue + || waveReductionConfiguration.BreakWaterHeight != null + || waveReductionConfiguration.BreakWaterType != null)) { Log.LogCalculationConversionError(Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_No_DikeProfile_provided_for_BreakWater_parameters, calculation.Name); @@ -317,11 +282,11 @@ } else if (!calculation.InputParameters.ForeshoreGeometry.Any()) { - if (readCalculation.UseForeshore.HasValue && readCalculation.UseForeshore.Value) + if (waveReductionConfiguration?.UseForeshoreProfile != null && waveReductionConfiguration.UseForeshoreProfile.Value) { Log.LogCalculationConversionError(string.Format( Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_DikeProfile_0_has_no_geometry_and_cannot_be_used, - readCalculation.DikeProfileId), + calculationConfiguration.DikeProfileId), calculation.Name); return false; } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfigurationReader.cs =================================================================== diff -u -r8336ede0837d35257e8b85c3b0090b0774342d90 -rb1fd20384e0835b604bb68d94e16e8ead46ed93e --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfigurationReader.cs (.../GrassCoverErosionInwardsCalculationConfigurationReader.cs) (revision 8336ede0837d35257e8b85c3b0090b0774342d90) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfigurationReader.cs (.../GrassCoverErosionInwardsCalculationConfigurationReader.cs) (revision b1fd20384e0835b604bb68d94e16e8ead46ed93e) @@ -35,9 +35,9 @@ /// /// This class reads a grass cover erosion inwards configuration from XML and creates /// a collection of corresponding , typically - /// containing one or more . + /// containing one or more . /// - public class GrassCoverErosionInwardsCalculationConfigurationReader : CalculationConfigurationReader + public class GrassCoverErosionInwardsCalculationConfigurationReader : CalculationConfigurationReader { private const string hrLocatieSchemaName = "HrLocatieSchema.xsd"; private const string orientatieSchemaName = "OrientatieSchema.xsd"; @@ -80,11 +80,10 @@ } }) {} - protected override ReadGrassCoverErosionInwardsCalculation ParseCalculationElement(XElement calculationElement) + protected override GrassCoverErosionInwardsCalculationConfiguration ParseCalculationElement(XElement calculationElement) { - var constructionProperties = new ReadGrassCoverErosionInwardsCalculation.ConstructionProperties + var configuration = new GrassCoverErosionInwardsCalculationConfiguration(calculationElement.Attribute(ConfigurationSchemaIdentifiers.NameAttribute).Value) { - Name = calculationElement.Attribute(ConfigurationSchemaIdentifiers.NameAttribute).Value, HydraulicBoundaryLocation = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement), DikeProfileId = calculationElement.GetStringValueFromDescendantElement(GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.DikeProfileElement), Orientation = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.Orientation), @@ -93,20 +92,11 @@ GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.DikeHeightCalculationTypeElement), OvertoppingRateCalculationType = (ConfigurationHydraulicLoadsCalculationType?) calculationElement.GetConvertedValueFromDescendantStringElement( GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.OvertoppingRateCalculationTypeElement), - UseBreakWater = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseBreakWater), - BreakWaterType = (ConfigurationBreakWaterType?) calculationElement.GetConvertedValueFromDescendantStringElement(ConfigurationSchemaIdentifiers.BreakWaterType), - BreakWaterHeight = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.BreakWaterHeight), - UseForeshore = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseForeshore) + WaveReduction = calculationElement.GetWaveReductionParameters(), + CriticalFlowRate = calculationElement.GetStochastConfiguration(GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.CriticalFlowRateStochastName) }; - XElement criticalFlowRateElement = calculationElement.GetStochastElement(GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.CriticalFlowRateStochastName); - if (criticalFlowRateElement != null) - { - constructionProperties.CriticalFlowRateMean = criticalFlowRateElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.MeanElement); - constructionProperties.CriticalFlowRateStandardDeviation = criticalFlowRateElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.StandardDeviationElement); - } - - return new ReadGrassCoverErosionInwardsCalculation(constructionProperties); + return configuration; } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/GrassCoverErosionInwardsCalculationConfigurationImporterTest.cs =================================================================== diff -u -r237b9031d74382e26141395ff845d5e43f44981d -rb1fd20384e0835b604bb68d94e16e8ead46ed93e --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/GrassCoverErosionInwardsCalculationConfigurationImporterTest.cs (.../GrassCoverErosionInwardsCalculationConfigurationImporterTest.cs) (revision 237b9031d74382e26141395ff845d5e43f44981d) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/GrassCoverErosionInwardsCalculationConfigurationImporterTest.cs (.../GrassCoverErosionInwardsCalculationConfigurationImporterTest.cs) (revision b1fd20384e0835b604bb68d94e16e8ead46ed93e) @@ -59,7 +59,7 @@ Assert.IsInstanceOf< CalculationConfigurationImporter< GrassCoverErosionInwardsCalculationConfigurationReader, - ReadGrassCoverErosionInwardsCalculation>>(importer); + GrassCoverErosionInwardsCalculationConfiguration>>(importer); } [Test] Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/GrassCoverErosionInwardsCalculationConfigurationReaderTest.cs =================================================================== diff -u -r8336ede0837d35257e8b85c3b0090b0774342d90 -rb1fd20384e0835b604bb68d94e16e8ead46ed93e --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/GrassCoverErosionInwardsCalculationConfigurationReaderTest.cs (.../GrassCoverErosionInwardsCalculationConfigurationReaderTest.cs) (revision 8336ede0837d35257e8b85c3b0090b0774342d90) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/GrassCoverErosionInwardsCalculationConfigurationReaderTest.cs (.../GrassCoverErosionInwardsCalculationConfigurationReaderTest.cs) (revision b1fd20384e0835b604bb68d94e16e8ead46ed93e) @@ -198,7 +198,7 @@ var reader = new GrassCoverErosionInwardsCalculationConfigurationReader(filePath); // Assert - Assert.IsInstanceOf>(reader); + Assert.IsInstanceOf>(reader); } [Test] @@ -214,7 +214,7 @@ // Assert Assert.AreEqual(1, readConfigurationItems.Count); - var calculation = readConfigurationItems[0] as ReadGrassCoverErosionInwardsCalculation; + var calculation = readConfigurationItems[0] as GrassCoverErosionInwardsCalculationConfiguration; Assert.IsNotNull(calculation); Assert.AreEqual("Calculation", calculation.Name); Assert.IsNull(calculation.HydraulicBoundaryLocation); @@ -223,12 +223,8 @@ Assert.IsNull(calculation.DikeHeight); Assert.IsNull(calculation.DikeHeightCalculationType); Assert.IsNull(calculation.OvertoppingRateCalculationType); - Assert.IsNull(calculation.UseBreakWater); - Assert.IsNull(calculation.BreakWaterType); - Assert.IsNull(calculation.BreakWaterHeight); - Assert.IsNull(calculation.UseForeshore); - Assert.IsNull(calculation.CriticalFlowRateMean); - Assert.IsNull(calculation.CriticalFlowRateStandardDeviation); + Assert.IsNull(calculation.WaveReduction); + Assert.IsNull(calculation.CriticalFlowRate); } [Test] @@ -244,10 +240,9 @@ // Assert Assert.AreEqual(1, readConfigurationItems.Count); - var calculation = readConfigurationItems[0] as ReadGrassCoverErosionInwardsCalculation; + var calculation = readConfigurationItems[0] as GrassCoverErosionInwardsCalculationConfiguration; Assert.IsNotNull(calculation); - Assert.IsNull(calculation.CriticalFlowRateMean); - Assert.IsNull(calculation.CriticalFlowRateStandardDeviation); + Assert.IsNull(calculation.CriticalFlowRate); } [Test] @@ -263,13 +258,13 @@ // Assert Assert.AreEqual(1, readConfigurationItems.Count); - var calculation = readConfigurationItems[0] as ReadGrassCoverErosionInwardsCalculation; + var calculation = readConfigurationItems[0] as GrassCoverErosionInwardsCalculationConfiguration; Assert.IsNotNull(calculation); Assert.IsNaN(calculation.Orientation); Assert.IsNaN(calculation.DikeHeight); - Assert.IsNaN(calculation.BreakWaterHeight); - Assert.IsNaN(calculation.CriticalFlowRateMean); - Assert.IsNaN(calculation.CriticalFlowRateStandardDeviation); + Assert.IsNaN(calculation.WaveReduction.BreakWaterHeight); + Assert.IsNaN(calculation.CriticalFlowRate.Mean); + Assert.IsNaN(calculation.CriticalFlowRate.StandardDeviation); } [Test] @@ -285,20 +280,20 @@ // Assert Assert.AreEqual(1, readConfigurationItems.Count); - var calculation = readConfigurationItems[0] as ReadGrassCoverErosionInwardsCalculation; + var calculation = readConfigurationItems[0] as GrassCoverErosionInwardsCalculationConfiguration; Assert.IsNotNull(calculation); Assert.IsNotNull(calculation.Orientation); Assert.IsNotNull(calculation.DikeHeight); - Assert.IsNotNull(calculation.BreakWaterHeight); - Assert.IsNotNull(calculation.CriticalFlowRateMean); - Assert.IsNotNull(calculation.CriticalFlowRateStandardDeviation); + Assert.IsNotNull(calculation.WaveReduction.BreakWaterHeight); + Assert.IsNotNull(calculation.CriticalFlowRate.Mean); + Assert.IsNotNull(calculation.CriticalFlowRate.StandardDeviation); Assert.IsTrue(double.IsPositiveInfinity(calculation.Orientation.Value)); Assert.IsTrue(double.IsNegativeInfinity(calculation.DikeHeight.Value)); - Assert.IsTrue(double.IsNegativeInfinity(calculation.BreakWaterHeight.Value)); - Assert.IsTrue(double.IsPositiveInfinity(calculation.CriticalFlowRateMean.Value)); - Assert.IsTrue(double.IsPositiveInfinity(calculation.CriticalFlowRateStandardDeviation.Value)); + Assert.IsTrue(double.IsNegativeInfinity(calculation.WaveReduction.BreakWaterHeight.Value)); + Assert.IsTrue(double.IsPositiveInfinity(calculation.CriticalFlowRate.Mean.Value)); + Assert.IsTrue(double.IsPositiveInfinity(calculation.CriticalFlowRate.StandardDeviation.Value)); } [Test] @@ -318,7 +313,7 @@ // Assert Assert.AreEqual(1, readConfigurationItems.Count); - var calculation = readConfigurationItems[0] as ReadGrassCoverErosionInwardsCalculation; + var calculation = readConfigurationItems[0] as GrassCoverErosionInwardsCalculationConfiguration; Assert.IsNotNull(calculation); Assert.AreEqual("Berekening 1", calculation.Name); Assert.AreEqual("Some_hydraulic_boundary_location", calculation.HydraulicBoundaryLocation); @@ -327,12 +322,12 @@ Assert.AreEqual(3.45, calculation.DikeHeight); Assert.AreEqual(ConfigurationHydraulicLoadsCalculationType.CalculateByAssessmentSectionNorm, calculation.DikeHeightCalculationType); Assert.AreEqual(ConfigurationHydraulicLoadsCalculationType.CalculateByProfileSpecificRequiredProbability, calculation.OvertoppingRateCalculationType); - Assert.AreEqual(true, calculation.UseBreakWater); - Assert.AreEqual(ConfigurationBreakWaterType.Dam, calculation.BreakWaterType); - Assert.AreEqual(1.234, calculation.BreakWaterHeight); - Assert.AreEqual(false, calculation.UseForeshore); - Assert.AreEqual(0.1, calculation.CriticalFlowRateMean); - Assert.AreEqual(0.2, calculation.CriticalFlowRateStandardDeviation); + Assert.AreEqual(true, calculation.WaveReduction.UseBreakWater); + Assert.AreEqual(ConfigurationBreakWaterType.Dam, calculation.WaveReduction.BreakWaterType); + Assert.AreEqual(1.234, calculation.WaveReduction.BreakWaterHeight); + Assert.AreEqual(false, calculation.WaveReduction.UseForeshoreProfile); + Assert.AreEqual(0.1, calculation.CriticalFlowRate.Mean); + Assert.AreEqual(0.2, calculation.CriticalFlowRate.StandardDeviation); } [Test] @@ -348,7 +343,7 @@ // Assert Assert.AreEqual(1, readConfigurationItems.Count); - var calculation = readConfigurationItems[0] as ReadGrassCoverErosionInwardsCalculation; + var calculation = readConfigurationItems[0] as GrassCoverErosionInwardsCalculationConfiguration; Assert.IsNotNull(calculation); Assert.AreEqual("Partial calculation 2", calculation.Name); Assert.IsNull(calculation.HydraulicBoundaryLocation); @@ -357,12 +352,11 @@ Assert.AreEqual(-1.2, calculation.DikeHeight); Assert.IsNull(calculation.DikeHeightCalculationType); Assert.IsNull(calculation.OvertoppingRateCalculationType); - Assert.AreEqual(false, calculation.UseBreakWater); - Assert.IsNull(calculation.BreakWaterType); - Assert.AreEqual(3.4, calculation.BreakWaterHeight); - Assert.IsNull(calculation.UseForeshore); - Assert.IsNull(calculation.CriticalFlowRateMean); - Assert.IsNull(calculation.CriticalFlowRateStandardDeviation); + Assert.AreEqual(false, calculation.WaveReduction.UseBreakWater); + Assert.IsNull(calculation.WaveReduction.BreakWaterType); + Assert.AreEqual(3.4, calculation.WaveReduction.BreakWaterHeight); + Assert.IsNull(calculation.WaveReduction.UseForeshoreProfile); + Assert.IsNull(calculation.CriticalFlowRate); } [Test] @@ -378,10 +372,10 @@ // Assert Assert.AreEqual(1, readConfigurationItems.Count); - var calculation = readConfigurationItems[0] as ReadGrassCoverErosionInwardsCalculation; + var calculation = readConfigurationItems[0] as GrassCoverErosionInwardsCalculationConfiguration; Assert.IsNotNull(calculation); - Assert.IsNull(calculation.CriticalFlowRateMean); - Assert.AreEqual(2.2, calculation.CriticalFlowRateStandardDeviation); + Assert.IsNull(calculation.CriticalFlowRate.Mean); + Assert.AreEqual(2.2, calculation.CriticalFlowRate.StandardDeviation); } [Test] @@ -397,10 +391,10 @@ // Assert Assert.AreEqual(1, readConfigurationItems.Count); - var calculation = readConfigurationItems[0] as ReadGrassCoverErosionInwardsCalculation; + var calculation = readConfigurationItems[0] as GrassCoverErosionInwardsCalculationConfiguration; Assert.IsNotNull(calculation); - Assert.AreEqual(1.1, calculation.CriticalFlowRateMean); - Assert.IsNull(calculation.CriticalFlowRateStandardDeviation); + Assert.AreEqual(1.1, calculation.CriticalFlowRate.Mean); + Assert.IsNull(calculation.CriticalFlowRate.StandardDeviation); } [Test] @@ -416,10 +410,10 @@ // Assert Assert.AreEqual(1, readConfigurationItems.Count); - var calculation = readConfigurationItems[0] as ReadGrassCoverErosionInwardsCalculation; + var calculation = readConfigurationItems[0] as GrassCoverErosionInwardsCalculationConfiguration; Assert.IsNotNull(calculation); - Assert.IsNull(calculation.CriticalFlowRateMean); - Assert.IsNull(calculation.CriticalFlowRateStandardDeviation); + Assert.IsNull(calculation.CriticalFlowRate.Mean); + Assert.IsNull(calculation.CriticalFlowRate.StandardDeviation); } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/GrassCoverErosionInwardsCalculationConfigurationTest.cs =================================================================== diff -u -r8336ede0837d35257e8b85c3b0090b0774342d90 -rb1fd20384e0835b604bb68d94e16e8ead46ed93e --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/GrassCoverErosionInwardsCalculationConfigurationTest.cs (.../GrassCoverErosionInwardsCalculationConfigurationTest.cs) (revision 8336ede0837d35257e8b85c3b0090b0774342d90) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/GrassCoverErosionInwardsCalculationConfigurationTest.cs (.../GrassCoverErosionInwardsCalculationConfigurationTest.cs) (revision b1fd20384e0835b604bb68d94e16e8ead46ed93e) @@ -33,35 +33,32 @@ public void Constructor_WithoutConstructionProperties_ThrowsArgumentNullException() { // Call - TestDelegate test = () => new ReadGrassCoverErosionInwardsCalculation(null); + TestDelegate test = () => new GrassCoverErosionInwardsCalculationConfiguration(null); // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("constructionProperties", paramName); + Assert.Throws(test); } [Test] public void Constructor_ConstructionPropertiesWithoutValues_PropertiesAreDefault() { + // Setup + const string name = "name"; + // Call - var constructionProperties = new ReadGrassCoverErosionInwardsCalculation.ConstructionProperties(); - var readCalculation = new ReadGrassCoverErosionInwardsCalculation(constructionProperties); + var readCalculation = new GrassCoverErosionInwardsCalculationConfiguration(name); // Assert Assert.IsInstanceOf(readCalculation); - Assert.IsNull(readCalculation.Name); + Assert.AreEqual(name, readCalculation.Name); Assert.IsNull(readCalculation.HydraulicBoundaryLocation); Assert.IsNull(readCalculation.DikeProfileId); Assert.IsNull(readCalculation.Orientation); Assert.IsNull(readCalculation.DikeHeight); Assert.IsNull(readCalculation.DikeHeightCalculationType); Assert.IsNull(readCalculation.OvertoppingRateCalculationType); - Assert.IsNull(readCalculation.UseBreakWater); - Assert.IsNull(readCalculation.BreakWaterType); - Assert.IsNull(readCalculation.BreakWaterHeight); - Assert.IsNull(readCalculation.UseForeshore); - Assert.IsNull(readCalculation.CriticalFlowRateMean); - Assert.IsNull(readCalculation.CriticalFlowRateStandardDeviation); + Assert.IsNull(readCalculation.WaveReduction); + Assert.IsNull(readCalculation.CriticalFlowRate); } [Test] @@ -82,7 +79,8 @@ const double criticalFlowMean = 4.4; const double critifalFlowStandardDeviation = 5.5; - var constructionProperties = new ReadGrassCoverErosionInwardsCalculation.ConstructionProperties + // Call + var readCalculation = new GrassCoverErosionInwardsCalculationConfiguration(calculationName) { Name = calculationName, HydraulicBoundaryLocation = hydraulicBoundaryLocationName, @@ -91,31 +89,34 @@ DikeHeight = dikeHeight, DikeHeightCalculationType = dikeHeightCalculationType, OvertoppingRateCalculationType = overtoppingRateCalculationType, - UseBreakWater = useBreakWater, - BreakWaterType = breakWaterType, - BreakWaterHeight = breakWaterHeight, - UseForeshore = useForeshore, - CriticalFlowRateMean = criticalFlowMean, - CriticalFlowRateStandardDeviation = critifalFlowStandardDeviation + WaveReduction = new WaveReductionConfiguration + { + UseBreakWater = useBreakWater, + BreakWaterType = breakWaterType, + BreakWaterHeight = breakWaterHeight, + UseForeshoreProfile = useForeshore + }, + CriticalFlowRate = new StochastConfiguration + { + Mean = criticalFlowMean, + StandardDeviation = critifalFlowStandardDeviation + } }; - // Call - var readCalculation = new ReadGrassCoverErosionInwardsCalculation(constructionProperties); - // Assert Assert.AreEqual(calculationName, readCalculation.Name); Assert.AreEqual(hydraulicBoundaryLocationName, readCalculation.HydraulicBoundaryLocation); - Assert.AreEqual(dikeProfileId, constructionProperties.DikeProfileId); + Assert.AreEqual(dikeProfileId, readCalculation.DikeProfileId); Assert.AreEqual(orientation, readCalculation.Orientation); Assert.AreEqual(dikeHeight, readCalculation.DikeHeight); Assert.AreEqual(dikeHeightCalculationType, readCalculation.DikeHeightCalculationType); Assert.AreEqual(overtoppingRateCalculationType, readCalculation.OvertoppingRateCalculationType); - Assert.AreEqual(useBreakWater, readCalculation.UseBreakWater); - Assert.AreEqual(breakWaterType, readCalculation.BreakWaterType); - Assert.AreEqual(breakWaterHeight, readCalculation.BreakWaterHeight); - Assert.AreEqual(useForeshore, readCalculation.UseForeshore); - Assert.AreEqual(criticalFlowMean, readCalculation.CriticalFlowRateMean); - Assert.AreEqual(critifalFlowStandardDeviation, readCalculation.CriticalFlowRateStandardDeviation); + Assert.AreEqual(useBreakWater, readCalculation.WaveReduction.UseBreakWater); + Assert.AreEqual(breakWaterType, readCalculation.WaveReduction.BreakWaterType); + Assert.AreEqual(breakWaterHeight, readCalculation.WaveReduction.BreakWaterHeight); + Assert.AreEqual(useForeshore, readCalculation.WaveReduction.UseForeshoreProfile); + Assert.AreEqual(criticalFlowMean, readCalculation.CriticalFlowRate.Mean); + Assert.AreEqual(critifalFlowStandardDeviation, readCalculation.CriticalFlowRate.StandardDeviation); } } } \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Configurations/HeightStructuresCalculationConfigurationReader.cs =================================================================== diff -u -r9f8c8ff1cd49a1764ff3dde12eea6be35d9c34a7 -rb1fd20384e0835b604bb68d94e16e8ead46ed93e --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Configurations/HeightStructuresCalculationConfigurationReader.cs (.../HeightStructuresCalculationConfigurationReader.cs) (revision 9f8c8ff1cd49a1764ff3dde12eea6be35d9c34a7) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Configurations/HeightStructuresCalculationConfigurationReader.cs (.../HeightStructuresCalculationConfigurationReader.cs) (revision b1fd20384e0835b604bb68d94e16e8ead46ed93e) @@ -92,43 +92,25 @@ protected override HeightStructuresCalculationConfiguration ParseCalculationElement(XElement calculationElement) { - var configuration = new HeightStructuresCalculationConfiguration(calculationElement.Attribute(ConfigurationSchemaIdentifiers.NameAttribute).Value); - configuration.FailureProbabilityStructureWithErosion = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.FailureProbabilityStructureWithErosionElement); - configuration.StructureNormalOrientation = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.Orientation); + var configuration = new HeightStructuresCalculationConfiguration(calculationElement.Attribute(ConfigurationSchemaIdentifiers.NameAttribute).Value) + { + FailureProbabilityStructureWithErosion = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.FailureProbabilityStructureWithErosionElement), + StructureNormalOrientation = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.Orientation), + ForeshoreProfileId = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.ForeshoreProfileNameElement), + HydraulicBoundaryLocationName = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement), + StructureId = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.StructureElement), + WaveReduction = calculationElement.GetWaveReductionParameters(), + LevelCrestStructure = calculationElement.GetStochastConfiguration(HeightStructuresConfigurationSchemaIdentifiers.LevelCrestStructureStochastName), + AllowedLevelIncreaseStorage = calculationElement.GetStochastConfiguration(ConfigurationSchemaIdentifiers.AllowedLevelIncreaseStorageStochastName), + FlowWidthAtBottomProtection = calculationElement.GetStochastConfiguration(ConfigurationSchemaIdentifiers.FlowWidthAtBottomProtectionStochastName), + ModelFactorSuperCriticalFlow = calculationElement.GetStochastConfiguration(ConfigurationSchemaIdentifiers.ModelFactorSuperCriticalFlowStochastName), + WidthFlowApertures = calculationElement.GetStochastConfiguration(ConfigurationSchemaIdentifiers.WidthFlowAperturesStochastName), + CriticalOvertoppingDischarge = calculationElement.GetStochastConfiguration(ConfigurationSchemaIdentifiers.CriticalOvertoppingDischargeStochastName), + StorageStructureArea = calculationElement.GetStochastConfiguration(ConfigurationSchemaIdentifiers.StorageStructureAreaStochastName), + StormDuration = calculationElement.GetStochastConfiguration(ConfigurationSchemaIdentifiers.StormDurationStochastName) + }; - configuration.ForeshoreProfileId = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.ForeshoreProfileNameElement); - configuration.HydraulicBoundaryLocationName = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement); - configuration.StructureId = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.StructureElement); - - configuration.WaveReduction = GetWaveReductionParameters(calculationElement); - - configuration.LevelCrestStructure = calculationElement.GetStochastConfiguration(HeightStructuresConfigurationSchemaIdentifiers.LevelCrestStructureStochastName); - configuration.AllowedLevelIncreaseStorage = calculationElement.GetStochastConfiguration(ConfigurationSchemaIdentifiers.AllowedLevelIncreaseStorageStochastName); - configuration.FlowWidthAtBottomProtection = calculationElement.GetStochastConfiguration(ConfigurationSchemaIdentifiers.FlowWidthAtBottomProtectionStochastName); - configuration.ModelFactorSuperCriticalFlow = calculationElement.GetStochastConfiguration(ConfigurationSchemaIdentifiers.ModelFactorSuperCriticalFlowStochastName); - configuration.WidthFlowApertures = calculationElement.GetStochastConfiguration(ConfigurationSchemaIdentifiers.WidthFlowAperturesStochastName); - - configuration.CriticalOvertoppingDischarge = calculationElement.GetStochastConfiguration(ConfigurationSchemaIdentifiers.CriticalOvertoppingDischargeStochastName); - configuration.StorageStructureArea = calculationElement.GetStochastConfiguration(ConfigurationSchemaIdentifiers.StorageStructureAreaStochastName); - configuration.StormDuration = calculationElement.GetStochastConfiguration(ConfigurationSchemaIdentifiers.StormDurationStochastName); - return configuration; } - - private static WaveReductionConfiguration GetWaveReductionParameters(XElement calculationElement) - { - XElement waveReduction = calculationElement.GetDescendantElement(ConfigurationSchemaIdentifiers.WaveReduction); - if (waveReduction != null) - { - return new WaveReductionConfiguration - { - BreakWaterType = (ConfigurationBreakWaterType?) calculationElement.GetConvertedValueFromDescendantStringElement(ConfigurationSchemaIdentifiers.BreakWaterType), - BreakWaterHeight = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.BreakWaterHeight), - UseBreakWater = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseBreakWater), - UseForeshoreProfile = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseForeshore) - }; - } - return null; - } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationTest.cs =================================================================== diff -u -r756064ca162892256021ac1616fe4680b2bba320 -rb1fd20384e0835b604bb68d94e16e8ead46ed93e --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationTest.cs (.../PipingCalculationConfigurationTest.cs) (revision 756064ca162892256021ac1616fe4680b2bba320) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationTest.cs (.../PipingCalculationConfigurationTest.cs) (revision b1fd20384e0835b604bb68d94e16e8ead46ed93e) @@ -30,7 +30,7 @@ public class PipingCalculationConfigurationTest { [Test] - public void Constructor_WithoutConstructionProperties_ThrowsArgumentNullException() + public void Constructor_WithoutName_ThrowsArgumentNullException() { // Call TestDelegate test = () => new PipingCalculationConfiguration(null); @@ -40,7 +40,7 @@ } [Test] - public void Constructor_ConstructionPropertiesWithoutValues_PropertiesAreDefault() + public void Constructor_WithName_PropertiesAreDefault() { // Setup const string name = "some name"; @@ -63,7 +63,7 @@ } [Test] - public void Constructor_ConstructionPropertiesWithValuesSet_PropertiesAsExpected() + public void Constructor_WithNameAndProperties_PropertiesAsExpected() { // Setup const string calculationName = "Name of the calculation"; Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Configurations/StabilityPointStructuresCalculationConfigurationReader.cs =================================================================== diff -u -r9f8c8ff1cd49a1764ff3dde12eea6be35d9c34a7 -rb1fd20384e0835b604bb68d94e16e8ead46ed93e --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Configurations/StabilityPointStructuresCalculationConfigurationReader.cs (.../StabilityPointStructuresCalculationConfigurationReader.cs) (revision 9f8c8ff1cd49a1764ff3dde12eea6be35d9c34a7) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Configurations/StabilityPointStructuresCalculationConfigurationReader.cs (.../StabilityPointStructuresCalculationConfigurationReader.cs) (revision b1fd20384e0835b604bb68d94e16e8ead46ed93e) @@ -135,25 +135,9 @@ ThresholdHeightOpenWeir = calculationElement.GetStochastConfiguration(StabilityPointStructuresConfigurationSchemaIdentifiers.ThresholdHeightOpenWeirStochastName), VerticalDistance = calculationElement.GetDoubleValueFromDescendantElement(StabilityPointStructuresConfigurationSchemaIdentifiers.VerticalDistanceElement), VolumicWeightWater = calculationElement.GetDoubleValueFromDescendantElement(StabilityPointStructuresConfigurationSchemaIdentifiers.VolumicWeightWaterElement), - WaveReduction = GetWaveReductionParameters(calculationElement), + WaveReduction = calculationElement.GetWaveReductionParameters(), WidthFlowApertures = calculationElement.GetStochastConfiguration(ConfigurationSchemaIdentifiers.WidthFlowAperturesStochastName) }; } - - private static WaveReductionConfiguration GetWaveReductionParameters(XElement calculationElement) - { - XElement waveReduction = calculationElement.GetDescendantElement(ConfigurationSchemaIdentifiers.WaveReduction); - if (waveReduction != null) - { - return new WaveReductionConfiguration - { - BreakWaterType = (ConfigurationBreakWaterType?) calculationElement.GetConvertedValueFromDescendantStringElement(ConfigurationSchemaIdentifiers.BreakWaterType), - BreakWaterHeight = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.BreakWaterHeight), - UseBreakWater = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseBreakWater), - UseForeshoreProfile = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseForeshore) - }; - } - return null; - } } } \ No newline at end of file