Index: Core/Common/src/Core.Common.IO/Readers/SqLiteDatabaseReaderBase.cs
===================================================================
diff -u -r7bf9203d0aa5bbed07732c7b38f7e272639120d8 -re4565100f14feece0bea5bc7acf9eef9acf7a8e6
--- Core/Common/src/Core.Common.IO/Readers/SqLiteDatabaseReaderBase.cs (.../SqLiteDatabaseReaderBase.cs) (revision 7bf9203d0aa5bbed07732c7b38f7e272639120d8)
+++ Core/Common/src/Core.Common.IO/Readers/SqLiteDatabaseReaderBase.cs (.../SqLiteDatabaseReaderBase.cs) (revision e4565100f14feece0bea5bc7acf9eef9acf7a8e6)
@@ -44,7 +44,6 @@
/// - The contains invalid characters.
/// - No file could be found at .
/// - Unable to open database file.
- /// - Preparing the queries to read from the database failed.
///
///
protected SqLiteDatabaseReaderBase(string databaseFilePath)
Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/HydraulicBoundaryDatabaseImporter.cs
===================================================================
diff -u -rf27092df1f897798c4a0b24f6fc91f49c9f294ce -re4565100f14feece0bea5bc7acf9eef9acf7a8e6
--- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/HydraulicBoundaryDatabaseImporter.cs (.../HydraulicBoundaryDatabaseImporter.cs) (revision f27092df1f897798c4a0b24f6fc91f49c9f294ce)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/HydraulicBoundaryDatabaseImporter.cs (.../HydraulicBoundaryDatabaseImporter.cs) (revision e4565100f14feece0bea5bc7acf9eef9acf7a8e6)
@@ -25,6 +25,7 @@
using Core.Common.Utils.Builders;
using log4net;
using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.IO.HydraRing;
using Ringtoets.Common.IO.Properties;
using Ringtoets.HydraRing.Data;
using Ringtoets.HydraRing.IO.HydraulicBoundaryDatabaseContext;
Fisheye: Tag e4565100f14feece0bea5bc7acf9eef9acf7a8e6 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/HydraulicBoundaryLocationFilter.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Common/src/Ringtoets.Common.IO/HydraRing/HydraRingSettingsDatabaseReader.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.IO/HydraRing/HydraRingSettingsDatabaseReader.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/HydraRing/HydraRingSettingsDatabaseReader.cs (revision e4565100f14feece0bea5bc7acf9eef9acf7a8e6)
@@ -0,0 +1,296 @@
+// 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 System.ComponentModel;
+using System.Data;
+using System.Data.SQLite;
+using Core.Common.IO.Exceptions;
+using Core.Common.IO.Readers;
+using Ringtoets.HydraRing.Calculation.Data;
+using Ringtoets.HydraRing.Calculation.Data.Settings;
+
+namespace Ringtoets.Common.IO.HydraRing
+{
+ ///
+ /// This class is responsible for reading values from the Hydra-Ring settings database and creating
+ /// settings from them.
+ ///
+ public class HydraRingSettingsDatabaseReader : SqLiteDatabaseReaderBase
+ {
+ private const string calculationTechniqueIdColumn = "CalculationMethod";
+ private const string formStartMethodColumn = "FORM_StartMethod";
+ private const string formNumberOfIterationsColumn = "FORM_NIterations";
+ private const string formRelaxationFactorColumn = "FORM_RelaxationFactor";
+ private const string formEpsBetaColumn = "FORM_EpsBeta";
+ private const string formEpsHohColumn = "FORM_EpsHOH";
+ private const string formEpsZFuncColumn = "FORM_EpsZFunc";
+ private const string dsStartMethodColumn = "DS_StartMethod";
+ private const string dsMinNumberOfIterationsColumn = "DS_Min";
+ private const string dsMaxNumberOfIterationsColumn = "DS_Max";
+ private const string dsVarCoefficientColumn = "DS_VarCoefficient";
+ private const string niUMinColumn = "NI_UMin";
+ private const string niUMaxColumn = "NI_UMax";
+ private const string niNumberStepsColumn = "NI_NumberSteps";
+
+ private const string minColumn = "Min";
+ private const string maxColumn = "Max";
+
+ private string locationIdColumn = "LocationID";
+
+ private const string locationIdParameterName = "@locationId";
+ private const string calculationTypeIdParameterName = "@calculationTypeId";
+ private const string mechanismIdParameterName = "@mechanismID";
+ private const string subMechanismIdParameterName = "@subMechanismID";
+ private const string timeIntegrationSchemeIdColumn = "TimeIntegrationSchemeID";
+
+ private readonly string designTableSettingsForLocationAndCalculationTypeQuery;
+ private readonly string numericSettingsForLocationMechanismAndSubMechanismQuery;
+ private readonly string excludedLocationsQuery;
+ private readonly string timeIntegrationSettingsForLocationAndCalculationTypeQuery;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The full path to the database file to use when reading settings.
+ /// Thrown when:
+ ///
+ /// - The contains invalid characters.
+ /// - No file could be found at .
+ /// - Unable to open database file.
+ ///
+ ///
+ public HydraRingSettingsDatabaseReader(string databaseFilePath)
+ : base(databaseFilePath)
+ {
+ designTableSettingsForLocationAndCalculationTypeQuery = string.Format(
+ "SELECT {0}, {1} FROM DesignTablesSettings WHERE LocationID = {2} AND CalculationTypeID = {3}",
+ minColumn,
+ maxColumn,
+ locationIdParameterName,
+ calculationTypeIdParameterName);
+
+ numericSettingsForLocationMechanismAndSubMechanismQuery = string.Format(
+ "SELECT {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13} " +
+ "FROM NumericsSettings WHERE LocationID = {14} AND MechanismID = {15} AND SubMechanismID = {16}",
+ calculationTechniqueIdColumn,
+ formStartMethodColumn,
+ formNumberOfIterationsColumn,
+ formRelaxationFactorColumn,
+ formEpsBetaColumn,
+ formEpsHohColumn,
+ formEpsZFuncColumn,
+ dsStartMethodColumn,
+ dsMinNumberOfIterationsColumn,
+ dsMaxNumberOfIterationsColumn,
+ dsVarCoefficientColumn,
+ niUMinColumn,
+ niUMaxColumn,
+ niNumberStepsColumn,
+ locationIdParameterName,
+ mechanismIdParameterName,
+ subMechanismIdParameterName);
+
+ timeIntegrationSettingsForLocationAndCalculationTypeQuery = string.Format(
+ "SELECT {0} FROM TimeIntegrationSettings WHERE LocationID = {1} AND CalculationTypeID = {2}",
+ timeIntegrationSchemeIdColumn,
+ locationIdParameterName,
+ calculationTypeIdParameterName);
+
+ excludedLocationsQuery = string.Format(
+ "SELECT {0} FROM ExcludedLocations",
+ locationIdColumn);
+ }
+
+ ///
+ /// Read a design tables setting for a given location and .
+ ///
+ /// The id of a hydraulic boundary location.
+ /// The type of the calculation to obtain the for.
+ /// A new containing values read from the database.
+ /// Thrown when is not a valid
+ /// value.
+ public DesignTablesSetting ReadDesignTableSetting(long locationId, HydraRingFailureMechanismType calculationType)
+ {
+ if (!Enum.IsDefined(calculationType.GetType(), calculationType))
+ {
+ throw new InvalidEnumArgumentException("calculationType", (int) calculationType, calculationType.GetType());
+ }
+
+ var reader = CreateDesignTablesDataReader(locationId, calculationType);
+ if (MoveNext(reader))
+ {
+ return new DesignTablesSetting(
+ Convert.ToDouble(reader[minColumn]),
+ Convert.ToDouble(reader[maxColumn]));
+ }
+ return null;
+ }
+
+ ///
+ /// Read a numerics setting for a given location and .
+ ///
+ /// The id of a hydraulic boundary location.
+ /// The mechanism id to obtain the for.
+ /// The sub mechanism id to obtain the for.
+ /// A new containing values read from the database.
+ public NumericsSetting ReadNumericsSetting(long locationId, int mechanimsId, int subMechanismId)
+ {
+ var reader = CreateNumericsSettingsDataReader(locationId, mechanimsId, subMechanismId);
+ if (MoveNext(reader))
+ {
+ return new NumericsSetting(
+ Convert.ToInt32(reader[calculationTechniqueIdColumn]),
+ Convert.ToInt32(reader[formStartMethodColumn]),
+ Convert.ToInt32(reader[formNumberOfIterationsColumn]),
+ Convert.ToDouble(reader[formRelaxationFactorColumn]),
+ Convert.ToDouble(reader[formEpsBetaColumn]),
+ Convert.ToDouble(reader[formEpsHohColumn]),
+ Convert.ToDouble(reader[formEpsZFuncColumn]),
+ Convert.ToInt32(reader[dsStartMethodColumn]),
+ Convert.ToInt32(reader[dsMinNumberOfIterationsColumn]),
+ Convert.ToInt32(reader[dsMaxNumberOfIterationsColumn]),
+ Convert.ToDouble(reader[dsVarCoefficientColumn]),
+ Convert.ToDouble(reader[niUMinColumn]),
+ Convert.ToDouble(reader[niUMaxColumn]),
+ Convert.ToInt32(reader[niNumberStepsColumn]));
+ }
+ return null;
+ }
+
+ ///
+ /// Read a time integration setting for a given location and .
+ ///
+ /// The id of a hydraulic boundary location.
+ /// The type of the calculation to obtain the for.
+ /// A new containing values read from the database.
+ /// Thrown when is not a valid
+ /// value.
+ public HydraulicModelsSetting ReadTimeIntegrationSetting(long locationId, HydraRingFailureMechanismType calculationType)
+ {
+ if (!Enum.IsDefined(calculationType.GetType(), calculationType))
+ {
+ throw new InvalidEnumArgumentException("calculationType", (int)calculationType, calculationType.GetType());
+ }
+
+ var reader = CreateTimeIntegrationDataReader(locationId, calculationType);
+ if (MoveNext(reader))
+ {
+ return new HydraulicModelsSetting(
+ Convert.ToInt32(reader[timeIntegrationSchemeIdColumn]));
+ }
+ return null;
+ }
+
+ ///
+ /// Reads the excluded locations (those for which no calculation is possible) from the database.
+ ///
+ /// A of id's for all the excluded locations.
+ public IEnumerable ReadExcludedLocations()
+ {
+ var reader = CreateExcludedLocationsDataReader();
+ while (MoveNext(reader))
+ {
+ yield return Convert.ToInt64(reader[locationIdColumn]);
+ }
+ }
+
+ private SQLiteDataReader CreateDesignTablesDataReader(long locationId, HydraRingFailureMechanismType calculationType)
+ {
+ var locationParameter = new SQLiteParameter
+ {
+ DbType = DbType.Int64,
+ ParameterName = locationIdParameterName,
+ Value = locationId
+ };
+
+ var typeParameter = new SQLiteParameter
+ {
+ DbType = DbType.Int32,
+ ParameterName = calculationTypeIdParameterName,
+ Value = (int)calculationType
+ };
+
+ return CreateDataReader(
+ designTableSettingsForLocationAndCalculationTypeQuery,
+ locationParameter,
+ typeParameter);
+ }
+
+ private SQLiteDataReader CreateNumericsSettingsDataReader(long locationId, int mechanimsId, int subMechanismId)
+ {
+ var locationParameter = new SQLiteParameter
+ {
+ DbType = DbType.Int64,
+ ParameterName = locationIdParameterName,
+ Value = locationId
+ };
+
+ var mechanismIdParameter = new SQLiteParameter
+ {
+ DbType = DbType.Int32,
+ ParameterName = mechanismIdParameterName,
+ Value = mechanimsId
+ };
+
+ var subMechanismIdParameter = new SQLiteParameter
+ {
+ DbType = DbType.Int32,
+ ParameterName = subMechanismIdParameterName,
+ Value = subMechanismId
+ };
+
+ return CreateDataReader(
+ numericSettingsForLocationMechanismAndSubMechanismQuery,
+ locationParameter,
+ mechanismIdParameter,
+ subMechanismIdParameter);
+ }
+
+ private SQLiteDataReader CreateTimeIntegrationDataReader(long locationId, HydraRingFailureMechanismType calculationType)
+ {
+ var locationParameter = new SQLiteParameter
+ {
+ DbType = DbType.Int64,
+ ParameterName = locationIdParameterName,
+ Value = locationId
+ };
+
+ var typeParameter = new SQLiteParameter
+ {
+ DbType = DbType.Int32,
+ ParameterName = calculationTypeIdParameterName,
+ Value = (int)calculationType
+ };
+
+ return CreateDataReader(
+ timeIntegrationSettingsForLocationAndCalculationTypeQuery,
+ locationParameter,
+ typeParameter);
+ }
+
+ private SQLiteDataReader CreateExcludedLocationsDataReader()
+ {
+ return CreateDataReader(excludedLocationsQuery);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.IO/HydraRing/HydraulicBoundaryLocationFilter.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.IO/HydraRing/HydraulicBoundaryLocationFilter.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/HydraRing/HydraulicBoundaryLocationFilter.cs (revision e4565100f14feece0bea5bc7acf9eef9acf7a8e6)
@@ -0,0 +1,63 @@
+// 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 System.Linq;
+using Ringtoets.Common.IO.Properties;
+using Ringtoets.HydraRing.Data;
+
+namespace Ringtoets.Common.IO.HydraRing
+{
+ ///
+ /// This class allows for filtering out based
+ /// on their name.
+ ///
+ public class HydraulicBoundaryLocationFilter
+ {
+ private readonly List locationsToFilterOut;
+
+ public HydraulicBoundaryLocationFilter()
+ {
+ string[] idsAsText = Resources.HydraulicBoundaryLocationsFilterList.Split(new[]
+ {
+ Environment.NewLine,
+ "\n"
+ }, StringSplitOptions.RemoveEmptyEntries);
+ var filterList = new List(idsAsText.Skip(1).Select(long.Parse)); // Skip the header, parse the remainder
+ filterList.Sort();
+
+ locationsToFilterOut = filterList;
+ }
+
+ ///
+ /// Indicates if the with
+ /// should be imported.
+ ///
+ /// The name of the location.
+ /// True if the location should be imported, false otherwise.
+ public bool ShouldInclude(long locationId)
+ {
+ int matchingIndex = locationsToFilterOut.BinarySearch(locationId);
+ return matchingIndex < 0;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj
===================================================================
diff -u -r2b2da37541708b8ad95286e731010dd9d27d5070 -re4565100f14feece0bea5bc7acf9eef9acf7a8e6
--- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 2b2da37541708b8ad95286e731010dd9d27d5070)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision e4565100f14feece0bea5bc7acf9eef9acf7a8e6)
@@ -40,6 +40,11 @@
+
+
+ ..\..\..\..\packages\System.Data.SQLite.Core.1.0.99.0\lib\net40\System.Data.SQLite.dll
+ True
+
@@ -59,7 +64,8 @@
-
+
+
@@ -119,6 +125,11 @@
Core.Components.Gis
False
+
+ {888D4097-8BC2-4703-9FB1-8744C94D525E}
+ Ringtoets.HydraRing.Calculation
+ False
+
{70f8cc9c-5bc8-4fb2-b201-eae7fa8088c2}
Ringtoets.HydraRing.Data
@@ -143,6 +154,13 @@
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
\ No newline at end of file
Fisheye: Tag e4565100f14feece0bea5bc7acf9eef9acf7a8e6 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/HydraulicBoundaryLocationFilterTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/HydraRing/HydraRingSettingsDatabaseReaderTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/HydraRing/HydraRingSettingsDatabaseReaderTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/HydraRing/HydraRingSettingsDatabaseReaderTest.cs (revision e4565100f14feece0bea5bc7acf9eef9acf7a8e6)
@@ -0,0 +1,271 @@
+// 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.ComponentModel;
+using System.IO;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.IO.HydraRing;
+using Ringtoets.HydraRing.Calculation.Data;
+using Ringtoets.HydraRing.Calculation.Data.Settings;
+
+namespace Ringtoets.Common.IO.Test.HydraRing
+{
+ [TestFixture]
+ public class HydraRingSettingsDatabaseReaderTest
+ {
+ private static readonly string completeDatabaseDataPath = TestHelper.GetTestDataPath(
+ TestDataPath.Ringtoets.Common.IO,
+ Path.Combine("HydraRingSettingsDatabaseReader", "7_67.config.sqlite"));
+
+ private static readonly string emptyDatabaseDataPath = TestHelper.GetTestDataPath(
+ TestDataPath.Ringtoets.Common.IO,
+ Path.Combine("HydraRingSettingsDatabaseReader", "7_67-empty.config.sqlite"));
+
+ [Test]
+ [TestCase(-1)]
+ [TestCase(12)]
+ [TestCase(15)]
+ public void ReadDesignTableSetting_InvalidFailureMechanismType_ThrowsInvalidEnumArgumentException(HydraRingFailureMechanismType calculationType)
+ {
+ // Setup
+ var reader = new HydraRingSettingsDatabaseReader(completeDatabaseDataPath);
+
+ // Call
+ TestDelegate test = () => reader.ReadDesignTableSetting(123, calculationType);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ [TestCase(700131, 0, 0.29, 2.29)]
+ [TestCase(700131, 3, 1.0, 5.0)]
+ [TestCase(700134, 2, -2.0, 0.0)]
+ [TestCase(700135, 4, 2.0, 5.0)]
+ public void ReadDesignTableSetting_ValidLocationIdAndFailureMechanismType_DesignTableSettingWithExpectedValues(
+ long locationId, HydraRingFailureMechanismType calculationType, double expectedMin, double expectedMax)
+ {
+ // Setup
+ var reader = new HydraRingSettingsDatabaseReader(completeDatabaseDataPath);
+
+ // Call
+ DesignTablesSetting setting = reader.ReadDesignTableSetting(locationId, calculationType);
+
+ // Assert
+ Assert.AreEqual(expectedMin, setting.ValueMin);
+ Assert.AreEqual(expectedMax, setting.ValueMax);
+ }
+
+ [Test]
+ [TestCase(700134, 7)]
+ [TestCase(0, 5)]
+ public void ReadDesignTableSetting_ValidLocationIdAndFailureMechanismTypeNotInDatabase_ReturnNull(long locationId, HydraRingFailureMechanismType calculationType)
+ {
+ // Setup
+ var reader = new HydraRingSettingsDatabaseReader(completeDatabaseDataPath);
+
+ // Call
+ DesignTablesSetting setting = reader.ReadDesignTableSetting(locationId, calculationType);
+
+ // Assert
+ Assert.IsNull(setting);
+ }
+
+ [Test]
+ public void ReadDesignTableSetting_EmptyTable_ReturnNull()
+ {
+ // Setup
+ var reader = new HydraRingSettingsDatabaseReader(emptyDatabaseDataPath);
+
+ // Call
+ DesignTablesSetting setting = reader.ReadDesignTableSetting(700131, 0);
+
+ // Assert
+ Assert.IsNull(setting);
+ }
+
+ [Test]
+ [TestCase(-1)]
+ [TestCase(12)]
+ [TestCase(15)]
+ public void ReadTimeIntegrationSetting_InvalidFailureMechanismType_ThrowsInvalidEnumArgumentException(HydraRingFailureMechanismType calculationType)
+ {
+ // Setup
+ var reader = new HydraRingSettingsDatabaseReader(completeDatabaseDataPath);
+
+ // Call
+ TestDelegate test = () => reader.ReadTimeIntegrationSetting(123, calculationType);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ [TestCase(700131, 0, 1)]
+ [TestCase(700131, 3, 1)]
+ [TestCase(700134, 2, 1)]
+ [TestCase(700135, 4, 1)]
+ public void ReadTimeIntegrationSetting_ValidLocationIdAndFailureMechanismType_DesignTableSettingWithExpectedValues(
+ long locationId, HydraRingFailureMechanismType calculationType, int expectedTimeIntegrationScheme)
+ {
+ // Setup
+ var reader = new HydraRingSettingsDatabaseReader(completeDatabaseDataPath);
+
+ // Call
+ HydraulicModelsSetting setting = reader.ReadTimeIntegrationSetting(locationId, calculationType);
+
+ // Assert
+ Assert.AreEqual(expectedTimeIntegrationScheme, setting.TimeIntegrationSchemeId);
+ }
+
+ [Test]
+ [TestCase(15, 10)]
+ [TestCase(0, 5)]
+ public void ReadTimeIntegrationSetting_ValidLocationIdAndFailureMechanismTypeNotInDatabase_ReturnNull(long locationId, HydraRingFailureMechanismType calculationType)
+ {
+ // Setup
+ var reader = new HydraRingSettingsDatabaseReader(completeDatabaseDataPath);
+
+ // Call
+ HydraulicModelsSetting setting = reader.ReadTimeIntegrationSetting(locationId, calculationType);
+
+ // Assert
+ Assert.IsNull(setting);
+ }
+
+ [Test]
+ public void ReadTimeIntegrationSetting_EmptyTable_ReturnNull()
+ {
+ // Setup
+ var reader = new HydraRingSettingsDatabaseReader(emptyDatabaseDataPath);
+
+ // Call
+ HydraulicModelsSetting setting = reader.ReadTimeIntegrationSetting(700131, 0);
+
+ // Assert
+ Assert.IsNull(setting);
+ }
+
+ [Test]
+ [TestCase(700132, 11, 16, 1, 4, 50, 0.15, 0.05, 0.01, 0.01, 0, 2, 20000, 100000.0, 0.1, -6.0, 6)]
+ [TestCase(700135, 3, 5, 4, 1, 50, 0.15, 0.05, 0.01, 0.01, 0, 2, 10000, 10000.0, 0.1, -6.0, 6)]
+ [TestCase(700135, 101, 102, 1, 4, 50, 0.15, 0.05, 0.01, 0.01, 0, 2, 20000, 100000.0, 0.1, -6.0, 6)]
+ public void ReadNumericsSetting_ValidLocationIdAndFailureMechanismType_DesignTableSettingWithExpectedValues(
+ long locationId,
+ int mechanismId,
+ int subMechanismId,
+ int expectedCalculationTechniqueId,
+ int expectedFormStartMethod,
+ int expectedFormNumberOfIterations,
+ double expectedFormRelaxationFactor,
+ double expectedFormEpsBeta,
+ double expectedFormEpsHoh,
+ double expectedFormEpsZFunc,
+ int expectedDsStartMethod,
+ int expectedDsMinNumberOfIterations,
+ int expectedDsMaxNumberOfIterations,
+ double expectedDsVarCoefficient,
+ double expectedNiUMin,
+ double expectedNiUMax,
+ int expectedNiNumberSteps)
+ {
+ // Setup
+ var reader = new HydraRingSettingsDatabaseReader(completeDatabaseDataPath);
+
+ // Call
+ NumericsSetting setting = reader.ReadNumericsSetting(locationId, mechanismId, subMechanismId);
+
+ // Assert
+ Assert.AreEqual(expectedCalculationTechniqueId, setting.CalculationTechniqueId);
+ Assert.AreEqual(expectedFormStartMethod, setting.FormStartMethod);
+ Assert.AreEqual(expectedFormNumberOfIterations, setting.FormNumberOfIterations);
+ Assert.AreEqual(expectedFormRelaxationFactor, setting.FormRelaxationFactor);
+ Assert.AreEqual(expectedFormEpsBeta, setting.FormEpsBeta);
+ Assert.AreEqual(expectedFormEpsHoh, setting.FormEpsHoh);
+ Assert.AreEqual(expectedFormEpsZFunc, setting.FormEpsZFunc);
+ Assert.AreEqual(expectedDsStartMethod, setting.DsStartMethod);
+ Assert.AreEqual(expectedDsMinNumberOfIterations, setting.DsMinNumberOfIterations);
+ Assert.AreEqual(expectedDsMaxNumberOfIterations, setting.DsMaxNumberOfIterations);
+ Assert.AreEqual(expectedDsVarCoefficient, setting.DsVarCoefficient);
+ Assert.AreEqual(expectedNiUMin, setting.NiUMin);
+ Assert.AreEqual(expectedNiUMax, setting.NiUMax);
+ Assert.AreEqual(expectedNiNumberSteps, setting.NiNumberSteps);
+ }
+
+ [Test]
+ [TestCase(700134, 7, 14)]
+ [TestCase(0, 5, 11)]
+ [TestCase(700134, 5, 25)]
+ public void ReadNumericsSetting_ValidLocationIdFailureMechanismTypeAndSubMechanismIdNotInDatabase_ReturnNull(
+ long locationId, int mechanismId, int subMechanismId)
+ {
+ // Setup
+ var reader = new HydraRingSettingsDatabaseReader(completeDatabaseDataPath);
+
+ // Call
+ NumericsSetting setting = reader.ReadNumericsSetting(locationId, mechanismId, subMechanismId);
+
+ // Assert
+ Assert.IsNull(setting);
+ }
+
+ [Test]
+ public void ReadNumericsSetting_EmptyTable_ReturnNull()
+ {
+ // Setup
+ var reader = new HydraRingSettingsDatabaseReader(emptyDatabaseDataPath);
+
+ // Call
+ NumericsSetting setting = reader.ReadNumericsSetting(700135, 101, 102);
+
+ // Assert
+ Assert.IsNull(setting);
+ }
+
+ [Test]
+ public void ReadExcludedLocations_TableWithRows_ReturnsAllLocationIdsInTable()
+ {
+ // Setup
+ var reader = new HydraRingSettingsDatabaseReader(completeDatabaseDataPath);
+
+ // Call
+ IEnumerable locations = reader.ReadExcludedLocations();
+
+ // Assert
+ CollectionAssert.AreEqual(new [] { 700141, 700142, 700143, 700146 }, locations);
+ }
+
+ [Test]
+ public void ReadExcludedLocations_EmptyTable_ReturnsEmptyList()
+ {
+ // Setup
+ var reader = new HydraRingSettingsDatabaseReader(emptyDatabaseDataPath);
+
+ // Call
+ IEnumerable locations = reader.ReadExcludedLocations();
+
+ // Assert
+ Assert.IsEmpty(locations);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/HydraRing/HydraulicBoundaryLocationFilterTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/HydraRing/HydraulicBoundaryLocationFilterTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/HydraRing/HydraulicBoundaryLocationFilterTest.cs (revision e4565100f14feece0bea5bc7acf9eef9acf7a8e6)
@@ -0,0 +1,65 @@
+// 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 NUnit.Framework;
+using Ringtoets.Common.IO.HydraRing;
+
+namespace Ringtoets.Common.IO.Test.HydraRing
+{
+ [TestFixture]
+ public class HydraulicBoundaryLocationFilterTest
+ {
+ [Test]
+ [TestCase(-1)]
+ [TestCase(long.MinValue)]
+ [TestCase(303192)]
+ [TestCase(303196)]
+ [TestCase(602961)]
+ [TestCase(603017)]
+ [TestCase(long.MaxValue)]
+ public void ShouldInclude_NameNotInFilterSet_ReturnsTrue(long id)
+ {
+ // Setup
+ var filter = new HydraulicBoundaryLocationFilter();
+
+ // Call
+ bool shouldBeIncluded = filter.ShouldInclude(id);
+
+ // Assert
+ Assert.IsTrue(shouldBeIncluded);
+ }
+
+ [Test]
+ [TestCase(303193)]
+ [TestCase(603075)]
+ public void ShouldInclude_NameInFilterSet_ReturnsFalse(long id)
+ {
+ // Setup
+ var filter = new HydraulicBoundaryLocationFilter();
+
+ // Call
+ bool shouldBeIncluded = filter.ShouldInclude(id);
+
+ // Assert
+ Assert.IsFalse(shouldBeIncluded);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj
===================================================================
diff -u -r2b2da37541708b8ad95286e731010dd9d27d5070 -re4565100f14feece0bea5bc7acf9eef9acf7a8e6
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 2b2da37541708b8ad95286e731010dd9d27d5070)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision e4565100f14feece0bea5bc7acf9eef9acf7a8e6)
@@ -46,6 +46,7 @@
+
..\..\..\..\packages\System.Data.SQLite.Core.1.0.99.0\lib\net40\System.Data.SQLite.dll
True
@@ -66,9 +67,10 @@
-
+
+
@@ -106,6 +108,10 @@
{d749ee4c-ce50-4c17-bf01-9a953028c126}
Core.Common.TestUtil
+
+ {888D4097-8BC2-4703-9FB1-8744C94D525E}
+ Ringtoets.HydraRing.Calculation
+
{70f8cc9c-5bc8-4fb2-b201-eae7fa8088c2}
Ringtoets.HydraRing.Data
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/HydraRingSettingsDatabaseReader/7_67-empty.config.sqlite
===================================================================
diff -u
Binary files differ
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/HydraRingSettingsDatabaseReader/7_67.config.sqlite
===================================================================
diff -u
Binary files differ
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Data/Settings/DesignTablesSetting.cs
===================================================================
diff -u -r03b153b8f94dc5ff3619bdd52c79394a0d7fde85 -re4565100f14feece0bea5bc7acf9eef9acf7a8e6
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Data/Settings/DesignTablesSetting.cs (.../DesignTablesSetting.cs) (revision 03b153b8f94dc5ff3619bdd52c79394a0d7fde85)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Data/Settings/DesignTablesSetting.cs (.../DesignTablesSetting.cs) (revision e4565100f14feece0bea5bc7acf9eef9acf7a8e6)
@@ -24,7 +24,7 @@
///
/// Container for design tables settings.
///
- internal class DesignTablesSetting
+ public class DesignTablesSetting
{
private readonly double valueMin;
private readonly double valueMax;
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Data/Settings/HydraulicModelsSetting.cs
===================================================================
diff -u -rf744bb990260662f885d34811a1ea042dae18550 -re4565100f14feece0bea5bc7acf9eef9acf7a8e6
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Data/Settings/HydraulicModelsSetting.cs (.../HydraulicModelsSetting.cs) (revision f744bb990260662f885d34811a1ea042dae18550)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Data/Settings/HydraulicModelsSetting.cs (.../HydraulicModelsSetting.cs) (revision e4565100f14feece0bea5bc7acf9eef9acf7a8e6)
@@ -24,7 +24,7 @@
///
/// Container for hydraulic models settings.
///
- internal class HydraulicModelsSetting
+ public class HydraulicModelsSetting
{
private readonly int timeIntegrationSchemeId;
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Data/Settings/NumericsSetting.cs
===================================================================
diff -u -rc7843d3b8c846c4aab66ba32e67f883b6555932b -re4565100f14feece0bea5bc7acf9eef9acf7a8e6
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Data/Settings/NumericsSetting.cs (.../NumericsSetting.cs) (revision c7843d3b8c846c4aab66ba32e67f883b6555932b)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Data/Settings/NumericsSetting.cs (.../NumericsSetting.cs) (revision e4565100f14feece0bea5bc7acf9eef9acf7a8e6)
@@ -24,7 +24,7 @@
///
/// Container for numerics settings.
///
- internal class NumericsSetting
+ public class NumericsSetting
{
private readonly int calculationTechniqueId;
private readonly int formStartMethod;
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryDatabaseContext/HydraulicBoundarySqLiteDatabaseReader.cs
===================================================================
diff -u -rce31448a066c084f755439f3e7d453bfb042b291 -re4565100f14feece0bea5bc7acf9eef9acf7a8e6
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryDatabaseContext/HydraulicBoundarySqLiteDatabaseReader.cs (.../HydraulicBoundarySqLiteDatabaseReader.cs) (revision ce31448a066c084f755439f3e7d453bfb042b291)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryDatabaseContext/HydraulicBoundarySqLiteDatabaseReader.cs (.../HydraulicBoundarySqLiteDatabaseReader.cs) (revision e4565100f14feece0bea5bc7acf9eef9acf7a8e6)
@@ -70,10 +70,7 @@
HasNext = false;
string locationsQuery = HydraulicBoundaryDatabaseQueryBuilder.GetRelevantLocationsQuery();
- sqliteDataReader = CreateDataReader(locationsQuery, new SQLiteParameter
- {
- DbType = DbType.String
- });
+ sqliteDataReader = CreateDataReader(locationsQuery);
MoveNext();
}
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Calculator/HydraRingCalculatorBaseTest.cs
===================================================================
diff -u -rbd73023d5f8926a411da214fb5ce522056a0e30a -re4565100f14feece0bea5bc7acf9eef9acf7a8e6
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Calculator/HydraRingCalculatorBaseTest.cs (.../HydraRingCalculatorBaseTest.cs) (revision bd73023d5f8926a411da214fb5ce522056a0e30a)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Calculator/HydraRingCalculatorBaseTest.cs (.../HydraRingCalculatorBaseTest.cs) (revision e4565100f14feece0bea5bc7acf9eef9acf7a8e6)
@@ -105,7 +105,7 @@
{
get
{
- return 0;
+ return HydraRingFailureMechanismType.AssessmentLevel;
}
}