Index: Ringtoets/Common/src/Ringtoets.Common.IO/Readers/CalculationConfigurationReaderHelper.cs
===================================================================
diff -u -r90d46f7d803d51c0a68ee35569cf3c918e5387fd -r9b6fa40a91299ecbbaffdbc79faf904b6c492d2f
--- Ringtoets/Common/src/Ringtoets.Common.IO/Readers/CalculationConfigurationReaderHelper.cs (.../CalculationConfigurationReaderHelper.cs) (revision 90d46f7d803d51c0a68ee35569cf3c918e5387fd)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Readers/CalculationConfigurationReaderHelper.cs (.../CalculationConfigurationReaderHelper.cs) (revision 9b6fa40a91299ecbbaffdbc79faf904b6c492d2f)
@@ -41,19 +41,13 @@
/// The value of the element, or null when the
/// does not have descendant elements of .
/// Thrown when any parameter is null.
+ /// Thrown when the value isn't in the correct format.
+ /// Thrown when the value represents a number
+ /// less than or greater than .
public static double? GetDoubleValueFromDescendantElement(this XElement parentElement, string descendantElementName)
{
- if (parentElement == null)
- {
- throw new ArgumentNullException(nameof(parentElement));
- }
- if (descendantElementName == null)
- {
- throw new ArgumentNullException(nameof(descendantElementName));
- }
+ XElement descendantElement = parentElement.GetDescendantElement(descendantElementName);
- XElement descendantElement = GetDescendantElement(parentElement, descendantElementName);
-
return descendantElement != null
? (double?) XmlConvert.ToDouble(descendantElement.Value)
: null;
@@ -67,19 +61,10 @@
/// The value of the element, or null when the
/// does not have descendant elements of .
/// Thrown when any parameter is null.
- public static string GetStringValueFromDescendantElement(XElement parentElement, string descendantElementName)
+ public static string GetStringValueFromDescendantElement(this XElement parentElement, string descendantElementName)
{
- if (parentElement == null)
- {
- throw new ArgumentNullException(nameof(parentElement));
- }
- if (descendantElementName == null)
- {
- throw new ArgumentNullException(nameof(descendantElementName));
- }
+ XElement descendantElement = parentElement.GetDescendantElement(descendantElementName);
- XElement descendantElement = GetDescendantElement(parentElement, descendantElementName);
-
return descendantElement?.Value;
}
@@ -91,9 +76,10 @@
/// The value, or null when the
/// does not have descendant elements of .
/// Thrown when any parameter is null.
- public static bool? GetBoolValueFromDescendantElement(XElement parentElement, string descendantElementName)
+ /// Thrown when the value does not represent a value.
+ public static bool? GetBoolValueFromDescendantElement(this XElement parentElement, string descendantElementName)
{
- XElement descendantElement = GetDescendantElement(parentElement, descendantElementName);
+ XElement descendantElement = parentElement.GetDescendantElement(descendantElementName);
return descendantElement != null
? (bool?) XmlConvert.ToBoolean(descendantElement.Value)
@@ -109,9 +95,10 @@
/// The converted value, or null when the
/// does not have descendant elements of .
/// Thrown when any parameter is null.
- public static object GetConvertedValueFromDescendantElement(XElement parentElement, string descendantElementName) where TConverter : TypeConverter, new()
+ /// Thrown when the conversion cannot be performed.
+ public static object GetConvertedValueFromDescendantElement(this XElement parentElement, string descendantElementName) where TConverter : TypeConverter, new()
{
- string stringValue = GetStringValueFromDescendantElement(parentElement, descendantElementName);
+ string stringValue = parentElement.GetStringValueFromDescendantElement(descendantElementName);
if (stringValue == null)
{
return null;
@@ -127,7 +114,7 @@
/// The stochast element, or null when the
/// does not have stochast elements with the name .
/// Thrown when any parameter is null.
- public static XElement GetStochastElement(XElement parentElement, string stochastName)
+ public static XElement GetStochastElement(this XElement parentElement, string stochastName)
{
if (parentElement == null)
{
@@ -152,7 +139,7 @@
/// 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)
+ public static XElement GetDescendantElement(this XElement parentElement, string descendantElementName)
{
if (parentElement == null)
{
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/BreakWaterTypeTypeConverterTest.cs
===================================================================
diff -u -rfde0ecf7d1d897337907d512aab471ead4a4c5e4 -r9b6fa40a91299ecbbaffdbc79faf904b6c492d2f
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/BreakWaterTypeTypeConverterTest.cs (.../BreakWaterTypeTypeConverterTest.cs) (revision fde0ecf7d1d897337907d512aab471ead4a4c5e4)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/BreakWaterTypeTypeConverterTest.cs (.../BreakWaterTypeTypeConverterTest.cs) (revision 9b6fa40a91299ecbbaffdbc79faf904b6c492d2f)
@@ -84,6 +84,20 @@
}
[Test]
+ public void ConvertTo_InvalidBreakWaterType_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new BreakWaterTypeTypeConverter();
+ var invalidValue = (BreakWaterType) 99999999;
+
+ // Call
+ TestDelegate call = () => converter.ConvertTo(invalidValue, typeof(string));
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
public void CanConvertFrom_String_ReturnTrue()
{
// Setup
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/CalculationConfigurationReaderHelperTest.cs
===================================================================
diff -u -r90d46f7d803d51c0a68ee35569cf3c918e5387fd -r9b6fa40a91299ecbbaffdbc79faf904b6c492d2f
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/CalculationConfigurationReaderHelperTest.cs (.../CalculationConfigurationReaderHelperTest.cs) (revision 90d46f7d803d51c0a68ee35569cf3c918e5387fd)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/CalculationConfigurationReaderHelperTest.cs (.../CalculationConfigurationReaderHelperTest.cs) (revision 9b6fa40a91299ecbbaffdbc79faf904b6c492d2f)
@@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Xml;
using System.Xml.Linq;
using NUnit.Framework;
@@ -101,8 +102,11 @@
[Test]
public void GetStringValueFromDescendantElement_ParentElementNull_ThrowArgumentNullException()
{
+ // Setup
+ XElement element = null;
+
// Call
- TestDelegate test = () => CalculationConfigurationReaderHelper.GetStringValueFromDescendantElement(null, "");
+ TestDelegate test = () => element.GetStringValueFromDescendantElement("");
// Assert
var exception = Assert.Throws(test);
@@ -113,7 +117,7 @@
public void GetStringValueFromDescendantElement_DescendantElementNameNull_ThrowArgumentNullException()
{
// Call
- TestDelegate test = () => CalculationConfigurationReaderHelper.GetStringValueFromDescendantElement(new XElement("Test"), null);
+ TestDelegate test = () => new XElement("Test").GetStringValueFromDescendantElement(null);
// Assert
var exception = Assert.Throws(test);
@@ -130,7 +134,7 @@
var element = new XElement("Root", new XElement(descendantElementName, descendantElementValue));
// Call
- string readValue = CalculationConfigurationReaderHelper.GetStringValueFromDescendantElement(element, descendantElementName);
+ string readValue = element.GetStringValueFromDescendantElement(descendantElementName);
// Assert
Assert.AreEqual(descendantElementValue, readValue);
@@ -143,7 +147,7 @@
var element = new XElement("Root", new XElement("number", "valueText"));
// Call
- string readValue = CalculationConfigurationReaderHelper.GetStringValueFromDescendantElement(element, "invalidName");
+ string readValue = element.GetStringValueFromDescendantElement("invalidName");
// Assert
Assert.IsNull(readValue);
@@ -152,8 +156,11 @@
[Test]
public void GetBoolValueFromDescendantElement_ParentElementNull_ThrowArgumentNullException()
{
+ // Setup
+ XElement element = null;
+
// Call
- TestDelegate test = () => CalculationConfigurationReaderHelper.GetBoolValueFromDescendantElement(null, "");
+ TestDelegate test = () => element.GetBoolValueFromDescendantElement("");
// Assert
var exception = Assert.Throws(test);
@@ -167,7 +174,7 @@
var element = new XElement("Root");
// Call
- TestDelegate test = () => CalculationConfigurationReaderHelper.GetBoolValueFromDescendantElement(element, null);
+ TestDelegate test = () => element.GetBoolValueFromDescendantElement(null);
// Assert
var exception = Assert.Throws(test);
@@ -186,7 +193,7 @@
var element = new XElement("Root", new XElement(descendantElementName, elementValue));
// Call
- bool? readValue = CalculationConfigurationReaderHelper.GetBoolValueFromDescendantElement(element, descendantElementName);
+ bool? readValue = element.GetBoolValueFromDescendantElement(descendantElementName);
// Assert
Assert.AreEqual(booleanValue, readValue);
@@ -201,17 +208,81 @@
var element = new XElement("Root", new XElement("booleanValue", elementValue));
// Call
- bool? readValue = CalculationConfigurationReaderHelper.GetBoolValueFromDescendantElement(element, "unmatchingChildElementName");
+ bool? readValue = element.GetBoolValueFromDescendantElement("unmatchingChildElementName");
// Assert
Assert.IsNull(readValue);
}
[Test]
+ public void GetConvertedValueFromDescendantElement_ParentElementNull_ThrowArgumentNullException()
+ {
+ // Setup
+ XElement element = null;
+
+ // Call
+ TestDelegate test = () => element.GetConvertedValueFromDescendantElement("");
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("parentElement", exception.ParamName);
+ }
+
+ [Test]
+ public void GetConvertedValueFromDescendantElement_DescendantElementNameNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var element = new XElement("Root");
+
+ // Call
+ TestDelegate test = () => element.GetConvertedValueFromDescendantElement(null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("descendantElementName", exception.ParamName);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void GetConvertedValueFromDescendantElement_ValidDescendantElement_ReturnValue(bool value)
+ {
+ // Setup
+ const string descendantElementName = "value";
+ string elementValue = XmlConvert.ToString(value);
+
+ var element = new XElement("Root", new XElement(descendantElementName, elementValue));
+
+ // Call
+ object readValue = element.GetConvertedValueFromDescendantElement(descendantElementName);
+
+ // Assert
+ Assert.AreEqual(value, readValue);
+ }
+
+ [Test]
+ public void GetConvertedValueFromDescendantElement_UnmatchedDescendantElement_ReturnNull()
+ {
+ // Setup
+ string elementValue = XmlConvert.ToString(true);
+
+ var element = new XElement("Root", new XElement("value", elementValue));
+
+ // Call
+ object readValue = element.GetConvertedValueFromDescendantElement("unmatchingChildElementName");
+
+ // Assert
+ Assert.IsNull(readValue);
+ }
+
+ [Test]
public void GetStochastElement_ParentElementNull_ThrowArgumentNullException()
{
+ // Setup
+ XElement element = null;
+
// Call
- TestDelegate test = () => CalculationConfigurationReaderHelper.GetStochastElement(null, "");
+ TestDelegate test = () => element.GetStochastElement("");
// Assert
var exception = Assert.Throws(test);
@@ -225,7 +296,7 @@
var element = new XElement("Root");
// Call
- TestDelegate test = () => CalculationConfigurationReaderHelper.GetStochastElement(element, null);
+ TestDelegate test = () => element.GetStochastElement(null);
// Assert
var exception = Assert.Throws(test);
@@ -239,7 +310,7 @@
var element = new XElement("Root");
// Call
- XElement stochastElement = CalculationConfigurationReaderHelper.GetStochastElement(element, "stochast_name");
+ XElement stochastElement = element.GetStochastElement("stochast_name");
// Assert
Assert.IsNull(stochastElement);
@@ -253,7 +324,7 @@
var element = new XElement("Root", stochastsElements);
// Call
- XElement stochastElement = CalculationConfigurationReaderHelper.GetStochastElement(element, "stochast_name");
+ XElement stochastElement = element.GetStochastElement("stochast_name");
// Assert
Assert.IsNull(stochastElement);
@@ -276,7 +347,7 @@
var element = new XElement("Root", stochastsElements);
// Call
- XElement stochastElement = CalculationConfigurationReaderHelper.GetStochastElement(element, "stochast_name");
+ XElement stochastElement = element.GetStochastElement("stochast_name");
// Assert
Assert.IsNull(stochastElement);
@@ -304,7 +375,7 @@
var element = new XElement("Root", stochastsElements);
// Call
- XElement stochastElement = CalculationConfigurationReaderHelper.GetStochastElement(element, stochastName);
+ XElement stochastElement = element.GetStochastElement(stochastName);
// Assert
Assert.AreSame(stochastElementToMatch, stochastElement);
@@ -313,8 +384,11 @@
[Test]
public void GetDescendantElement_ParentElementNull_ThrowArgumentNullException()
{
+ // Setup
+ XElement element = null;
+
// Call
- TestDelegate test = () => CalculationConfigurationReaderHelper.GetDescendantElement(null, "");
+ TestDelegate test = () => element.GetDescendantElement("");
// Assert
var exception = Assert.Throws(test);
@@ -325,7 +399,7 @@
public void GetDescendantElement_DescendantElementNameNull_ThrowArgumentNullException()
{
// Call
- TestDelegate test = () => CalculationConfigurationReaderHelper.GetDescendantElement(new XElement("Test"), null);
+ TestDelegate test = () => new XElement("Test").GetDescendantElement(null);
// Assert
var exception = Assert.Throws(test);
@@ -337,7 +411,7 @@
public void GetDescendantElement_ValidDescendantName_ReturnElement(XElement parentElement)
{
// Call
- XElement element = CalculationConfigurationReaderHelper.GetDescendantElement(parentElement, "descendant");
+ XElement element = parentElement.GetDescendantElement("descendant");
// Assert
Assert.IsNotNull(element);
@@ -351,7 +425,7 @@
var parentElement = new XElement("Root", new XElement("Child", new XElement("descendant")));
// Call
- XElement element = CalculationConfigurationReaderHelper.GetDescendantElement(parentElement, "something_else");
+ XElement element = parentElement.GetDescendantElement("something_else");
// Assert
Assert.IsNull(element);
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeHeightCalculationTypeTypeConverter.cs
===================================================================
diff -u -r7a466d4ccb9d859b47f565b400808eb6933b18f0 -r9b6fa40a91299ecbbaffdbc79faf904b6c492d2f
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeHeightCalculationTypeTypeConverter.cs (.../DikeHeightCalculationTypeTypeConverter.cs) (revision 7a466d4ccb9d859b47f565b400808eb6933b18f0)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeHeightCalculationTypeTypeConverter.cs (.../DikeHeightCalculationTypeTypeConverter.cs) (revision 9b6fa40a91299ecbbaffdbc79faf904b6c492d2f)
@@ -36,7 +36,7 @@
{
if (destinationType == typeof(string))
{
- var dikeHeightCalculationType = (DikeHeightCalculationType)value;
+ var dikeHeightCalculationType = (DikeHeightCalculationType) value;
switch (dikeHeightCalculationType)
{
case DikeHeightCalculationType.NoCalculation:
@@ -45,6 +45,8 @@
return Resources.DikeHeightCalculationTypeTypeConverter_CalculateByAssessmentSectionNorm;
case DikeHeightCalculationType.CalculateByProfileSpecificRequiredProbability:
return Resources.DikeHeightCalculationTypeTypeConverter_CalculateByProfileSpecificRequiredProbability;
+ default:
+ throw new NotSupportedException();
}
}
return base.ConvertTo(context, culture, value, destinationType);
@@ -68,7 +70,7 @@
{
return DikeHeightCalculationType.NoCalculation;
}
- if(text == Resources.DikeHeightCalculationTypeTypeConverter_CalculateByAssessmentSectionNorm)
+ if (text == Resources.DikeHeightCalculationTypeTypeConverter_CalculateByAssessmentSectionNorm)
{
return DikeHeightCalculationType.CalculateByAssessmentSectionNorm;
}
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Readers/GrassCoverErosionInwardsCalculationConfigurationReader.cs
===================================================================
diff -u -r90d46f7d803d51c0a68ee35569cf3c918e5387fd -r9b6fa40a91299ecbbaffdbc79faf904b6c492d2f
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Readers/GrassCoverErosionInwardsCalculationConfigurationReader.cs (.../GrassCoverErosionInwardsCalculationConfigurationReader.cs) (revision 90d46f7d803d51c0a68ee35569cf3c918e5387fd)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Readers/GrassCoverErosionInwardsCalculationConfigurationReader.cs (.../GrassCoverErosionInwardsCalculationConfigurationReader.cs) (revision 9b6fa40a91299ecbbaffdbc79faf904b6c492d2f)
@@ -77,24 +77,19 @@
var constructionProperties = new ReadGrassCoverErosionInwardsCalculation.ConstructionProperties
{
Name = calculationElement.Attribute(ConfigurationSchemaIdentifiers.NameAttribute)?.Value,
- HydraulicBoundaryLocation = CalculationConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement,
- ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement),
- DikeProfile = CalculationConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement,
- GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.DikeProfileElement),
+ HydraulicBoundaryLocation = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement),
+ DikeProfile = calculationElement.GetStringValueFromDescendantElement(GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.DikeProfileElement),
Orientation = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.Orientation),
DikeHeight = calculationElement.GetDoubleValueFromDescendantElement(GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.DikeHeightElement),
- DikeHeightCalculationType = (DikeHeightCalculationType?) CalculationConfigurationReaderHelper.GetConvertedValueFromDescendantElement(calculationElement,
- GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.DikeHeightCalculationTypeElement),
- UseBreakWater = CalculationConfigurationReaderHelper.GetBoolValueFromDescendantElement(calculationElement,
- ConfigurationSchemaIdentifiers.UseBreakWater),
- BreakWaterType = (BreakWaterType?) CalculationConfigurationReaderHelper.GetConvertedValueFromDescendantElement(calculationElement,
- ConfigurationSchemaIdentifiers.BreakWaterType),
+ DikeHeightCalculationType = (DikeHeightCalculationType?) calculationElement.GetConvertedValueFromDescendantElement(
+ GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.DikeHeightCalculationTypeElement),
+ UseBreakWater = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseBreakWater),
+ BreakWaterType = (BreakWaterType?) calculationElement.GetConvertedValueFromDescendantElement(ConfigurationSchemaIdentifiers.BreakWaterType),
BreakWaterHeight = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.BreakWaterHeight),
- UseForeshore = CalculationConfigurationReaderHelper.GetBoolValueFromDescendantElement(calculationElement,
- ConfigurationSchemaIdentifiers.UseForeshore)
+ UseForeshore = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseForeshore)
};
- XElement criticalFlowRateElement = CalculationConfigurationReaderHelper.GetStochastElement(calculationElement, GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.CriticalFlowRateStochastName);
+ XElement criticalFlowRateElement = calculationElement.GetStochastElement(GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.CriticalFlowRateStochastName);
if (criticalFlowRateElement != null)
{
constructionProperties.CriticalFlowRateMean = criticalFlowRateElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.MeanElement);
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/DikeHeightCalculationTypeTypeConverterTest.cs
===================================================================
diff -u -r7a466d4ccb9d859b47f565b400808eb6933b18f0 -r9b6fa40a91299ecbbaffdbc79faf904b6c492d2f
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/DikeHeightCalculationTypeTypeConverterTest.cs (.../DikeHeightCalculationTypeTypeConverterTest.cs) (revision 7a466d4ccb9d859b47f565b400808eb6933b18f0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/DikeHeightCalculationTypeTypeConverterTest.cs (.../DikeHeightCalculationTypeTypeConverterTest.cs) (revision 9b6fa40a91299ecbbaffdbc79faf904b6c492d2f)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.ComponentModel;
using NUnit.Framework;
using Ringtoets.GrassCoverErosionInwards.Data;
@@ -81,6 +82,34 @@
}
[Test]
+ public void ConvertTo_InvalidDikeHeightCalculationTypeValue_ThrownNotSupportedException()
+ {
+ // Setup
+ var converter = new DikeHeightCalculationTypeTypeConverter();
+
+ var invalidValue = (DikeHeightCalculationType) 9999999;
+
+ // Call
+ TestDelegate call = () => converter.ConvertTo(invalidValue, typeof(string));
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ public void ConvertTo_Object_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new DikeHeightCalculationTypeTypeConverter();
+
+ // Call
+ TestDelegate call = () => converter.ConvertTo(DikeHeightCalculationType.NoCalculation, typeof(object));
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
public void CanConvertFrom_String_ReturnTrue()
{
// Setup
@@ -121,5 +150,18 @@
// Assert
Assert.AreEqual(expectedResult, result);
}
+
+ [Test]
+ public void ConvertFrom_UnsupportedString_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new DikeHeightCalculationTypeTypeConverter();
+
+ // Call
+ TestDelegate call = () => converter.ConvertFrom("");
+
+ // Assert
+ Assert.Throws(call);
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingCalculationConfigurationReader.cs
===================================================================
diff -u -r90d46f7d803d51c0a68ee35569cf3c918e5387fd -r9b6fa40a91299ecbbaffdbc79faf904b6c492d2f
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingCalculationConfigurationReader.cs (.../PipingCalculationConfigurationReader.cs) (revision 90d46f7d803d51c0a68ee35569cf3c918e5387fd)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingCalculationConfigurationReader.cs (.../PipingCalculationConfigurationReader.cs) (revision 9b6fa40a91299ecbbaffdbc79faf904b6c492d2f)
@@ -72,28 +72,22 @@
{
Name = calculationElement.Attribute(ConfigurationSchemaIdentifiers.NameAttribute)?.Value,
AssessmentLevel = calculationElement.GetDoubleValueFromDescendantElement(PipingCalculationConfigurationSchemaIdentifiers.AssessmentLevelElement),
- HydraulicBoundaryLocation = CalculationConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement,
- ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement),
- SurfaceLine = CalculationConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement,
- PipingCalculationConfigurationSchemaIdentifiers.SurfaceLineElement),
+ HydraulicBoundaryLocation = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement),
+ SurfaceLine = calculationElement.GetStringValueFromDescendantElement(PipingCalculationConfigurationSchemaIdentifiers.SurfaceLineElement),
EntryPointL = calculationElement.GetDoubleValueFromDescendantElement(PipingCalculationConfigurationSchemaIdentifiers.EntryPointLElement),
ExitPointL = calculationElement.GetDoubleValueFromDescendantElement(PipingCalculationConfigurationSchemaIdentifiers.ExitPointLElement),
- StochasticSoilModel = CalculationConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement,
- PipingCalculationConfigurationSchemaIdentifiers.StochasticSoilModelElement),
- StochasticSoilProfile = CalculationConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement,
- PipingCalculationConfigurationSchemaIdentifiers.StochasticSoilProfileElement)
+ StochasticSoilModel = calculationElement.GetStringValueFromDescendantElement(PipingCalculationConfigurationSchemaIdentifiers.StochasticSoilModelElement),
+ StochasticSoilProfile = calculationElement.GetStringValueFromDescendantElement(PipingCalculationConfigurationSchemaIdentifiers.StochasticSoilProfileElement)
};
- XElement phreaticLevelExitElement = CalculationConfigurationReaderHelper.GetStochastElement(calculationElement,
- PipingCalculationConfigurationSchemaIdentifiers.PhreaticLevelExitStochastName);
+ XElement phreaticLevelExitElement = calculationElement.GetStochastElement(PipingCalculationConfigurationSchemaIdentifiers.PhreaticLevelExitStochastName);
if (phreaticLevelExitElement != null)
{
constructionProperties.PhreaticLevelExitMean = phreaticLevelExitElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.MeanElement);
constructionProperties.PhreaticLevelExitStandardDeviation = phreaticLevelExitElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.StandardDeviationElement);
}
- XElement dampingFactorExitElement = CalculationConfigurationReaderHelper.GetStochastElement(calculationElement,
- PipingCalculationConfigurationSchemaIdentifiers.DampingFactorExitStochastName);
+ XElement dampingFactorExitElement = calculationElement.GetStochastElement(PipingCalculationConfigurationSchemaIdentifiers.DampingFactorExitStochastName);
if (dampingFactorExitElement != null)
{
constructionProperties.DampingFactorExitMean = dampingFactorExitElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.MeanElement);
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/WaveConditionsCalculationConfigurationReader.cs
===================================================================
diff -u -r90d46f7d803d51c0a68ee35569cf3c918e5387fd -r9b6fa40a91299ecbbaffdbc79faf904b6c492d2f
--- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/WaveConditionsCalculationConfigurationReader.cs (.../WaveConditionsCalculationConfigurationReader.cs) (revision 90d46f7d803d51c0a68ee35569cf3c918e5387fd)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/WaveConditionsCalculationConfigurationReader.cs (.../WaveConditionsCalculationConfigurationReader.cs) (revision 9b6fa40a91299ecbbaffdbc79faf904b6c492d2f)
@@ -78,23 +78,18 @@
var constructionProperties = new ReadWaveConditionsCalculation.ConstructionProperties
{
Name = calculationElement.Attribute(ConfigurationSchemaIdentifiers.NameAttribute)?.Value,
- HydraulicBoundaryLocation = CalculationConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement,
- ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement),
+ HydraulicBoundaryLocation = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement),
UpperBoundaryRevetment = calculationElement.GetDoubleValueFromDescendantElement(WaveConditionsCalculationConfigurationSchemaIdentifiers.UpperBoundaryRevetment),
LowerBoundaryRevetment = calculationElement.GetDoubleValueFromDescendantElement(WaveConditionsCalculationConfigurationSchemaIdentifiers.LowerBoundaryRevetment),
UpperBoundaryWaterLevels = calculationElement.GetDoubleValueFromDescendantElement(WaveConditionsCalculationConfigurationSchemaIdentifiers.UpperBoundaryWaterLevels),
LowerBoundaryWaterLevels = calculationElement.GetDoubleValueFromDescendantElement(WaveConditionsCalculationConfigurationSchemaIdentifiers.LowerBoundaryWaterLevels),
StepSize = calculationElement.GetDoubleValueFromDescendantElement(WaveConditionsCalculationConfigurationSchemaIdentifiers.StepSize),
- ForeshoreProfile = CalculationConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement,
- WaveConditionsCalculationConfigurationSchemaIdentifiers.ForeshoreProfile),
+ ForeshoreProfile = calculationElement.GetStringValueFromDescendantElement(WaveConditionsCalculationConfigurationSchemaIdentifiers.ForeshoreProfile),
Orientation = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.Orientation),
- UseBreakWater = CalculationConfigurationReaderHelper.GetBoolValueFromDescendantElement(calculationElement,
- ConfigurationSchemaIdentifiers.UseBreakWater),
- BreakWaterType = CalculationConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement,
- ConfigurationSchemaIdentifiers.BreakWaterType),
+ UseBreakWater = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseBreakWater),
+ BreakWaterType = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.BreakWaterType),
BreakWaterHeight = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.BreakWaterHeight),
- UseForeshore = CalculationConfigurationReaderHelper.GetBoolValueFromDescendantElement(calculationElement,
- ConfigurationSchemaIdentifiers.UseForeshore)
+ UseForeshore = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseForeshore)
};
return new ReadWaveConditionsCalculation(constructionProperties);
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/WaveConditionsInputStepSizeTypeConverterTest.cs
===================================================================
diff -u -rfde0ecf7d1d897337907d512aab471ead4a4c5e4 -r9b6fa40a91299ecbbaffdbc79faf904b6c492d2f
--- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/WaveConditionsInputStepSizeTypeConverterTest.cs (.../WaveConditionsInputStepSizeTypeConverterTest.cs) (revision fde0ecf7d1d897337907d512aab471ead4a4c5e4)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/WaveConditionsInputStepSizeTypeConverterTest.cs (.../WaveConditionsInputStepSizeTypeConverterTest.cs) (revision 9b6fa40a91299ecbbaffdbc79faf904b6c492d2f)
@@ -85,6 +85,19 @@
}
[Test]
+ public void ConvertTo_Object_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new WaveConditionsInputStepSizeTypeConverter();
+
+ // Call
+ TestDelegate call = () => converter.ConvertTo(WaveConditionsInputStepSize.Half, typeof(object));
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
public void CanConvertFrom_String_ReturnTrue()
{
// Setup