Index: Ringtoets/Common/src/Ringtoets.Common.IO/Readers/ConfigurationReaderHelper.cs
===================================================================
diff -u -r78e404373f030f9fef45733c2f6c560d6ea58b21 -rdc37877b917879d9c7b63ff1fb4552bff4943c66
--- Ringtoets/Common/src/Ringtoets.Common.IO/Readers/ConfigurationReaderHelper.cs (.../ConfigurationReaderHelper.cs) (revision 78e404373f030f9fef45733c2f6c560d6ea58b21)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Readers/ConfigurationReaderHelper.cs (.../ConfigurationReaderHelper.cs) (revision dc37877b917879d9c7b63ff1fb4552bff4943c66)
@@ -32,58 +32,75 @@
public static class ConfigurationReaderHelper
{
///
- /// Gets the double value from a child element.
+ /// Gets the double value from a descendant element.
///
- /// The that contains the child element.
- /// The name of the child element.
+ /// The that contains the descendant element.
+ /// The name of the descendant element.
/// The value of the element, or null when the
- /// does not have child elements of .
+ /// does not have descendant elements of .
/// Thrown when any parameter is null.
- public static double? GetDoubleValueFromChildElement(XElement parentElement, string childElementName)
+ public static double? GetDoubleValueFromDescendantElement(XElement parentElement, string descendantElementName)
{
if (parentElement == null)
{
throw new ArgumentNullException(nameof(parentElement));
}
- if (childElementName == null)
+ if (descendantElementName == null)
{
- throw new ArgumentNullException(nameof(childElementName));
+ throw new ArgumentNullException(nameof(descendantElementName));
}
- XElement childElement = GetChildElement(parentElement, childElementName);
+ XElement descendantElement = GetDescendantElement(parentElement, descendantElementName);
- return childElement != null
- ? (double?) XmlConvert.ToDouble(childElement.Value)
+ return descendantElement != null
+ ? (double?) XmlConvert.ToDouble(descendantElement.Value)
: null;
}
///
- /// Gets the string value from a child element.
+ /// Gets the string value from a descendant element.
///
- /// The that contains the child element.
- /// The name of the child element.
+ /// The that contains the descendant element.
+ /// The name of the descendant element.
/// The value of the element, or null when the
- /// does not have child elements of .
+ /// does not have descendant elements of .
/// Thrown when any parameter is null.
- public static string GetStringValueFromChildElement(XElement parentElement, string childElementName)
+ public static string GetStringValueFromDescendantElement(XElement parentElement, string descendantElementName)
{
if (parentElement == null)
{
throw new ArgumentNullException(nameof(parentElement));
}
- if (childElementName == null)
+ if (descendantElementName == null)
{
- throw new ArgumentNullException(nameof(childElementName));
+ throw new ArgumentNullException(nameof(descendantElementName));
}
- XElement childElement = GetChildElement(parentElement, childElementName);
+ XElement descendantElement = GetDescendantElement(parentElement, descendantElementName);
- return childElement?.Value;
+ return descendantElement?.Value;
}
- private static XElement GetChildElement(XElement parentElement, string childElementName)
+ ///
+ /// Gets a descendant element with the given .
+ ///
+ /// The that contains the descendant element.
+ /// The name of the descendant element.
+ /// The element, or null when the
+ /// does not have descendant elements of .
+ /// Thrown when any parameter is null.
+ public static XElement GetDescendantElement(XElement parentElement, string descendantElementName)
{
- return parentElement.Elements(childElementName).FirstOrDefault();
+ if (parentElement == null)
+ {
+ throw new ArgumentNullException(nameof(parentElement));
+ }
+ if (descendantElementName == null)
+ {
+ throw new ArgumentNullException(nameof(descendantElementName));
+ }
+
+ return parentElement.Descendants(descendantElementName).FirstOrDefault();
}
}
}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/ConfigurationReaderHelperTest.cs
===================================================================
diff -u -r78e404373f030f9fef45733c2f6c560d6ea58b21 -rdc37877b917879d9c7b63ff1fb4552bff4943c66
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/ConfigurationReaderHelperTest.cs (.../ConfigurationReaderHelperTest.cs) (revision 78e404373f030f9fef45733c2f6c560d6ea58b21)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/ConfigurationReaderHelperTest.cs (.../ConfigurationReaderHelperTest.cs) (revision dc37877b917879d9c7b63ff1fb4552bff4943c66)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
using System.Xml.Linq;
using NUnit.Framework;
using Ringtoets.Common.IO.Readers;
@@ -30,105 +31,161 @@
public class ConfigurationReaderHelperTest
{
[Test]
- public void GetDoubleValueFromChildElement_ParentElementNull_ThrowArgumentNullException()
+ public void GetDoubleValueFromDescendantElement_ParentElementNull_ThrowArgumentNullException()
{
// Call
- TestDelegate test = () => ConfigurationReaderHelper.GetDoubleValueFromChildElement(null, "");
+ TestDelegate test = () => ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(null, "");
// Assert
var exception = Assert.Throws(test);
Assert.AreEqual("parentElement", exception.ParamName);
}
[Test]
- public void GetDoubleValueFromChildElement_ChildElementNameNull_ThrowArgumentNullException()
+ public void GetDoubleValueFromDescendantElement_DescendantElementNameNull_ThrowArgumentNullException()
{
// Call
- TestDelegate test = () => ConfigurationReaderHelper.GetDoubleValueFromChildElement(new XElement("Root"), null);
+ TestDelegate test = () => ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(new XElement("Root"), null);
// Assert
var exception = Assert.Throws(test);
- Assert.AreEqual("childElementName", exception.ParamName);
+ Assert.AreEqual("descendantElementName", exception.ParamName);
}
[Test]
- public void GetDoubleValueFromChildElement_ValidChildElement_ReturnValue()
+ public void GetDoubleValueFromDescendantElement_ValidDescendantElement_ReturnValue()
{
// Setup
- const string childElementName = "number";
- const double childElementValue = 3;
+ const string descendantElementName = "number";
+ const double descendantElementValue = 3;
- var element = new XElement("Root", new XElement(childElementName, childElementValue));
+ var element = new XElement("Root", new XElement(descendantElementName, descendantElementValue));
// Call
- double? readValue = ConfigurationReaderHelper.GetDoubleValueFromChildElement(element, childElementName);
+ double? readValue = ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(element, descendantElementName);
// Assert
- Assert.AreEqual(childElementValue, readValue.Value);
+ Assert.AreEqual(descendantElementValue, readValue.Value);
}
[Test]
- public void GetDoubleValueFromChildElement_InvalidChildElement_ReturnNull()
+ public void GetDoubleValueFromDescendantElement_InvalidDescendantElement_ReturnNull()
{
// Setup
var element = new XElement("Root", new XElement("number", (double) 3));
// Call
- double? readValue = ConfigurationReaderHelper.GetDoubleValueFromChildElement(element, "invalidName");
+ double? readValue = ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(element, "invalidName");
// Assert
Assert.IsNull(readValue);
}
[Test]
- public void GetStringValueFromChildElement_ParentElementNull_ThrowArgumentNullException()
+ public void GetStringValueFromDescendantElement_ParentElementNull_ThrowArgumentNullException()
{
// Call
- TestDelegate test = () => ConfigurationReaderHelper.GetStringValueFromChildElement(null, "");
+ TestDelegate test = () => ConfigurationReaderHelper.GetStringValueFromDescendantElement(null, "");
// Assert
var exception = Assert.Throws(test);
Assert.AreEqual("parentElement", exception.ParamName);
}
[Test]
- public void GetStringValueFromChildElement_ChildElementNameNull_ThrowArgumentNullException()
+ public void GetStringValueFromDescendantElement_DescendantElementNameNull_ThrowArgumentNullException()
{
// Call
- TestDelegate test = () => ConfigurationReaderHelper.GetStringValueFromChildElement(new XElement("Test"), null);
+ TestDelegate test = () => ConfigurationReaderHelper.GetStringValueFromDescendantElement(new XElement("Test"), null);
// Assert
var exception = Assert.Throws(test);
- Assert.AreEqual("childElementName", exception.ParamName);
+ Assert.AreEqual("descendantElementName", exception.ParamName);
}
[Test]
- public void GetStringValueFromChildElement_ValidChildElement_ReturnValue()
+ public void GetStringValueFromDescendantElement_ValidDescendantElement_ReturnValue()
{
// Setup
- const string childElementName = "text";
- const string childElementValue = "valueText";
+ const string descendantElementName = "text";
+ const string descendantElementValue = "valueText";
- var element = new XElement("Root", new XElement(childElementName, childElementValue));
+ var element = new XElement("Root", new XElement(descendantElementName, descendantElementValue));
// Call
- string readValue = ConfigurationReaderHelper.GetStringValueFromChildElement(element, childElementName);
+ string readValue = ConfigurationReaderHelper.GetStringValueFromDescendantElement(element, descendantElementName);
// Assert
- Assert.AreEqual(childElementValue, readValue);
+ Assert.AreEqual(descendantElementValue, readValue);
}
[Test]
- public void GetStringValueFromChildElement_InvalidChildElement_ReturnNull()
+ public void GetStringValueFromDescendantElement_InvalidDescendantElement_ReturnNull()
{
// Setup
var element = new XElement("Root", new XElement("number", "valueText"));
// Call
- string readValue = ConfigurationReaderHelper.GetStringValueFromChildElement(element, "invalidName");
+ string readValue = ConfigurationReaderHelper.GetStringValueFromDescendantElement(element, "invalidName");
// Assert
Assert.IsNull(readValue);
}
+
+ [Test]
+ public void GetDescendantElement_ParentElementNull_ThrowArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => ConfigurationReaderHelper.GetDescendantElement(null, "");
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("parentElement", exception.ParamName);
+ }
+
+ [Test]
+ public void GetDescendantElement_DescendantElementNameNull_ThrowArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => ConfigurationReaderHelper.GetDescendantElement(new XElement("Test"), null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("descendantElementName", exception.ParamName);
+ }
+
+ [Test]
+ [TestCaseSource(nameof(XElements))]
+ public void GetDescendantElement_ValidDescendantName_ReturnElement(XElement parentElement)
+ {
+ // Call
+ XElement element = ConfigurationReaderHelper.GetDescendantElement(parentElement, "descendant");
+
+ // Assert
+ Assert.IsNotNull(element);
+ Assert.AreEqual("descendant", element.Name.LocalName);
+ }
+
+ [Test]
+ public void GetDescendantElement_InvalidDescendantName_ReturnNull()
+ {
+ // Setup
+ var parentElement = new XElement("Root", new XElement("Child", new XElement("descendant")));
+
+ // Call
+ XElement element = ConfigurationReaderHelper.GetDescendantElement(parentElement, "something_else");
+
+ // Assert
+ Assert.IsNull(element);
+ }
+
+ private static IEnumerable XElements
+ {
+ get
+ {
+ yield return new TestCaseData(new XElement("Root", new XElement("descendant")));
+ yield return new TestCaseData(new XElement("Root", new XElement("Child", new XElement("descendant"))));
+ }
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingConfigurationReader.cs
===================================================================
diff -u -r78e404373f030f9fef45733c2f6c560d6ea58b21 -rdc37877b917879d9c7b63ff1fb4552bff4943c66
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingConfigurationReader.cs (.../PipingConfigurationReader.cs) (revision 78e404373f030f9fef45733c2f6c560d6ea58b21)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingConfigurationReader.cs (.../PipingConfigurationReader.cs) (revision dc37877b917879d9c7b63ff1fb4552bff4943c66)
@@ -72,37 +72,37 @@
var constructionProperties = new ReadPipingCalculation.ConstructionProperties
{
Name = calculationElement.Attribute(ConfigurationSchemaIdentifiers.NameAttribute)?.Value,
- AssessmentLevel = ConfigurationReaderHelper.GetDoubleValueFromChildElement(calculationElement,
+ AssessmentLevel = ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(calculationElement,
PipingConfigurationSchemaIdentifiers.AssessmentLevelElement),
- HydraulicBoundaryLocation = ConfigurationReaderHelper.GetStringValueFromChildElement(calculationElement,
+ HydraulicBoundaryLocation = ConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement,
ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement),
- SurfaceLine = ConfigurationReaderHelper.GetStringValueFromChildElement(calculationElement,
+ SurfaceLine = ConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement,
PipingConfigurationSchemaIdentifiers.SurfaceLineElement),
- EntryPointL = ConfigurationReaderHelper.GetDoubleValueFromChildElement(calculationElement,
+ EntryPointL = ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(calculationElement,
PipingConfigurationSchemaIdentifiers.EntryPointLElement),
- ExitPointL = ConfigurationReaderHelper.GetDoubleValueFromChildElement(calculationElement,
+ ExitPointL = ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(calculationElement,
PipingConfigurationSchemaIdentifiers.ExitPointLElement),
- StochasticSoilModel = ConfigurationReaderHelper.GetStringValueFromChildElement(calculationElement,
+ StochasticSoilModel = ConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement,
PipingConfigurationSchemaIdentifiers.StochasticSoilModelElement),
- StochasticSoilProfile = ConfigurationReaderHelper.GetStringValueFromChildElement(calculationElement,
+ StochasticSoilProfile = ConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement,
PipingConfigurationSchemaIdentifiers.StochasticSoilProfileElement)
};
XElement phreaticLevelExitElement = GetStochastChildElement(calculationElement, PipingConfigurationSchemaIdentifiers.PhreaticLevelExitStochastName);
if (phreaticLevelExitElement != null)
{
- constructionProperties.PhreaticLevelExitMean = ConfigurationReaderHelper.GetDoubleValueFromChildElement(phreaticLevelExitElement,
+ constructionProperties.PhreaticLevelExitMean = ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(phreaticLevelExitElement,
ConfigurationSchemaIdentifiers.MeanElement);
- constructionProperties.PhreaticLevelExitStandardDeviation = ConfigurationReaderHelper.GetDoubleValueFromChildElement(phreaticLevelExitElement,
+ constructionProperties.PhreaticLevelExitStandardDeviation = ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(phreaticLevelExitElement,
ConfigurationSchemaIdentifiers.StandardDeviationElement);
}
XElement dampingFactorExitElement = GetStochastChildElement(calculationElement, PipingConfigurationSchemaIdentifiers.DampingFactorExitStochastName);
if (dampingFactorExitElement != null)
{
- constructionProperties.DampingFactorExitMean = ConfigurationReaderHelper.GetDoubleValueFromChildElement(dampingFactorExitElement,
+ constructionProperties.DampingFactorExitMean = ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(dampingFactorExitElement,
ConfigurationSchemaIdentifiers.MeanElement);
- constructionProperties.DampingFactorExitStandardDeviation = ConfigurationReaderHelper.GetDoubleValueFromChildElement(dampingFactorExitElement,
+ constructionProperties.DampingFactorExitStandardDeviation = ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(dampingFactorExitElement,
ConfigurationSchemaIdentifiers.StandardDeviationElement);
}
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/ReadBreakWaterType.cs
===================================================================
diff -u
--- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/ReadBreakWaterType.cs (revision 0)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/ReadBreakWaterType.cs (revision dc37877b917879d9c7b63ff1fb4552bff4943c66)
@@ -0,0 +1,49 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+namespace Ringtoets.Revetment.IO.Readers
+{
+ ///
+ /// Specifies the breakwater type of a .
+ ///
+ public enum ReadBreakWaterType
+ {
+ ///
+ /// Indicates there is no breakwater.
+ ///
+ None = 0,
+
+ ///
+ /// Indicates there is a caisson-shaped breakwater.
+ ///
+ Caisson = 1,
+
+ ///
+ /// Indicates there is a vertical structure-shaped breakwater.
+ ///
+ Vertical = 2,
+
+ ///
+ /// Indicates there is a harbor breakwater.
+ ///
+ HarborDam = 3
+ }
+}
\ No newline at end of file
Fisheye: Tag dc37877b917879d9c7b63ff1fb4552bff4943c66 refers to a dead (removed) revision in file `Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/ReadDamType.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/ReadWaveConditionsCalculation.cs
===================================================================
diff -u -rf0bc02e4ddd85caf9c51b909d36c31343398cd71 -rdc37877b917879d9c7b63ff1fb4552bff4943c66
--- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/ReadWaveConditionsCalculation.cs (.../ReadWaveConditionsCalculation.cs) (revision f0bc02e4ddd85caf9c51b909d36c31343398cd71)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/ReadWaveConditionsCalculation.cs (.../ReadWaveConditionsCalculation.cs) (revision dc37877b917879d9c7b63ff1fb4552bff4943c66)
@@ -50,9 +50,9 @@
StepSize = constructionProperties.StepSize;
ForeshoreProfile = constructionProperties.ForeshoreProfile;
Orientation = constructionProperties.Orientation;
- UseDam = constructionProperties.UseDam;
- DamType = constructionProperties.DamType;
- DamHeight = constructionProperties.DamHeight;
+ UseBreakWater = constructionProperties.UseBreakWater;
+ BreakWaterType = constructionProperties.BreakWaterType;
+ BreakWaterHeight = constructionProperties.BreakWaterHeight;
UseForeshore = constructionProperties.UseForeshore;
}
@@ -97,19 +97,19 @@
public double? Orientation { get; }
///
- /// Gets whether the dam should be used for the read calculation.
+ /// Gets whether the breakwater should be used for the read calculation.
///
- public bool? UseDam { get; }
+ public bool? UseBreakWater { get; }
///
- /// Gets the dam type of the read calculation.
+ /// Gets the breakwater type of the read calculation.
///
- public ReadDamType DamType { get; }
+ public ReadBreakWaterType BreakWaterType { get; }
///
- /// Gets the dam height of the read calculation.
+ /// Gets the breakwater height of the read calculation.
///
- public double? DamHeight { get; }
+ public double? BreakWaterHeight { get; }
///
/// Gets whether the foreshore should be used for the read calculation.
@@ -169,19 +169,19 @@
public double? Orientation { internal get; set; }
///
- /// Gets or sets the value for .
+ /// Gets or sets the value for .
///
- public bool? UseDam { internal get; set; }
+ public bool? UseBreakWater { internal get; set; }
///
- /// Gets or sets the value for .
+ /// Gets or sets the value for .
///
- public ReadDamType DamType { internal get; set; }
+ public ReadBreakWaterType BreakWaterType { internal get; set; }
///
- /// Gets or sets the value for .
+ /// Gets or sets the value for .
///
- public double? DamHeight { internal get; set; }
+ public double? BreakWaterHeight { internal get; set; }
///
/// Gets or sets the value for .
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/WaveConditionsInputConfigurationReader.cs
===================================================================
diff -u -ra0c7229c5e088639649bec9d2d64e0e30bad1d48 -rdc37877b917879d9c7b63ff1fb4552bff4943c66
--- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/WaveConditionsInputConfigurationReader.cs (.../WaveConditionsInputConfigurationReader.cs) (revision a0c7229c5e088639649bec9d2d64e0e30bad1d48)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/WaveConditionsInputConfigurationReader.cs (.../WaveConditionsInputConfigurationReader.cs) (revision dc37877b917879d9c7b63ff1fb4552bff4943c66)
@@ -21,9 +21,11 @@
using System;
using System.Collections.Generic;
+using System.Xml;
using System.Xml.Linq;
using Core.Common.IO.Exceptions;
using Ringtoets.Common.IO.Readers;
+using Ringtoets.Common.IO.Schema;
using Ringtoets.Revetment.IO.Properties;
using RingtoestCommonIOResources = Ringtoets.Common.IO.Properties.Resources;
@@ -55,26 +57,81 @@
///
public WaveConditionsInputConfigurationReader(string xmlFilePath)
: base(xmlFilePath,
- Resources.BekledingenHrConfiguratieSchema,
- new Dictionary
- {
- {
- hydraulicBoundaryLocationSchemaName, RingtoestCommonIOResources.HrLocatieSchema
- },
- {
- orientationSchemaName, RingtoestCommonIOResources.OrientatieSchema
- },
- {
- foreshoreProfileSchemaName, RingtoestCommonIOResources.VoorlandProfielSchema
- },
- {
- waveReductionSchemaName, RingtoestCommonIOResources.GolfReductieSchema
- }
- }) {}
+ Resources.BekledingenHrConfiguratieSchema,
+ new Dictionary
+ {
+ {
+ hydraulicBoundaryLocationSchemaName, RingtoestCommonIOResources.HrLocatieSchema
+ },
+ {
+ orientationSchemaName, RingtoestCommonIOResources.OrientatieSchema
+ },
+ {
+ foreshoreProfileSchemaName, RingtoestCommonIOResources.VoorlandProfielSchema
+ },
+ {
+ waveReductionSchemaName, RingtoestCommonIOResources.GolfReductieSchema
+ }
+ }) {}
protected override ReadWaveConditionsCalculation ParseCalculationElement(XElement calculationElement)
{
- throw new NotImplementedException();
+ var constructionProperties = new ReadWaveConditionsCalculation.ConstructionProperties
+ {
+ Name = calculationElement.Attribute(ConfigurationSchemaIdentifiers.NameAttribute)?.Value,
+ HydraulicBoundaryLocation = ConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement,
+ ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement),
+ UpperBoundaryRevetment = ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(calculationElement,
+ WaveConditionsInputConfigurationSchemaIdentifiers.UpperBoundaryRevetment),
+ LowerBoundaryRevetment = ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(calculationElement,
+ WaveConditionsInputConfigurationSchemaIdentifiers.LowerBoundaryRevetment),
+ UpperBoundaryWaterLevels = ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(calculationElement,
+ WaveConditionsInputConfigurationSchemaIdentifiers.UpperBoundaryWaterLevels),
+ LowerBoundaryWaterLevels = ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(calculationElement,
+ WaveConditionsInputConfigurationSchemaIdentifiers.LowerBoundaryWaterLevels),
+ StepSize = ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(calculationElement,
+ WaveConditionsInputConfigurationSchemaIdentifiers.StepSize),
+ ForeshoreProfile = ConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement,
+ WaveConditionsInputConfigurationSchemaIdentifiers.ForeshoreProfile),
+ Orientation = ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(calculationElement,
+ ConfigurationSchemaIdentifiers.Orientation),
+ UseBreakWater = GetBoolValueFromChildElement(calculationElement,
+ ConfigurationSchemaIdentifiers.UseBreakWater),
+ BreakWaterType = GetBreakWaterType(calculationElement,
+ ConfigurationSchemaIdentifiers.BreakWaterType),
+ BreakWaterHeight = ConfigurationReaderHelper.GetDoubleValueFromDescendantElement(calculationElement,
+ ConfigurationSchemaIdentifiers.BreakWaterHeight),
+ UseForeshore = GetBoolValueFromChildElement(calculationElement,
+ ConfigurationSchemaIdentifiers.UseForeshore)
+ };
+
+ return new ReadWaveConditionsCalculation(constructionProperties);
}
+
+ private static ReadBreakWaterType GetBreakWaterType(XElement parentElement, string childElementName)
+ {
+ string element = ConfigurationReaderHelper.GetStringValueFromDescendantElement(parentElement, childElementName);
+
+ switch (element)
+ {
+ case ConfigurationSchemaIdentifiers.BreakWaterCaisson:
+ return ReadBreakWaterType.Caisson;
+ case ConfigurationSchemaIdentifiers.BreakWaterDam:
+ return ReadBreakWaterType.HarborDam;
+ case ConfigurationSchemaIdentifiers.BreakWaterWall:
+ return ReadBreakWaterType.Vertical;
+ default:
+ return ReadBreakWaterType.None;
+ }
+ }
+
+ private static bool? GetBoolValueFromChildElement(XElement parentElement, string childElementName)
+ {
+ XElement descendantElement = ConfigurationReaderHelper.GetDescendantElement(parentElement, childElementName);
+
+ return descendantElement != null
+ ? (bool?) XmlConvert.ToBoolean(descendantElement.Value)
+ : null;
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Ringtoets.Revetment.IO.csproj
===================================================================
diff -u -rf0bc02e4ddd85caf9c51b909d36c31343398cd71 -rdc37877b917879d9c7b63ff1fb4552bff4943c66
--- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Ringtoets.Revetment.IO.csproj (.../Ringtoets.Revetment.IO.csproj) (revision f0bc02e4ddd85caf9c51b909d36c31343398cd71)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Ringtoets.Revetment.IO.csproj (.../Ringtoets.Revetment.IO.csproj) (revision dc37877b917879d9c7b63ff1fb4552bff4943c66)
@@ -54,7 +54,7 @@
True
Resources.resx
-
+
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditionsInputConfigurationSchemaIdentifiers.cs
===================================================================
diff -u -r2923096aeb41e1fb5d4ba0ad43ccb9f95ca7407a -rdc37877b917879d9c7b63ff1fb4552bff4943c66
--- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditionsInputConfigurationSchemaIdentifiers.cs (.../WaveConditionsInputConfigurationSchemaIdentifiers.cs) (revision 2923096aeb41e1fb5d4ba0ad43ccb9f95ca7407a)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditionsInputConfigurationSchemaIdentifiers.cs (.../WaveConditionsInputConfigurationSchemaIdentifiers.cs) (revision dc37877b917879d9c7b63ff1fb4552bff4943c66)
@@ -27,11 +27,6 @@
internal static class WaveConditionsInputConfigurationSchemaIdentifiers
{
///
- /// The tag of elements containing the name of the hydraulic boundary location.
- ///
- internal const string HydraulicBoundaryLocationElement = "hrlocatie";
-
- ///
/// The tag of elements containing the upper boundary of revetment.
///
internal const string UpperBoundaryRevetment = "bovengrensbekleding";
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditionsInputConfigurationWriter.cs
===================================================================
diff -u -rfde0ecf7d1d897337907d512aab471ead4a4c5e4 -rdc37877b917879d9c7b63ff1fb4552bff4943c66
--- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditionsInputConfigurationWriter.cs (.../WaveConditionsInputConfigurationWriter.cs) (revision fde0ecf7d1d897337907d512aab471ead4a4c5e4)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditionsInputConfigurationWriter.cs (.../WaveConditionsInputConfigurationWriter.cs) (revision dc37877b917879d9c7b63ff1fb4552bff4943c66)
@@ -88,7 +88,7 @@
if (hydraulicBoundaryLocation != null)
{
writer.WriteElementString(
- WaveConditionsInputConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement,
+ ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement,
hydraulicBoundaryLocation.Name);
}
}
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Readers/ReadWaveConditionsCalculationTest.cs
===================================================================
diff -u -rf0bc02e4ddd85caf9c51b909d36c31343398cd71 -rdc37877b917879d9c7b63ff1fb4552bff4943c66
--- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Readers/ReadWaveConditionsCalculationTest.cs (.../ReadWaveConditionsCalculationTest.cs) (revision f0bc02e4ddd85caf9c51b909d36c31343398cd71)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Readers/ReadWaveConditionsCalculationTest.cs (.../ReadWaveConditionsCalculationTest.cs) (revision dc37877b917879d9c7b63ff1fb4552bff4943c66)
@@ -57,9 +57,9 @@
Assert.IsNull(readCalculation.StepSize);
Assert.IsNull(readCalculation.ForeshoreProfile);
Assert.IsNull(readCalculation.Orientation);
- Assert.IsNull(readCalculation.UseDam);
- Assert.AreEqual(ReadDamType.None, readCalculation.DamType);
- Assert.IsNull(readCalculation.DamHeight);
+ Assert.IsNull(readCalculation.UseBreakWater);
+ Assert.AreEqual(ReadBreakWaterType.None, readCalculation.BreakWaterType);
+ Assert.IsNull(readCalculation.BreakWaterHeight);
Assert.IsNull(readCalculation.UseForeshore);
}
@@ -76,9 +76,9 @@
const double stepSize = 5.5;
const string foreshoreProfileName = "Name of the foreshore profile";
const double orientation = 6.6;
- const bool useDam = true;
- const ReadDamType damType = ReadDamType.Caisson;
- const double damHeight = 7.7;
+ const bool useBreakWater = true;
+ const ReadBreakWaterType breakWaterType = ReadBreakWaterType.Caisson;
+ const double breakWaterHeight = 7.7;
const bool useForeshore = false;
// Call
@@ -93,9 +93,9 @@
StepSize = stepSize,
ForeshoreProfile = foreshoreProfileName,
Orientation = orientation,
- UseDam = useDam,
- DamType = damType,
- DamHeight = damHeight,
+ UseBreakWater = useBreakWater,
+ BreakWaterType = breakWaterType,
+ BreakWaterHeight = breakWaterHeight,
UseForeshore = useForeshore
});
@@ -109,9 +109,9 @@
Assert.AreEqual(stepSize, readPipingCalculation.StepSize);
Assert.AreEqual(foreshoreProfileName, readPipingCalculation.ForeshoreProfile);
Assert.AreEqual(orientation, readPipingCalculation.Orientation);
- Assert.AreEqual(useDam, readPipingCalculation.UseDam);
- Assert.AreEqual(damType, readPipingCalculation.DamType);
- Assert.AreEqual(damHeight, readPipingCalculation.DamHeight);
+ Assert.AreEqual(useBreakWater, readPipingCalculation.UseBreakWater);
+ Assert.AreEqual(breakWaterType, readPipingCalculation.BreakWaterType);
+ Assert.AreEqual(breakWaterHeight, readPipingCalculation.BreakWaterHeight);
Assert.AreEqual(useForeshore, readPipingCalculation.UseForeshore);
}
}
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Readers/WaveConditionsInputConfigurationReaderTest.cs
===================================================================
diff -u -ra0c7229c5e088639649bec9d2d64e0e30bad1d48 -rdc37877b917879d9c7b63ff1fb4552bff4943c66
--- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Readers/WaveConditionsInputConfigurationReaderTest.cs (.../WaveConditionsInputConfigurationReaderTest.cs) (revision a0c7229c5e088639649bec9d2d64e0e30bad1d48)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Readers/WaveConditionsInputConfigurationReaderTest.cs (.../WaveConditionsInputConfigurationReaderTest.cs) (revision dc37877b917879d9c7b63ff1fb4552bff4943c66)
@@ -201,5 +201,162 @@
Assert.IsInstanceOf(exception.InnerException);
StringAssert.Contains(expectedParsingMessage, exception.InnerException?.Message);
}
+
+ [Test]
+ public void Read_ValidConfigurationWithEmptyCalculation_ReturnExpectedReadWaveConditionsInput()
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, "validConfigurationEmptyCalculation.xml");
+ var reader = new WaveConditionsInputConfigurationReader(filePath);
+
+ // Call
+ List readItems = reader.Read().ToList();
+
+ // Assert
+ Assert.AreEqual(1, readItems.Count);
+
+ var calculation = readItems[0] as ReadWaveConditionsCalculation;
+ Assert.IsNotNull(calculation);
+ Assert.AreEqual("Berekening 1", calculation.Name);
+ Assert.IsNull(calculation.HydraulicBoundaryLocation);
+ Assert.IsNull(calculation.UpperBoundaryRevetment);
+ Assert.IsNull(calculation.LowerBoundaryRevetment);
+ Assert.IsNull(calculation.UpperBoundaryWaterLevels);
+ Assert.IsNull(calculation.LowerBoundaryWaterLevels);
+ Assert.IsNull(calculation.StepSize);
+ Assert.IsNull(calculation.ForeshoreProfile);
+ Assert.IsNull(calculation.Orientation);
+ Assert.IsNull(calculation.UseBreakWater);
+ Assert.AreEqual(ReadBreakWaterType.None, calculation.BreakWaterType);
+ Assert.IsNull(calculation.BreakWaterHeight);
+ Assert.IsNull(calculation.UseForeshore);
+ }
+
+ [Test]
+ public void Read_ValidConfigurationWithCalculationContainingEmptyWaveReduction_ReturnExpectedReadWaveConditionsCalculation()
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, "validConfigurationCalculationContainingEmptyWaveReduction.xml");
+ var reader = new WaveConditionsInputConfigurationReader(filePath);
+
+ // Call
+ List readItems = reader.Read().ToList();
+
+ // Assert
+ Assert.AreEqual(1, readItems.Count);
+
+ var calculation = readItems[0] as ReadWaveConditionsCalculation;
+ Assert.IsNotNull(calculation);
+ Assert.IsNull(calculation.UseBreakWater);
+ Assert.AreEqual(ReadBreakWaterType.None, calculation.BreakWaterType);
+ Assert.IsNull(calculation.BreakWaterHeight);
+ Assert.IsNull(calculation.UseForeshore);
+ }
+
+ [Test]
+ public void Read_ValidConfigurationWithCalculationContainingNaNs_ReturnExpectedReadWaveConditionsCalculation()
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, "validConfigurationCalculationContainingNaNs.xml");
+ var reader = new WaveConditionsInputConfigurationReader(filePath);
+
+ // Call
+ List readItems = reader.Read().ToList();
+
+ // Assert
+ Assert.AreEqual(1, readItems.Count);
+
+ var calculation = readItems[0] as ReadWaveConditionsCalculation;
+ Assert.IsNotNull(calculation);
+ Assert.IsNaN(calculation.UpperBoundaryRevetment);
+ Assert.IsNaN(calculation.LowerBoundaryRevetment);
+ Assert.IsNaN(calculation.UpperBoundaryWaterLevels);
+ Assert.IsNaN(calculation.LowerBoundaryWaterLevels);
+ Assert.IsNaN(calculation.Orientation);
+ Assert.IsNaN(calculation.BreakWaterHeight);
+ }
+
+ [Test]
+ public void Read_ValidConfigurationWithCalculationContainingInfinities_ReturnExpectedReadWaveConditionsCalculation()
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, "validConfigurationCalculationContaininInfinities.xml");
+ var reader = new WaveConditionsInputConfigurationReader(filePath);
+
+ // Call
+ List readItems = reader.Read().ToList();
+
+ // Assert
+ Assert.AreEqual(1, readItems.Count);
+
+ var calculation = readItems[0] as ReadWaveConditionsCalculation;
+ Assert.IsNotNull(calculation);
+ Assert.IsTrue(calculation.UpperBoundaryRevetment != null && double.IsPositiveInfinity((double) calculation.UpperBoundaryRevetment));
+ Assert.IsTrue(calculation.LowerBoundaryRevetment != null && double.IsNegativeInfinity((double) calculation.LowerBoundaryRevetment));
+ Assert.IsTrue(calculation.UpperBoundaryWaterLevels != null && double.IsPositiveInfinity((double) calculation.UpperBoundaryWaterLevels));
+ Assert.IsTrue(calculation.LowerBoundaryWaterLevels != null && double.IsNegativeInfinity((double) calculation.LowerBoundaryWaterLevels));
+ Assert.IsTrue(calculation.Orientation != null && double.IsPositiveInfinity((double) calculation.Orientation));
+ Assert.IsTrue(calculation.BreakWaterHeight != null && double.IsPositiveInfinity((double) calculation.BreakWaterHeight));
+ }
+
+ [Test]
+ public void Read_ValidConfigurationWithFullCalculation_ReturnExpectedReadWaveConditionsCalculation()
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, "validConfigurationFullCalculation.xml");
+ var reader = new WaveConditionsInputConfigurationReader(filePath);
+
+ // Call
+ List readItems = reader.Read().ToList();
+
+ // Assert
+ Assert.AreEqual(1, readItems.Count);
+
+ var calculation = readItems[0] as ReadWaveConditionsCalculation;
+ Assert.IsNotNull(calculation);
+ Assert.AreEqual("Berekening 1", calculation.Name);
+ Assert.AreEqual("HRlocatie", calculation.HydraulicBoundaryLocation);
+ Assert.AreEqual(1.1, calculation.UpperBoundaryRevetment);
+ Assert.AreEqual(2.2, calculation.LowerBoundaryRevetment);
+ Assert.AreEqual(3.3, calculation.UpperBoundaryWaterLevels);
+ Assert.AreEqual(4.4, calculation.LowerBoundaryWaterLevels);
+ Assert.AreEqual(0.5, calculation.StepSize);
+ Assert.AreEqual("Voorlandprofiel", calculation.ForeshoreProfile);
+ Assert.AreEqual(5.5, calculation.Orientation);
+ Assert.IsTrue(calculation.UseBreakWater);
+ Assert.AreEqual(ReadBreakWaterType.Caisson, calculation.BreakWaterType);
+ Assert.AreEqual(6.6, calculation.BreakWaterHeight);
+ Assert.IsFalse(calculation.UseForeshore);
+ }
+
+ [Test]
+ public void Read_ValidConfigurationWithPartialCalculation_ReturnExpectedReadWaveConditionsCalculation()
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, "validConfigurationPartialCalculation.xml");
+ var reader = new WaveConditionsInputConfigurationReader(filePath);
+
+ // Call
+ List readItems = reader.Read().ToList();
+
+ // Assert
+ Assert.AreEqual(1, readItems.Count);
+
+ var calculation = readItems[0] as ReadWaveConditionsCalculation;
+ Assert.IsNotNull(calculation);
+ Assert.AreEqual("Berekening 1", calculation.Name);
+ Assert.IsNull(calculation.HydraulicBoundaryLocation);
+ Assert.AreEqual(1.1, calculation.UpperBoundaryRevetment);
+ Assert.AreEqual(2.2, calculation.LowerBoundaryRevetment);
+ Assert.IsNull(calculation.UpperBoundaryWaterLevels);
+ Assert.IsNull(calculation.LowerBoundaryWaterLevels);
+ Assert.AreEqual(0.5, calculation.StepSize);
+ Assert.IsNull(calculation.ForeshoreProfile);
+ Assert.IsNull(calculation.Orientation);
+ Assert.IsTrue(calculation.UseBreakWater);
+ Assert.AreEqual(ReadBreakWaterType.Caisson, calculation.BreakWaterType);
+ Assert.AreEqual(3.3, calculation.BreakWaterHeight);
+ Assert.IsNull(calculation.UseForeshore);
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationReader/validConfigurationCalculationContaininInfinities.xml
===================================================================
diff -u
--- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationReader/validConfigurationCalculationContaininInfinities.xml (revision 0)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationReader/validConfigurationCalculationContaininInfinities.xml (revision dc37877b917879d9c7b63ff1fb4552bff4943c66)
@@ -0,0 +1,13 @@
+
+
+
+ INF
+ -INF
+ INF
+ -INF
+ INF
+
+ INF
+
+
+
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationReader/validConfigurationCalculationContainingEmptyWaveReduction.xml
===================================================================
diff -u
--- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationReader/validConfigurationCalculationContainingEmptyWaveReduction.xml (revision 0)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationReader/validConfigurationCalculationContainingEmptyWaveReduction.xml (revision dc37877b917879d9c7b63ff1fb4552bff4943c66)
@@ -0,0 +1,6 @@
+
+
+
+
+
+
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationReader/validConfigurationCalculationContainingNaNs.xml
===================================================================
diff -u
--- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationReader/validConfigurationCalculationContainingNaNs.xml (revision 0)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationReader/validConfigurationCalculationContainingNaNs.xml (revision dc37877b917879d9c7b63ff1fb4552bff4943c66)
@@ -0,0 +1,13 @@
+
+
+
+ NaN
+ NaN
+ NaN
+ NaN
+ NaN
+
+ NaN
+
+
+
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationReader/validConfigurationFullCalculation.xml
===================================================================
diff -u
--- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationReader/validConfigurationFullCalculation.xml (revision 0)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationReader/validConfigurationFullCalculation.xml (revision dc37877b917879d9c7b63ff1fb4552bff4943c66)
@@ -0,0 +1,19 @@
+
+
+
+ HRlocatie
+ 1.1
+ 2.2
+ 3.3
+ 4.4
+ 0.5
+ Voorlandprofiel
+ 5.5
+
+ true
+ caisson
+ 6.6
+ false
+
+
+
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationReader/validConfigurationPartialCalculation.xml
===================================================================
diff -u
--- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationReader/validConfigurationPartialCalculation.xml (revision 0)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationReader/validConfigurationPartialCalculation.xml (revision dc37877b917879d9c7b63ff1fb4552bff4943c66)
@@ -0,0 +1,13 @@
+
+
+
+ 1.1
+ 2.2
+ 0.5
+
+ true
+ caisson
+ 3.3
+
+
+