Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/IO/DesignTablesSettingsCsvReader.cs
===================================================================
diff -u -rc99a72f80fc8db3a8a6fd0db0d1181bcda1e0f8f -r1ffce7db57db828039b8e2d5a24715cbaa76f6a8
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/IO/DesignTablesSettingsCsvReader.cs (.../DesignTablesSettingsCsvReader.cs) (revision c99a72f80fc8db3a8a6fd0db0d1181bcda1e0f8f)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/IO/DesignTablesSettingsCsvReader.cs (.../DesignTablesSettingsCsvReader.cs) (revision 1ffce7db57db828039b8e2d5a24715cbaa76f6a8)
@@ -29,7 +29,7 @@
///
/// The reader for in csv format.
///
- internal class DesignTablesSettingsCsvReader : HydraRingSettingsCsvReader>>
+ internal class DesignTablesSettingsCsvReader : HydraRingSettingsVariableCsvReader>>
{
private readonly Dictionary columns = new Dictionary
{
@@ -47,40 +47,6 @@
}
};
- private readonly Dictionary failureMechanismTypes = new Dictionary
- {
- {
- assessmentLevelKey, HydraRingFailureMechanismType.AssessmentLevel
- },
- {
- waveHeightKey, HydraRingFailureMechanismType.WaveHeight
- },
- {
- wavePeakPeriodKey, HydraRingFailureMechanismType.WavePeakPeriod
- },
- {
- waveSpectralPeriodKey, HydraRingFailureMechanismType.WaveSpectralPeriod
- },
- {
- qVariantKey, HydraRingFailureMechanismType.QVariant
- },
- {
- dikeHeightKey, HydraRingFailureMechanismType.DikesHeight
- },
- {
- grassKey, HydraRingFailureMechanismType.DikesOvertopping
- },
- {
- heightStructuresKey, HydraRingFailureMechanismType.StructuresOvertopping
- },
- {
- closingStructuresKey, HydraRingFailureMechanismType.StructuresClosure
- },
- {
- structuresStructuralFailureKey, HydraRingFailureMechanismType.StructuresStructuralFailure
- }
- };
-
///
/// Creates a new instance of .
///
@@ -92,7 +58,7 @@
protected override void CreateSetting(IList line)
{
// Get failure mechanism
- var failureMechanismType = GetFailureMechanismType(line);
+ var failureMechanismType = GetFailureMechanismType(GetStringValueFromElement(line[columns[variableKey]]));
if (!Settings.ContainsKey(failureMechanismType))
{
@@ -107,11 +73,6 @@
}
}
- private HydraRingFailureMechanismType GetFailureMechanismType(IList line)
- {
- return failureMechanismTypes[GetStringValueFromElement(line[columns[variableKey]])];
- }
-
private string GetRingId(IList line)
{
return GetStringValueFromElement(line[columns[ringIdKey]]);
@@ -131,20 +92,5 @@
private const string maxKey = "Max";
#endregion
-
- #region Variable names
-
- private const string assessmentLevelKey = "Toetspeil";
- private const string waveHeightKey = "Hs";
- private const string wavePeakPeriodKey = "Tp";
- private const string waveSpectralPeriodKey = "Tm-1,0";
- private const string qVariantKey = "Q";
- private const string dikeHeightKey = "HBN";
- private const string grassKey = "Gras";
- private const string heightStructuresKey = "KwHoogte";
- private const string closingStructuresKey = "KwSluiten";
- private const string structuresStructuralFailureKey = "KwPuntconstructies";
-
- #endregion
}
}
\ No newline at end of file
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/IO/HydraRingSettingsVariableCsvReader.cs
===================================================================
diff -u
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/IO/HydraRingSettingsVariableCsvReader.cs (revision 0)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/IO/HydraRingSettingsVariableCsvReader.cs (revision 1ffce7db57db828039b8e2d5a24715cbaa76f6a8)
@@ -0,0 +1,104 @@
+// 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.Collections.Generic;
+using Ringtoets.HydraRing.Calculation.Data;
+
+namespace Ringtoets.HydraRing.Calculation.IO
+{
+ ///
+ /// An abstract base for Hydra-Ring settings readers with variable properties.
+ ///
+ /// The output format of the read settings.
+ internal abstract class HydraRingSettingsVariableCsvReader : HydraRingSettingsCsvReader
+ {
+ private readonly Dictionary failureMechanismTypes = new Dictionary
+ {
+ {
+ assessmentLevelKey, HydraRingFailureMechanismType.AssessmentLevel
+ },
+ {
+ waveHeightKey, HydraRingFailureMechanismType.WaveHeight
+ },
+ {
+ wavePeakPeriodKey, HydraRingFailureMechanismType.WavePeakPeriod
+ },
+ {
+ waveSpectralPeriodKey, HydraRingFailureMechanismType.WaveSpectralPeriod
+ },
+ {
+ qVariantKey, HydraRingFailureMechanismType.QVariant
+ },
+ {
+ dikeHeightKey, HydraRingFailureMechanismType.DikesHeight
+ },
+ {
+ grassKey, HydraRingFailureMechanismType.DikesOvertopping
+ },
+ {
+ heightStructuresKey, HydraRingFailureMechanismType.StructuresOvertopping
+ },
+ {
+ closingStructuresKey, HydraRingFailureMechanismType.StructuresClosure
+ },
+ {
+ structuresStructuralFailureKey, HydraRingFailureMechanismType.StructuresStructuralFailure
+ }
+ };
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The file contents to read.
+ /// The provided settings object to add the read settings to.
+ /// Thrown when or is null.
+ protected HydraRingSettingsVariableCsvReader(string fileContents, TOutput settings)
+ : base(fileContents, settings) {}
+
+ protected abstract override void CreateSetting(IList line);
+
+ ///
+ /// Gets the from the variable.
+ ///
+ /// The variable to get the for.
+ /// The .
+ protected HydraRingFailureMechanismType GetFailureMechanismType(string variable)
+ {
+ return failureMechanismTypes[variable];
+ }
+
+ #region Variable names
+
+ private const string assessmentLevelKey = "Toetspeil";
+ private const string waveHeightKey = "Hs";
+ private const string wavePeakPeriodKey = "Tp";
+ private const string waveSpectralPeriodKey = "Tm-1,0";
+ private const string qVariantKey = "Q";
+ private const string dikeHeightKey = "HBN";
+ private const string grassKey = "Gras";
+ private const string heightStructuresKey = "KwHoogte";
+ private const string closingStructuresKey = "KwSluiten";
+ private const string structuresStructuralFailureKey = "KwPuntconstructies";
+
+ #endregion
+ }
+}
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/IO/HydraulicModelsSettingsCsvReader.cs
===================================================================
diff -u -r44d85a660b65ecf101a5cd1e9b0a8eafe7ff8bad -r1ffce7db57db828039b8e2d5a24715cbaa76f6a8
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/IO/HydraulicModelsSettingsCsvReader.cs (.../HydraulicModelsSettingsCsvReader.cs) (revision 44d85a660b65ecf101a5cd1e9b0a8eafe7ff8bad)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/IO/HydraulicModelsSettingsCsvReader.cs (.../HydraulicModelsSettingsCsvReader.cs) (revision 1ffce7db57db828039b8e2d5a24715cbaa76f6a8)
@@ -29,7 +29,7 @@
///
/// The reader for in csv format.
///
- internal class HydraulicModelsSettingsCsvReader : HydraRingSettingsCsvReader>>
+ internal class HydraulicModelsSettingsCsvReader : HydraRingSettingsVariableCsvReader>>
{
private readonly Dictionary columns = new Dictionary
{
@@ -44,40 +44,6 @@
}
};
- private readonly Dictionary failureMechanismTypes = new Dictionary
- {
- {
- assessmentLevelKey, HydraRingFailureMechanismType.AssessmentLevel
- },
- {
- waveHeightKey, HydraRingFailureMechanismType.WaveHeight
- },
- {
- wavePeakPeriodKey, HydraRingFailureMechanismType.WavePeakPeriod
- },
- {
- waveSpectralPeriodKey, HydraRingFailureMechanismType.WaveSpectralPeriod
- },
- {
- qVariantKey, HydraRingFailureMechanismType.QVariant
- },
- {
- dikeHeightKey, HydraRingFailureMechanismType.DikesHeight
- },
- {
- grassKey, HydraRingFailureMechanismType.DikesOvertopping
- },
- {
- heightStructuresKey, HydraRingFailureMechanismType.StructuresOvertopping
- },
- {
- closingStructuresKey, HydraRingFailureMechanismType.StructuresClosure
- },
- {
- structuresStructuralFailureKey, HydraRingFailureMechanismType.StructuresStructuralFailure
- }
- };
-
///
/// Creates a new instance of .
///
@@ -89,7 +55,7 @@
protected override void CreateSetting(IList line)
{
// Get failure mechanism
- var failureMechanismType = GetFailureMechanismType(line);
+ var failureMechanismType = GetFailureMechanismType(GetStringValueFromElement(line[columns[variableKey]]));
if (!Settings.ContainsKey(failureMechanismType))
{
@@ -104,11 +70,6 @@
}
}
- private HydraRingFailureMechanismType GetFailureMechanismType(IList line)
- {
- return failureMechanismTypes[GetStringValueFromElement(line[columns[variableKey]])];
- }
-
private string GetRingId(IList line)
{
return GetStringValueFromElement(line[columns[ringIdKey]]);
@@ -126,20 +87,5 @@
private const string timeIntegrationSchemeIdKey = "TimeIntegrationSchemeIdKey";
#endregion
-
- #region Variable names
-
- private const string assessmentLevelKey = "Toetspeil";
- private const string waveHeightKey = "Hs";
- private const string wavePeakPeriodKey = "Tp";
- private const string waveSpectralPeriodKey = "Tm-1,0";
- private const string qVariantKey = "Q";
- private const string dikeHeightKey = "HBN";
- private const string grassKey = "Gras";
- private const string heightStructuresKey = "KwHoogte";
- private const string closingStructuresKey = "KwSluiten";
- private const string structuresStructuralFailureKey = "KwPuntconstructies";
-
- #endregion
}
}
\ No newline at end of file
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj
===================================================================
diff -u -r44d85a660b65ecf101a5cd1e9b0a8eafe7ff8bad -r1ffce7db57db828039b8e2d5a24715cbaa76f6a8
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj (.../Ringtoets.HydraRing.Calculation.csproj) (revision 44d85a660b65ecf101a5cd1e9b0a8eafe7ff8bad)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj (.../Ringtoets.HydraRing.Calculation.csproj) (revision 1ffce7db57db828039b8e2d5a24715cbaa76f6a8)
@@ -70,6 +70,7 @@
+
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/IO/DesignTablesSettingsCsvReaderTest.cs
===================================================================
diff -u -r44d85a660b65ecf101a5cd1e9b0a8eafe7ff8bad -r1ffce7db57db828039b8e2d5a24715cbaa76f6a8
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/IO/DesignTablesSettingsCsvReaderTest.cs (.../DesignTablesSettingsCsvReaderTest.cs) (revision 44d85a660b65ecf101a5cd1e9b0a8eafe7ff8bad)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/IO/DesignTablesSettingsCsvReaderTest.cs (.../DesignTablesSettingsCsvReaderTest.cs) (revision 1ffce7db57db828039b8e2d5a24715cbaa76f6a8)
@@ -182,7 +182,7 @@
"205", new DesignTablesSetting(5, 15)
}
}
- },
+ }
};
}
}
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/IO/HydraRingSettingsVariableCsvReaderTest.cs
===================================================================
diff -u
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/IO/HydraRingSettingsVariableCsvReaderTest.cs (revision 0)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/IO/HydraRingSettingsVariableCsvReaderTest.cs (revision 1ffce7db57db828039b8e2d5a24715cbaa76f6a8)
@@ -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.Collections.Generic;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.HydraRing.Calculation.Data;
+using Ringtoets.HydraRing.Calculation.IO;
+
+namespace Ringtoets.HydraRing.Calculation.Test.IO
+{
+ [TestFixture]
+ public class HydraRingSettingsVariableCsvReaderTest
+ {
+ [Test]
+ public void Constructor_FileContentsNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => new TestVariableCsvReader(null, new object());
+
+ // Assert
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "File contents must be set.");
+ }
+
+ [Test]
+ public void Constructor_SettingsNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => new TestVariableCsvReader("path.csv", null);
+
+ // Assert
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "The settings object must be provided.");
+ }
+
+ [Test]
+ [TestCase("Toetspeil", HydraRingFailureMechanismType.AssessmentLevel)]
+ [TestCase("Hs", HydraRingFailureMechanismType.WaveHeight)]
+ [TestCase("Tp", HydraRingFailureMechanismType.WavePeakPeriod)]
+ [TestCase("Tm-1,0", HydraRingFailureMechanismType.WaveSpectralPeriod)]
+ [TestCase("Q", HydraRingFailureMechanismType.QVariant)]
+ [TestCase("HBN", HydraRingFailureMechanismType.DikesHeight)]
+ [TestCase("Gras", HydraRingFailureMechanismType.DikesOvertopping)]
+ [TestCase("KwHoogte", HydraRingFailureMechanismType.StructuresOvertopping)]
+ [TestCase("KwSluiten", HydraRingFailureMechanismType.StructuresClosure)]
+ [TestCase("KwPuntconstructies", HydraRingFailureMechanismType.StructuresStructuralFailure)]
+ public void GetFailureMechanismType_Always_ReturnsFailureMechanismType(string variable, HydraRingFailureMechanismType expectedType)
+ {
+ // Setup
+ var reader = new TestVariableCsvReader("path.csv", new object());
+
+ // Call
+ HydraRingFailureMechanismType actualType = reader.TestGetFailureMechanismType(variable);
+
+ // Assert
+ Assert.AreEqual(expectedType, actualType);
+ }
+
+ private class TestVariableCsvReader : HydraRingSettingsVariableCsvReader