Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/ClosingStructuresCalculationConfigurationWriter.cs
===================================================================
diff -u
--- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/ClosingStructuresCalculationConfigurationWriter.cs (revision 0)
+++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/ClosingStructuresCalculationConfigurationWriter.cs (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -0,0 +1,93 @@
+// 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.
+
+using System;
+using System.Xml;
+using Ringtoets.Common.IO.Writers;
+
+namespace Ringtoets.ClosingStructures.IO
+{
+ ///
+ /// Writer for writing in XML format to file.
+ ///
+ public class ClosingStructuresCalculationConfigurationWriter : StructureCalculationConfigurationWriter
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The path of the file to write to.
+ /// Thrown when is invalid.
+ /// A valid path:
+ ///
+ /// - is not empty or null,
+ /// - does not consist out of only whitespace characters,
+ /// - does not contain an invalid character,
+ /// - does not end with a directory or path separator (empty file name).
+ ///
+ public ClosingStructuresCalculationConfigurationWriter(string filePath)
+ : base(filePath) {}
+
+ protected override void WriteSpecificStructureParameters(ClosingStructuresCalculationConfiguration configuration, XmlWriter writer)
+ {
+ if (configuration.InflowModelType != null)
+ {
+ writer.WriteElementString(
+ ClosingStructuresConfigurationSchemaIdentifiers.InflowModelType,
+ new ConfigurationClosingStructureInflowModelTypeConverter().ConvertToInvariantString(configuration.InflowModelType));
+ }
+
+ WriteElementWhenContentAvailable(writer,
+ ClosingStructuresConfigurationSchemaIdentifiers.FactorStormDurationOpenStructure,
+ configuration.FactorStormDurationOpenStructure);
+ WriteElementWhenContentAvailable(writer,
+ ClosingStructuresConfigurationSchemaIdentifiers.IdenticalApertures,
+ configuration.IdenticalApertures);
+ WriteElementWhenContentAvailable(writer,
+ ClosingStructuresConfigurationSchemaIdentifiers.ProbabilityOrFrequencyOpenStructureBeforeFlooding,
+ configuration.ProbabilityOrFrequencyOpenStructureBeforeFlooding);
+ WriteElementWhenContentAvailable(writer,
+ ClosingStructuresConfigurationSchemaIdentifiers.FailureProbabilityOpenStructure,
+ configuration.FailureProbabilityOpenStructure);
+ WriteElementWhenContentAvailable(writer,
+ ClosingStructuresConfigurationSchemaIdentifiers.FailureProbabilityReparation,
+ configuration.FailureProbabilityReparation);
+ }
+
+ protected override void WriteSpecificStochasts(ClosingStructuresCalculationConfiguration configuration, XmlWriter writer)
+ {
+ WriteDistributionWhenAvailable(writer,
+ ClosingStructuresConfigurationSchemaIdentifiers.DrainCoefficientStochastName,
+ configuration.DrainCoefficient);
+ WriteDistributionWhenAvailable(writer,
+ ClosingStructuresConfigurationSchemaIdentifiers.InsideWaterLevelStochastName,
+ configuration.InsideWaterLevel);
+ WriteDistributionWhenAvailable(writer,
+ ClosingStructuresConfigurationSchemaIdentifiers.AreaFlowAperturesStochastName,
+ configuration.AreaFlowApertures);
+ WriteDistributionWhenAvailable(writer,
+ ClosingStructuresConfigurationSchemaIdentifiers.ThresholdHeightOpenWeirStochastName,
+ configuration.ThresholdHeightOpenWeir);
+ WriteDistributionWhenAvailable(writer,
+ ClosingStructuresConfigurationSchemaIdentifiers.LevelCrestStructureNotClosingStochastName,
+ configuration.LevelCrestStructureNotClosing);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/ClosingStructuresConfigurationSchemaIdentifiers.cs
===================================================================
diff -u -r8963d5e5c4a22feba25c4e936e6b67de7104cccd -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/ClosingStructuresConfigurationSchemaIdentifiers.cs (.../ClosingStructuresConfigurationSchemaIdentifiers.cs) (revision 8963d5e5c4a22feba25c4e936e6b67de7104cccd)
+++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/ClosingStructuresConfigurationSchemaIdentifiers.cs (.../ClosingStructuresConfigurationSchemaIdentifiers.cs) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -26,13 +26,86 @@
///
public static class ClosingStructuresConfigurationSchemaIdentifiers
{
+ #region parameters
+
+ ///
+ /// The identifier for the identical apertures element.
+ ///
+ public const string IdenticalApertures = "nrdoorstroomopeningen";
+
+ ///
+ /// The identifier for the factor storm duration open structure element.
+ ///
+ public const string FactorStormDurationOpenStructure = "factorstormduur";
+
+ ///
+ /// The identifier for the failure probability open structure element.
+ ///
+ public const string FailureProbabilityOpenStructure = "kansmislukkensluiting";
+
+ ///
+ /// The identifier for the failure probability reparation element.
+ ///
+ public const string FailureProbabilityReparation = "faalkansherstel";
+
+ ///
+ /// The identifier for theprobability or frequencey open structure before flooding element.
+ ///
+ public const string ProbabilityOrFrequencyOpenStructureBeforeFlooding = "kansopopenstaan";
+
+ ///
+ /// The identifier for the inflow model type element.
+ ///
+ public const string InflowModelType = "instroommodel";
+
+ #endregion
+
#region stochasts
-
+
///
/// The identifier for the level crest structure not closing stochast name.
///
public const string LevelCrestStructureNotClosingStochastName = "kruinhoogte";
+ ///
+ /// The identifier for the inside water level stochast name.
+ ///
+ public const string InsideWaterLevelStochastName = "binnenwaterstand";
+
+ ///
+ /// The identifier for the drain coefficient stochast name.
+ ///
+ public const string DrainCoefficientStochastName = "afvoercoefficient";
+
+ ///
+ /// The identifier for the threshold height open weir stochast name.
+ ///
+ public const string ThresholdHeightOpenWeirStochastName = "drempelhoogte";
+
+ ///
+ /// The identifier for the area flow apertures stochast name.
+ ///
+ public const string AreaFlowAperturesStochastName = "doorstroomoppervlak";
+
#endregion
+
+ #region inflow model type
+
+ ///
+ /// The identifier for the flooded culvert inflow model type.
+ ///
+ public const string FloodedCulvert = "verdronkenkoker";
+
+ ///
+ /// The identifier for the low will inflow model type.
+ ///
+ public const string LowSill = "lagedrempel";
+
+ ///
+ /// The identifier for the vertical wall inflow model type.
+ ///
+ public const string VerticalWall = "verticalewand";
+
+ #endregion
}
}
\ No newline at end of file
Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/ConfigurationClosingStructureInflowModelTypeConverter.cs
===================================================================
diff -u
--- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/ConfigurationClosingStructureInflowModelTypeConverter.cs (revision 0)
+++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/ConfigurationClosingStructureInflowModelTypeConverter.cs (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -0,0 +1,126 @@
+// 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.
+
+using System;
+using System.ComponentModel;
+using System.Globalization;
+using Ringtoets.ClosingStructures.Data;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.IO.Configurations;
+using Ringtoets.Common.IO.Schema;
+
+namespace Ringtoets.ClosingStructures.IO
+{
+ ///
+ /// Converts to
+ /// or and back.
+ ///
+ public class ConfigurationClosingStructureInflowModelTypeConverter : TypeConverter
+ {
+ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
+ {
+ if (destinationType == typeof(ClosingStructureInflowModelType))
+ {
+ return true;
+ }
+ return base.CanConvertTo(context, destinationType);
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == typeof(string))
+ {
+ var type = (ConfigurationClosingStructureInflowModelType)value;
+ switch (type)
+ {
+ case ConfigurationClosingStructureInflowModelType.FloodedCulvert:
+ return ClosingStructuresConfigurationSchemaIdentifiers.FloodedCulvert;
+ case ConfigurationClosingStructureInflowModelType.LowSill:
+ return ClosingStructuresConfigurationSchemaIdentifiers.LowSill;
+ case ConfigurationClosingStructureInflowModelType.VerticalWall:
+ return ClosingStructuresConfigurationSchemaIdentifiers.VerticalWall;
+ default:
+ throw new NotSupportedException();
+ }
+ }
+ if (destinationType == typeof(ClosingStructureInflowModelType))
+ {
+ var type = (ConfigurationClosingStructureInflowModelType)value;
+ switch (type)
+ {
+ case ConfigurationClosingStructureInflowModelType.FloodedCulvert:
+ return ClosingStructureInflowModelType.FloodedCulvert;
+ case ConfigurationClosingStructureInflowModelType.LowSill:
+ return ClosingStructureInflowModelType.LowSill;
+ case ConfigurationClosingStructureInflowModelType.VerticalWall:
+ return ClosingStructureInflowModelType.VerticalWall;
+ default:
+ throw new NotSupportedException();
+ }
+ }
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ if (sourceType == typeof(string))
+ {
+ return true;
+ }
+ if (sourceType == typeof(ClosingStructureInflowModelType))
+ {
+ return true;
+ }
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ var text = value as string;
+ if (text != null)
+ {
+ switch (text)
+ {
+ case ClosingStructuresConfigurationSchemaIdentifiers.FloodedCulvert:
+ return ConfigurationClosingStructureInflowModelType.FloodedCulvert;
+ case ClosingStructuresConfigurationSchemaIdentifiers.LowSill:
+ return ConfigurationClosingStructureInflowModelType.LowSill;
+ case ClosingStructuresConfigurationSchemaIdentifiers.VerticalWall:
+ return ConfigurationClosingStructureInflowModelType.VerticalWall;
+ }
+ }
+ var breakWaterType = value as ClosingStructureInflowModelType?;
+ if (breakWaterType != null)
+ {
+ switch (breakWaterType)
+ {
+ case ClosingStructureInflowModelType.FloodedCulvert:
+ return ConfigurationClosingStructureInflowModelType.FloodedCulvert;
+ case ClosingStructureInflowModelType.LowSill:
+ return ConfigurationClosingStructureInflowModelType.LowSill;
+ case ClosingStructureInflowModelType.VerticalWall:
+ return ConfigurationClosingStructureInflowModelType.VerticalWall;
+ }
+ }
+ return base.ConvertFrom(context, culture, value);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Resources/KunstwerkenBetrouwbaarheidSluitenSchema.xsd
===================================================================
diff -u -r8963d5e5c4a22feba25c4e936e6b67de7104cccd -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Resources/KunstwerkenBetrouwbaarheidSluitenSchema.xsd (.../KunstwerkenBetrouwbaarheidSluitenSchema.xsd) (revision 8963d5e5c4a22feba25c4e936e6b67de7104cccd)
+++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Resources/KunstwerkenBetrouwbaarheidSluitenSchema.xsd (.../KunstwerkenBetrouwbaarheidSluitenSchema.xsd) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -65,7 +65,7 @@
-
+
Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Ringtoets.ClosingStructures.IO.csproj
===================================================================
diff -u -r8963d5e5c4a22feba25c4e936e6b67de7104cccd -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Ringtoets.ClosingStructures.IO.csproj (.../Ringtoets.ClosingStructures.IO.csproj) (revision 8963d5e5c4a22feba25c4e936e6b67de7104cccd)
+++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Ringtoets.ClosingStructures.IO.csproj (.../Ringtoets.ClosingStructures.IO.csproj) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -38,15 +38,18 @@
+
Properties\GlobalAssembly.cs
+
+
True
Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/ClosingStructuresCalculationConfigurationWriterTest.cs
===================================================================
diff -u
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/ClosingStructuresCalculationConfigurationWriterTest.cs (revision 0)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/ClosingStructuresCalculationConfigurationWriterTest.cs (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -0,0 +1,195 @@
+// 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.
+
+using System.Collections.Generic;
+using System.IO;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.IO.Configurations;
+using Ringtoets.Common.IO.TestUtil;
+using Ringtoets.Common.IO.Writers;
+
+namespace Ringtoets.ClosingStructures.IO.Test
+{
+ [TestFixture]
+ public class ClosingStructuresCalculationConfigurationWriterTest
+ : CustomSchemaCalculationConfigurationWriterDesignGuidelinesTestFixture<
+ ClosingStructuresCalculationConfigurationWriter,
+ ClosingStructuresCalculationConfiguration>
+ {
+ private readonly string testDataPath = TestHelper.GetTestDataPath(
+ TestDataPath.Ringtoets.ClosingStructures.IO,
+ nameof(ClosingStructuresCalculationConfigurationWriter));
+
+ private static IEnumerable Calculations
+ {
+ get
+ {
+ yield return new TestCaseData("completeConfiguration", new[]
+ {
+ CreateFullCalculation()
+ })
+ .SetName("Calculation configuration with all parameters set");
+ yield return new TestCaseData("sparseConfiguration", new[]
+ {
+ new ClosingStructuresCalculationConfiguration("sparse config")
+ })
+ .SetName("Calculation configuration with none of its parameters set");
+ yield return new TestCaseData("folderWithSubfolderAndCalculation", new IConfigurationItem[]
+ {
+ new CalculationGroupConfiguration("Testmap", new IConfigurationItem[]
+ {
+ CreateFullCalculation(),
+ new CalculationGroupConfiguration("Nested", new IConfigurationItem[]
+ {
+ new ClosingStructuresCalculationConfiguration("Berekening 2")
+ })
+ })
+ })
+ .SetName("Calculation configurations in a hierarchy");
+ }
+ }
+
+ protected override void AssertDefaultConstructedInstance(ClosingStructuresCalculationConfigurationWriter writer)
+ {
+ Assert.IsInstanceOf>(writer);
+ }
+
+ [Test]
+ [TestCaseSource(nameof(Calculations))]
+ public void Write_ValidCalculation_ValidFile(string expectedFileName, IConfigurationItem[] configuration)
+ {
+ // Setup
+ string filePath = TestHelper.GetScratchPadPath($"{nameof(ClosingStructuresCalculationConfigurationWriterTest)}.{nameof(Write_ValidCalculation_ValidFile)}.{expectedFileName}.xml");
+
+ try
+ {
+ var writer = new ClosingStructuresCalculationConfigurationWriter(filePath);
+
+ // Call
+ writer.Write(configuration);
+
+ // Assert
+ Assert.IsTrue(File.Exists(filePath));
+
+ string actualXml = File.ReadAllText(filePath);
+ string expectedXmlFilePath = Path.Combine(testDataPath, $"{expectedFileName}.xml");
+ string expectedXml = File.ReadAllText(expectedXmlFilePath);
+
+ Assert.AreEqual(expectedXml, actualXml);
+ }
+ finally
+ {
+ File.Delete(filePath);
+ }
+ }
+
+ private static ClosingStructuresCalculationConfiguration CreateFullCalculation()
+ {
+ return new ClosingStructuresCalculationConfiguration("Berekening 1")
+ {
+ HydraulicBoundaryLocationName = "Locatie1",
+ StructureName = "kunstwerk1",
+ ForeshoreProfileName = "profiel1",
+ FailureProbabilityStructureWithErosion = 1e-4,
+ StructureNormalOrientation = 67.1,
+ FactorStormDurationOpenStructure = 1.0,
+ IdenticalApertures = 1,
+ ProbabilityOrFrequencyOpenStructureBeforeFlooding = 1e-2,
+ FailureProbabilityOpenStructure = 1e-3,
+ FailureProbabilityReparation = 1e-2,
+ InflowModelType = ConfigurationClosingStructureInflowModelType.LowSill,
+ WaveReduction = new WaveReductionConfiguration
+ {
+ UseBreakWater = true,
+ BreakWaterType = ConfigurationBreakWaterType.Dam,
+ BreakWaterHeight = 1.23,
+ UseForeshoreProfile = true
+ },
+ FlowWidthAtBottomProtection = new MeanStandardDeviationStochastConfiguration
+ {
+ Mean = 15.2,
+ StandardDeviation = 0.1
+ },
+ WidthFlowApertures = new MeanStandardDeviationStochastConfiguration
+ {
+ Mean = 13.2,
+ StandardDeviation = 0.3
+ },
+ StorageStructureArea = new MeanVariationCoefficientStochastConfiguration
+ {
+ Mean = 15000,
+ VariationCoefficient = 0.01
+ },
+ CriticalOvertoppingDischarge = new MeanVariationCoefficientStochastConfiguration
+ {
+ Mean = 2,
+ VariationCoefficient = 0.1
+ },
+ ModelFactorSuperCriticalFlow = new MeanStandardDeviationStochastConfiguration
+ {
+ Mean = 1.1,
+ StandardDeviation = 0.14
+ },
+ AllowedLevelIncreaseStorage = new MeanStandardDeviationStochastConfiguration
+ {
+ Mean = 0.2,
+ StandardDeviation = 0.01
+ },
+ StormDuration = new MeanVariationCoefficientStochastConfiguration
+ {
+ Mean = 6.0,
+ VariationCoefficient = 0.22
+ },
+ DrainCoefficient = new MeanStandardDeviationStochastConfiguration
+ {
+ Mean = 1.1,
+ StandardDeviation = 0.02
+ },
+ InsideWaterLevel = new MeanStandardDeviationStochastConfiguration
+ {
+ Mean = 0.5,
+ StandardDeviation = 0.1
+ },
+ AreaFlowApertures = new MeanStandardDeviationStochastConfiguration
+ {
+ Mean = 80.5,
+ StandardDeviation = 1
+ },
+ ThresholdHeightOpenWeir = new MeanStandardDeviationStochastConfiguration
+ {
+ Mean = 1.2,
+ StandardDeviation = 0.1
+ },
+ LevelCrestStructureNotClosing = new MeanStandardDeviationStochastConfiguration
+ {
+ Mean = 4.3,
+ StandardDeviation = 0.2
+ }
+ };
+ }
+
+ protected override ClosingStructuresCalculationConfigurationWriter CreateWriterInstance(string filePath)
+ {
+ return new ClosingStructuresCalculationConfigurationWriter(filePath);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/ConfigurationClosingStructureInflowModelTypeConverterTest.cs
===================================================================
diff -u
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/ConfigurationClosingStructureInflowModelTypeConverterTest.cs (revision 0)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/ConfigurationClosingStructureInflowModelTypeConverterTest.cs (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -0,0 +1,216 @@
+// 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.
+
+using System;
+using System.ComponentModel;
+using NUnit.Framework;
+using Ringtoets.ClosingStructures.Data;
+
+namespace Ringtoets.ClosingStructures.IO.Test
+{
+ [TestFixture]
+ public class ConfigurationClosingStructureInflowModelTypeConverterTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var converter = new ConfigurationClosingStructureInflowModelTypeConverter();
+
+ // Assert
+ Assert.IsInstanceOf(converter);
+ }
+
+ [Test]
+ public void CanConvertTo_String_ReturnTrue()
+ {
+ // Setup
+ var converter = new ConfigurationClosingStructureInflowModelTypeConverter();
+
+ // Call
+ bool canConvertToString = converter.CanConvertTo(typeof(string));
+
+ // Assert
+ Assert.IsTrue(canConvertToString);
+ }
+
+ [Test]
+ public void CanConvertTo_ClosingStructureInflowModelType_ReturnTrue()
+ {
+ // Setup
+ var converter = new ConfigurationClosingStructureInflowModelTypeConverter();
+
+ // Call
+ bool canConvertToString = converter.CanConvertTo(typeof(ClosingStructureInflowModelType));
+
+ // Assert
+ Assert.IsTrue(canConvertToString);
+ }
+
+ [Test]
+ public void CanConvertTo_OtherThanStringOrClosingStructureInflowModelType_ReturnFalse()
+ {
+ // Setup
+ var converter = new ConfigurationClosingStructureInflowModelTypeConverter();
+
+ // Call
+ bool canConvertToString = converter.CanConvertTo(typeof(object));
+
+ // Assert
+ Assert.IsFalse(canConvertToString);
+ }
+
+ [Test]
+ [TestCase(ConfigurationClosingStructureInflowModelType.FloodedCulvert, ClosingStructuresConfigurationSchemaIdentifiers.FloodedCulvert)]
+ [TestCase(ConfigurationClosingStructureInflowModelType.LowSill, ClosingStructuresConfigurationSchemaIdentifiers.LowSill)]
+ [TestCase(ConfigurationClosingStructureInflowModelType.VerticalWall, ClosingStructuresConfigurationSchemaIdentifiers.VerticalWall)]
+ public void ConvertTo_VariousCases_ReturnExpectedText(ConfigurationClosingStructureInflowModelType value,
+ string expectedResult)
+ {
+ // Setup
+ var converter = new ConfigurationClosingStructureInflowModelTypeConverter();
+
+ // Call
+ object result = converter.ConvertTo(value, typeof(string));
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+
+ [Test]
+ public void ConvertTo_InvalidClosingStructureInflowModelType_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new ConfigurationClosingStructureInflowModelTypeConverter();
+ var invalidValue = (ConfigurationClosingStructureInflowModelType)99999999;
+
+ // Call
+ TestDelegate call = () => converter.ConvertTo(invalidValue, typeof(string));
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ [TestCase(ConfigurationClosingStructureInflowModelType.FloodedCulvert, ClosingStructureInflowModelType.FloodedCulvert)]
+ [TestCase(ConfigurationClosingStructureInflowModelType.LowSill, ClosingStructureInflowModelType.LowSill)]
+ [TestCase(ConfigurationClosingStructureInflowModelType.VerticalWall, ClosingStructureInflowModelType.VerticalWall)]
+ public void ConvertTo_VariousCases_ReturnExpectedText(ConfigurationClosingStructureInflowModelType value,
+ ClosingStructureInflowModelType expectedResult)
+ {
+ // Setup
+ var converter = new ConfigurationClosingStructureInflowModelTypeConverter();
+
+ // Call
+ object result = converter.ConvertTo(value, typeof(ClosingStructureInflowModelType));
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+
+ [Test]
+ public void CanConvertFrom_String_ReturnTrue()
+ {
+ // Setup
+ var converter = new ConfigurationClosingStructureInflowModelTypeConverter();
+
+ // Call
+ bool canConvertFromString = converter.CanConvertFrom(typeof(string));
+
+ // Assert
+ Assert.IsTrue(canConvertFromString);
+ }
+
+ [Test]
+ public void CanConvertFrom_ClosingStructureInflowModelType_ReturnTrue()
+ {
+ // Setup
+ var converter = new ConfigurationClosingStructureInflowModelTypeConverter();
+
+ // Call
+ bool canConvertFromString = converter.CanConvertFrom(typeof(ClosingStructureInflowModelType));
+
+ // Assert
+ Assert.IsTrue(canConvertFromString);
+ }
+
+ [Test]
+ public void CanConvertFrom_OtherThanStringOrClosingStructureInflowModelType_ReturnFalse()
+ {
+ // Setup
+ var converter = new ConfigurationClosingStructureInflowModelTypeConverter();
+
+ // Call
+ bool canConvertFromString = converter.CanConvertFrom(typeof(object));
+
+ // Assert
+ Assert.IsFalse(canConvertFromString);
+ }
+
+ [Test]
+ [TestCase(ClosingStructuresConfigurationSchemaIdentifiers.FloodedCulvert,ConfigurationClosingStructureInflowModelType.FloodedCulvert)]
+ [TestCase(ClosingStructuresConfigurationSchemaIdentifiers.LowSill, ConfigurationClosingStructureInflowModelType.LowSill)]
+ [TestCase(ClosingStructuresConfigurationSchemaIdentifiers.VerticalWall, ConfigurationClosingStructureInflowModelType.VerticalWall)]
+ public void ConvertFrom_Text_ReturnExpectedClosingStructureInflowModelType(string value,
+ ConfigurationClosingStructureInflowModelType expectedResult)
+ {
+ // Setup
+ var converter = new ConfigurationClosingStructureInflowModelTypeConverter();
+
+ // Call
+ object result = converter.ConvertFrom(value);
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+
+ [Test]
+ public void ConvertFrom_InvalidText_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new ConfigurationClosingStructureInflowModelTypeConverter();
+
+ // Call
+ TestDelegate call = () => converter.ConvertFrom("A");
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ [TestCase(ClosingStructureInflowModelType.FloodedCulvert, ConfigurationClosingStructureInflowModelType.FloodedCulvert)]
+ [TestCase(ClosingStructureInflowModelType.LowSill, ConfigurationClosingStructureInflowModelType.LowSill)]
+ [TestCase(ClosingStructureInflowModelType.VerticalWall, ConfigurationClosingStructureInflowModelType.VerticalWall)]
+ public void ConvertFrom_ClosingStructureInflowModelType_ReturnExpectedClosingStructureInflowModelType(ClosingStructureInflowModelType value,
+ ConfigurationClosingStructureInflowModelType expectedResult)
+ {
+ // Setup
+ var converter = new ConfigurationClosingStructureInflowModelTypeConverter();
+
+ // Call
+ object result = converter.ConvertFrom(value);
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+
+ }
+}
\ No newline at end of file
Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/Ringtoets.ClosingStructures.IO.Test.csproj
===================================================================
diff -u -r8963d5e5c4a22feba25c4e936e6b67de7104cccd -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/Ringtoets.ClosingStructures.IO.Test.csproj (.../Ringtoets.ClosingStructures.IO.Test.csproj) (revision 8963d5e5c4a22feba25c4e936e6b67de7104cccd)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/Ringtoets.ClosingStructures.IO.Test.csproj (.../Ringtoets.ClosingStructures.IO.Test.csproj) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -51,6 +51,8 @@
+
+
@@ -76,6 +78,10 @@
{52BA7627-CBAB-4209-BE77-3B5F31378277}
Ringtoets.Common.IO
+
+ {33508D7C-1602-4C0D-8503-73AAE98C19E5}
+ Ringtoets.Common.IO.TestUtil
+
{C6309704-D67B-434C-BC98-9F8910BC1D10}
Ringtoets.ClosingStructures.Data
Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/test-data/ClosingStructuresCalculationConfigurationWriter/completeConfiguration.xml
===================================================================
diff -u
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/test-data/ClosingStructuresCalculationConfigurationWriter/completeConfiguration.xml (revision 0)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/test-data/ClosingStructuresCalculationConfigurationWriter/completeConfiguration.xml (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -0,0 +1,72 @@
+
+
+
+ Locatie1
+ kunstwerk1
+ 67.1
+ 0.0001
+ profiel1
+ lagedrempel
+ 1
+ 1
+ 0.01
+ 0.001
+ 0.01
+
+ true
+ havendam
+ 1.23
+ true
+
+
+
+ 15.2
+ 0.1
+
+
+ 13.2
+ 0.3
+
+
+ 15000
+ 0.01
+
+
+ 2
+ 0.1
+
+
+ 1.1
+ 0.14
+
+
+ 0.2
+ 0.01
+
+
+ 6
+ 0.22
+
+
+ 1.1
+ 0.02
+
+
+ 0.5
+ 0.1
+
+
+ 80.5
+ 1
+
+
+ 1.2
+ 0.1
+
+
+ 4.3
+ 0.2
+
+
+
+
\ No newline at end of file
Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/test-data/ClosingStructuresCalculationConfigurationWriter/folderWithSubfolderAndCalculation.xml
===================================================================
diff -u
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/test-data/ClosingStructuresCalculationConfigurationWriter/folderWithSubfolderAndCalculation.xml (revision 0)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/test-data/ClosingStructuresCalculationConfigurationWriter/folderWithSubfolderAndCalculation.xml (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -0,0 +1,79 @@
+
+
+
+
\ No newline at end of file
Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/test-data/ClosingStructuresCalculationConfigurationWriter/sparseConfiguration.xml
===================================================================
diff -u
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/test-data/ClosingStructuresCalculationConfigurationWriter/sparseConfiguration.xml (revision 0)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/test-data/ClosingStructuresCalculationConfigurationWriter/sparseConfiguration.xml (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/Helpers/ConfigurationBreakWaterTypeConverter.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/Helpers/ConfigurationBreakWaterTypeConverter.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/Helpers/ConfigurationBreakWaterTypeConverter.cs (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -0,0 +1,124 @@
+// 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.
+
+using System;
+using System.ComponentModel;
+using System.Globalization;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.IO.Schema;
+
+namespace Ringtoets.Common.IO.Configurations.Helpers
+{
+ ///
+ /// Converts to or
+ /// and back.
+ ///
+ public class ConfigurationBreakWaterTypeConverter : TypeConverter
+ {
+ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
+ {
+ if (destinationType == typeof(BreakWaterType))
+ {
+ return true;
+ }
+ return base.CanConvertTo(context, destinationType);
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == typeof(string))
+ {
+ var type = (ConfigurationBreakWaterType) value;
+ switch (type)
+ {
+ case ConfigurationBreakWaterType.Caisson:
+ return ConfigurationSchemaIdentifiers.BreakWaterCaisson;
+ case ConfigurationBreakWaterType.Dam:
+ return ConfigurationSchemaIdentifiers.BreakWaterDam;
+ case ConfigurationBreakWaterType.Wall:
+ return ConfigurationSchemaIdentifiers.BreakWaterWall;
+ default:
+ throw new NotSupportedException();
+ }
+ }
+ if (destinationType == typeof(BreakWaterType))
+ {
+ var type = (ConfigurationBreakWaterType)value;
+ switch (type)
+ {
+ case ConfigurationBreakWaterType.Caisson:
+ return BreakWaterType.Caisson;
+ case ConfigurationBreakWaterType.Dam:
+ return BreakWaterType.Dam;
+ case ConfigurationBreakWaterType.Wall:
+ return BreakWaterType.Wall;
+ default:
+ throw new NotSupportedException();
+ }
+ }
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ if (sourceType == typeof(string))
+ {
+ return true;
+ }
+ if (sourceType == typeof(BreakWaterType))
+ {
+ return true;
+ }
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ var text = value as string;
+ if (text != null)
+ {
+ switch (text)
+ {
+ case ConfigurationSchemaIdentifiers.BreakWaterCaisson:
+ return ConfigurationBreakWaterType.Caisson;
+ case ConfigurationSchemaIdentifiers.BreakWaterDam:
+ return ConfigurationBreakWaterType.Dam;
+ case ConfigurationSchemaIdentifiers.BreakWaterWall:
+ return ConfigurationBreakWaterType.Wall;
+ }
+ }
+ var breakWaterType = value as BreakWaterType?;
+ if (breakWaterType != null)
+ {
+ switch (breakWaterType)
+ {
+ case BreakWaterType.Caisson:
+ return ConfigurationBreakWaterType.Caisson;
+ case BreakWaterType.Dam:
+ return ConfigurationBreakWaterType.Dam;
+ case BreakWaterType.Wall:
+ return ConfigurationBreakWaterType.Wall;
+ }
+ }
+ return base.ConvertFrom(context, culture, value);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag c0c4d914f97d3471b73898030db0066dced39331 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/Helpers/SchemaBreakWaterTypeConverter.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj
===================================================================
diff -u -r8963d5e5c4a22feba25c4e936e6b67de7104cccd -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 8963d5e5c4a22feba25c4e936e6b67de7104cccd)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -62,7 +62,7 @@
-
+
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Writers/CalculationConfigurationWriter.cs
===================================================================
diff -u -r8963d5e5c4a22feba25c4e936e6b67de7104cccd -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/Common/src/Ringtoets.Common.IO/Writers/CalculationConfigurationWriter.cs (.../CalculationConfigurationWriter.cs) (revision 8963d5e5c4a22feba25c4e936e6b67de7104cccd)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Writers/CalculationConfigurationWriter.cs (.../CalculationConfigurationWriter.cs) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -196,7 +196,7 @@
private static string BreakWaterTypeAsXmlString(ConfigurationBreakWaterType type)
{
- return new SchemaBreakWaterTypeConverter().ConvertToInvariantString(type);
+ return new ConfigurationBreakWaterTypeConverter().ConvertToInvariantString(type);
}
private static void WriteDistribution(IDistribution distribution, string elementName, XmlWriter writer)
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Writers/XmlWriterExtensions.cs
===================================================================
diff -u -r82db5c5ee21fae9e20fee1412dbb29b1c47b038a -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/Common/src/Ringtoets.Common.IO/Writers/XmlWriterExtensions.cs (.../XmlWriterExtensions.cs) (revision 82db5c5ee21fae9e20fee1412dbb29b1c47b038a)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Writers/XmlWriterExtensions.cs (.../XmlWriterExtensions.cs) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -138,7 +138,7 @@
}
if (waveReduction.BreakWaterType.HasValue)
{
- writer.WriteElementString(ConfigurationSchemaIdentifiers.BreakWaterType, new SchemaBreakWaterTypeConverter().ConvertToInvariantString(waveReduction.BreakWaterType.Value));
+ writer.WriteElementString(ConfigurationSchemaIdentifiers.BreakWaterType, new ConfigurationBreakWaterTypeConverter().ConvertToInvariantString(waveReduction.BreakWaterType.Value));
}
if (waveReduction.BreakWaterHeight.HasValue)
{
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/ConfigurationBreakWaterTypeConverterTest.cs
===================================================================
diff -u -r8963d5e5c4a22feba25c4e936e6b67de7104cccd -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/ConfigurationBreakWaterTypeConverterTest.cs (.../ConfigurationBreakWaterTypeConverterTest.cs) (revision 8963d5e5c4a22feba25c4e936e6b67de7104cccd)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/ConfigurationBreakWaterTypeConverterTest.cs (.../ConfigurationBreakWaterTypeConverterTest.cs) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -36,7 +36,7 @@
public void Constructor_ExpectedValues()
{
// Call
- var converter = new SchemaBreakWaterTypeConverter();
+ var converter = new ConfigurationBreakWaterTypeConverter();
// Assert
Assert.IsInstanceOf(converter);
@@ -46,7 +46,7 @@
public void CanConvertTo_String_ReturnTrue()
{
// Setup
- var converter = new SchemaBreakWaterTypeConverter();
+ var converter = new ConfigurationBreakWaterTypeConverter();
// Call
bool canConvertToString = converter.CanConvertTo(typeof(string));
@@ -59,7 +59,7 @@
public void CanConvertTo_BreakWaterType_ReturnTrue()
{
// Setup
- var converter = new SchemaBreakWaterTypeConverter();
+ var converter = new ConfigurationBreakWaterTypeConverter();
// Call
bool canConvertToString = converter.CanConvertTo(typeof(BreakWaterType));
@@ -72,7 +72,7 @@
public void CanConvertTo_OtherThanStringOrBreakWaterType_ReturnFalse()
{
// Setup
- var converter = new SchemaBreakWaterTypeConverter();
+ var converter = new ConfigurationBreakWaterTypeConverter();
// Call
bool canConvertToString = converter.CanConvertTo(typeof(object));
@@ -89,7 +89,7 @@
string expectedResult)
{
// Setup
- var converter = new SchemaBreakWaterTypeConverter();
+ var converter = new ConfigurationBreakWaterTypeConverter();
// Call
object result = converter.ConvertTo(value, typeof(string));
@@ -102,7 +102,7 @@
public void ConvertTo_InvalidBreakWaterType_ThrowNotSupportedException()
{
// Setup
- var converter = new SchemaBreakWaterTypeConverter();
+ var converter = new ConfigurationBreakWaterTypeConverter();
var invalidValue = (ConfigurationBreakWaterType) 99999999;
// Call
@@ -120,7 +120,7 @@
BreakWaterType expectedResult)
{
// Setup
- var converter = new SchemaBreakWaterTypeConverter();
+ var converter = new ConfigurationBreakWaterTypeConverter();
// Call
object result = converter.ConvertTo(value, typeof(BreakWaterType));
@@ -133,7 +133,7 @@
public void CanConvertFrom_String_ReturnTrue()
{
// Setup
- var converter = new SchemaBreakWaterTypeConverter();
+ var converter = new ConfigurationBreakWaterTypeConverter();
// Call
bool canConvertFromString = converter.CanConvertFrom(typeof(string));
@@ -146,7 +146,7 @@
public void CanConvertFrom_BreakWaterType_ReturnTrue()
{
// Setup
- var converter = new SchemaBreakWaterTypeConverter();
+ var converter = new ConfigurationBreakWaterTypeConverter();
// Call
bool canConvertFromString = converter.CanConvertFrom(typeof(BreakWaterType));
@@ -159,7 +159,7 @@
public void CanConvertFrom_OtherThanStringOrBreakWaterType_ReturnFalse()
{
// Setup
- var converter = new SchemaBreakWaterTypeConverter();
+ var converter = new ConfigurationBreakWaterTypeConverter();
// Call
bool canConvertFromString = converter.CanConvertFrom(typeof(object));
@@ -176,7 +176,7 @@
ConfigurationBreakWaterType expectedResult)
{
// Setup
- var converter = new SchemaBreakWaterTypeConverter();
+ var converter = new ConfigurationBreakWaterTypeConverter();
// Call
object result = converter.ConvertFrom(value);
@@ -189,7 +189,7 @@
public void ConvertFrom_InvalidText_ThrowNotSupportedException()
{
// Setup
- var converter = new SchemaBreakWaterTypeConverter();
+ var converter = new ConfigurationBreakWaterTypeConverter();
// Call
TestDelegate call = () => converter.ConvertFrom("A");
@@ -206,7 +206,7 @@
ConfigurationBreakWaterType expectedResult)
{
// Setup
- var converter = new SchemaBreakWaterTypeConverter();
+ var converter = new ConfigurationBreakWaterTypeConverter();
// Call
object result = converter.ConvertFrom(value);
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/XmlWriterExtensionsTest.cs
===================================================================
diff -u -r8963d5e5c4a22feba25c4e936e6b67de7104cccd -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/XmlWriterExtensionsTest.cs (.../XmlWriterExtensionsTest.cs) (revision 8963d5e5c4a22feba25c4e936e6b67de7104cccd)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/XmlWriterExtensionsTest.cs (.../XmlWriterExtensionsTest.cs) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -399,7 +399,8 @@
public void WriteWaveReduction_WithoutDifferentSetParameters_WritesStochastWithSetParameters(WaveReductionConfiguration waveReduction, string fileName)
{
// Setup
- string filePath = TestHelper.GetScratchPadPath(nameof(WriteWaveReduction_WithoutDifferentSetParameters_WritesStochastWithSetParameters));
+ string filePath = TestHelper.GetScratchPadPath(
+ $"{nameof(WriteWaveReduction_WithoutDifferentSetParameters_WritesStochastWithSetParameters)}.{fileName}");
try
{
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Readers/GrassCoverErosionInwardsCalculationConfigurationReader.cs
===================================================================
diff -u -r8963d5e5c4a22feba25c4e936e6b67de7104cccd -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Readers/GrassCoverErosionInwardsCalculationConfigurationReader.cs (.../GrassCoverErosionInwardsCalculationConfigurationReader.cs) (revision 8963d5e5c4a22feba25c4e936e6b67de7104cccd)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Readers/GrassCoverErosionInwardsCalculationConfigurationReader.cs (.../GrassCoverErosionInwardsCalculationConfigurationReader.cs) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -93,7 +93,7 @@
DikeHeightCalculationType = (ReadDikeHeightCalculationType?) calculationElement.GetConvertedValueFromDescendantStringElement(
GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.DikeHeightCalculationTypeElement),
UseBreakWater = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseBreakWater),
- BreakWaterType = (ConfigurationBreakWaterType?) calculationElement.GetConvertedValueFromDescendantStringElement(ConfigurationSchemaIdentifiers.BreakWaterType),
+ BreakWaterType = (ConfigurationBreakWaterType?) calculationElement.GetConvertedValueFromDescendantStringElement(ConfigurationSchemaIdentifiers.BreakWaterType),
BreakWaterHeight = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.BreakWaterHeight),
UseForeshore = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseForeshore)
};
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationExporter.cs
===================================================================
diff -u -r8963d5e5c4a22feba25c4e936e6b67de7104cccd -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationExporter.cs (.../HeightStructuresCalculationConfigurationExporter.cs) (revision 8963d5e5c4a22feba25c4e936e6b67de7104cccd)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationExporter.cs (.../HeightStructuresCalculationConfigurationExporter.cs) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -75,7 +75,7 @@
{
UseForeshoreProfile = input.UseForeshore,
UseBreakWater = input.UseBreakWater,
- BreakWaterType = (ConfigurationBreakWaterType?) new SchemaBreakWaterTypeConverter().ConvertFrom(input.BreakWater.Type),
+ BreakWaterType = (ConfigurationBreakWaterType?) new ConfigurationBreakWaterTypeConverter().ConvertFrom(input.BreakWater.Type),
BreakWaterHeight = input.BreakWater.Height
};
}
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationImporter.cs
===================================================================
diff -u -r99681405f4c6e99e9db1d14b508d863158624650 -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationImporter.cs (.../HeightStructuresCalculationConfigurationImporter.cs) (revision 99681405f4c6e99e9db1d14b508d863158624650)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationImporter.cs (.../HeightStructuresCalculationConfigurationImporter.cs) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -453,7 +453,7 @@
if (waveReduction.BreakWaterType.HasValue)
{
- calculation.InputParameters.BreakWater.Type = (BreakWaterType) new SchemaBreakWaterTypeConverter().ConvertTo(waveReduction.BreakWaterType.Value, typeof(BreakWaterType));
+ calculation.InputParameters.BreakWater.Type = (BreakWaterType) new ConfigurationBreakWaterTypeConverter().ConvertTo(waveReduction.BreakWaterType.Value, typeof(BreakWaterType));
}
if (waveReduction.BreakWaterHeight.HasValue)
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationReader.cs
===================================================================
diff -u -r8963d5e5c4a22feba25c4e936e6b67de7104cccd -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationReader.cs (.../HeightStructuresCalculationConfigurationReader.cs) (revision 8963d5e5c4a22feba25c4e936e6b67de7104cccd)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationReader.cs (.../HeightStructuresCalculationConfigurationReader.cs) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -123,7 +123,7 @@
{
return new WaveReductionConfiguration
{
- BreakWaterType = (ConfigurationBreakWaterType?) calculationElement.GetConvertedValueFromDescendantStringElement(ConfigurationSchemaIdentifiers.BreakWaterType),
+ BreakWaterType = (ConfigurationBreakWaterType?) calculationElement.GetConvertedValueFromDescendantStringElement(ConfigurationSchemaIdentifiers.BreakWaterType),
BreakWaterHeight = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.BreakWaterHeight),
UseBreakWater = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseBreakWater),
UseForeshoreProfile = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseForeshore)
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/HeightStructuresCalculationConfigurationWriterTest.cs
===================================================================
diff -u -r8963d5e5c4a22feba25c4e936e6b67de7104cccd -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/HeightStructuresCalculationConfigurationWriterTest.cs (.../HeightStructuresCalculationConfigurationWriterTest.cs) (revision 8963d5e5c4a22feba25c4e936e6b67de7104cccd)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/HeightStructuresCalculationConfigurationWriterTest.cs (.../HeightStructuresCalculationConfigurationWriterTest.cs) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -21,10 +21,8 @@
using System.Collections.Generic;
using System.IO;
-using Core.Common.Base.Data;
using Core.Common.TestUtil;
using NUnit.Framework;
-using Ringtoets.Common.IO;
using Ringtoets.Common.IO.Configurations;
using Ringtoets.Common.IO.TestUtil;
using Ringtoets.Common.IO.Writers;
@@ -66,7 +64,7 @@
})
})
})
- .SetName("Calculation configuration with none of its parameters set");
+ .SetName("Calculation configurations in a hierarchy");
}
}
@@ -80,7 +78,7 @@
public void Write_ValidCalculation_ValidFile(string expectedFileName, IConfigurationItem[] configuration)
{
// Setup
- string filePath = TestHelper.GetScratchPadPath("test.xml");
+ string filePath = TestHelper.GetScratchPadPath($"{nameof(HeightStructuresCalculationConfigurationWriterTest)}.{nameof(Write_ValidCalculation_ValidFile)}.{expectedFileName}.xml");
try
{
@@ -122,41 +120,43 @@
},
StormDuration = new MeanVariationCoefficientStochastConfiguration
{
- Mean = (RoundedDouble) 6.0
+ Mean = 6.0,
+ VariationCoefficient= 0.22
},
ModelFactorSuperCriticalFlow = new MeanStandardDeviationStochastConfiguration
{
- Mean = (RoundedDouble) 1.10
+ Mean = 1.1,
+ StandardDeviation = 0.14
},
FlowWidthAtBottomProtection = new MeanStandardDeviationStochastConfiguration
{
- Mean = (RoundedDouble) 15.2,
- StandardDeviation = (RoundedDouble) 0.1
+ Mean = 15.2,
+ StandardDeviation = 0.1
},
WidthFlowApertures = new MeanStandardDeviationStochastConfiguration
{
- Mean = (RoundedDouble) 13.2,
- StandardDeviation = (RoundedDouble) 0.3
+ Mean = 13.2,
+ StandardDeviation = 0.3
},
StorageStructureArea = new MeanVariationCoefficientStochastConfiguration
{
- Mean = (RoundedDouble) 15000,
- VariationCoefficient = (RoundedDouble) 0.01
+ Mean = 15000,
+ VariationCoefficient = 0.01
},
AllowedLevelIncreaseStorage = new MeanStandardDeviationStochastConfiguration
{
- Mean = (RoundedDouble) 0.2,
- StandardDeviation = (RoundedDouble) 0.01
+ Mean = 0.2,
+ StandardDeviation = 0.01
},
LevelCrestStructure = new MeanStandardDeviationStochastConfiguration
{
- Mean = (RoundedDouble) 4.3,
- StandardDeviation = (RoundedDouble) 0.2
+ Mean = 4.3,
+ StandardDeviation = 0.2
},
CriticalOvertoppingDischarge = new MeanVariationCoefficientStochastConfiguration
{
- Mean = (RoundedDouble) 2,
- VariationCoefficient = (RoundedDouble) 0.1
+ Mean = 2,
+ VariationCoefficient = 0.1
}
};
}
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationWriter/completeConfiguration.xml
===================================================================
diff -u -r01bf64868d92c60de88996ec6052f5aeec2c98b3 -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationWriter/completeConfiguration.xml (.../completeConfiguration.xml) (revision 01bf64868d92c60de88996ec6052f5aeec2c98b3)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationWriter/completeConfiguration.xml (.../completeConfiguration.xml) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -31,13 +31,15 @@
1.1
+ 0.14
0.2
0.01
6
+ 0.22
4.3
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationWriter/folderWithSubfolderAndCalculation.xml
===================================================================
diff -u -raafce5702ca1008a5b523f82d2c6b0ae91fcb1df -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationWriter/folderWithSubfolderAndCalculation.xml (.../folderWithSubfolderAndCalculation.xml) (revision aafce5702ca1008a5b523f82d2c6b0ae91fcb1df)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationWriter/folderWithSubfolderAndCalculation.xml (.../folderWithSubfolderAndCalculation.xml) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -32,13 +32,15 @@
1.1
+ 0.14
0.2
0.01
6
+ 0.22
4.3
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/WaveConditionsCalculationConfigurationReader.cs
===================================================================
diff -u -r8963d5e5c4a22feba25c4e936e6b67de7104cccd -rc0c4d914f97d3471b73898030db0066dced39331
--- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/WaveConditionsCalculationConfigurationReader.cs (.../WaveConditionsCalculationConfigurationReader.cs) (revision 8963d5e5c4a22feba25c4e936e6b67de7104cccd)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/WaveConditionsCalculationConfigurationReader.cs (.../WaveConditionsCalculationConfigurationReader.cs) (revision c0c4d914f97d3471b73898030db0066dced39331)
@@ -90,7 +90,7 @@
ForeshoreProfile = calculationElement.GetStringValueFromDescendantElement(WaveConditionsCalculationConfigurationSchemaIdentifiers.ForeshoreProfile),
Orientation = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.Orientation),
UseBreakWater = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseBreakWater),
- BreakWaterType = (ConfigurationBreakWaterType?) calculationElement.GetConvertedValueFromDescendantStringElement(ConfigurationSchemaIdentifiers.BreakWaterType),
+ BreakWaterType = (ConfigurationBreakWaterType?) calculationElement.GetConvertedValueFromDescendantStringElement(ConfigurationSchemaIdentifiers.BreakWaterType),
BreakWaterHeight = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.BreakWaterHeight),
UseForeshore = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseForeshore)
};