Index: Core/Common/test/Core.Common.TestUtil/TestDataPath.cs =================================================================== diff -u -rfea3332b5f7a5cea6b41de4a6368c1f1c2bf1282 -rfe9af51d0ecee9dc64884d9370cf951fe787a8bc --- Core/Common/test/Core.Common.TestUtil/TestDataPath.cs (.../TestDataPath.cs) (revision fea3332b5f7a5cea6b41de4a6368c1f1c2bf1282) +++ Core/Common/test/Core.Common.TestUtil/TestDataPath.cs (.../TestDataPath.cs) (revision fe9af51d0ecee9dc64884d9370cf951fe787a8bc) @@ -34,18 +34,11 @@ public static class Components { - public static readonly TestDataPath DotSpatial = System.IO.Path.Combine("Core", "Components", "test", "Core.Components.DotSpatial.Test"); - public static class Gis { public static readonly TestDataPath IO = System.IO.Path.Combine("Core", "Components", "test", "Core.Components.Gis.IO.Test"); } } - - public static class Plugins - { - public static readonly TestDataPath DotSpatial = System.IO.Path.Combine("Core", "Plugins", "test", "Core.Plugins.DotSpatial.Test"); - } } public static class Ringtoets @@ -58,6 +51,7 @@ public static class HydraRing { public static readonly TestDataPath IO = System.IO.Path.Combine("Ringtoets", "HydraRing", "test", "Ringtoets.HydraRing.IO.Test"); + public static readonly TestDataPath Calculation = System.IO.Path.Combine("Ringtoets", "HydraRing", "test", "Ringtoets.HydraRing.Calculation.Test"); } public static class Integration Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/HydraRingConfiguration.cs =================================================================== diff -u -rdd33f3b9d039c570742b8233da23326538c848cf -rfe9af51d0ecee9dc64884d9370cf951fe787a8bc --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/HydraRingConfiguration.cs (.../HydraRingConfiguration.cs) (revision dd33f3b9d039c570742b8233da23326538c848cf) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/HydraRingConfiguration.cs (.../HydraRingConfiguration.cs) (revision fe9af51d0ecee9dc64884d9370cf951fe787a8bc) @@ -296,7 +296,7 @@ foreach (var subMechanimsId in failureMechanismDefaults.SubMechanismIds) { - var subMechanismSettings = subMechanismSettingsProvider.GetSubMechanismSettings(hydraRingCalculation.FailureMechanismType, subMechanimsId); + var subMechanismSettings = subMechanismSettingsProvider.GetSubMechanismSettings(hydraRingCalculation.FailureMechanismType, subMechanimsId, ringId); orderDictionaries.Add(new OrderedDictionary { Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/IO/HydraRingSettingsCsvReader.cs =================================================================== diff -u -r968645e02cdc2c21c899fa8099589c779138be54 -rfe9af51d0ecee9dc64884d9370cf951fe787a8bc --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/IO/HydraRingSettingsCsvReader.cs (.../HydraRingSettingsCsvReader.cs) (revision 968645e02cdc2c21c899fa8099589c779138be54) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/IO/HydraRingSettingsCsvReader.cs (.../HydraRingSettingsCsvReader.cs) (revision fe9af51d0ecee9dc64884d9370cf951fe787a8bc) @@ -62,16 +62,16 @@ /// /// Creates a new instance of . /// - /// The path to the file to read. - /// Thrown when is not set. - public HydraRingSettingsCsvReader(string path) + /// The file to read. + /// Thrown when is not set. + public HydraRingSettingsCsvReader(string file) { - if (string.IsNullOrEmpty(path)) + if (string.IsNullOrEmpty(file)) { - throw new ArgumentNullException("path", "A path to a file must be set."); + throw new ArgumentNullException("file", "A file must be set."); } - filePath = path; + filePath = file; } /// Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Settings/SubMechanismSettingsProvider.cs =================================================================== diff -u -rdd33f3b9d039c570742b8233da23326538c848cf -rfe9af51d0ecee9dc64884d9370cf951fe787a8bc --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Settings/SubMechanismSettingsProvider.cs (.../SubMechanismSettingsProvider.cs) (revision dd33f3b9d039c570742b8233da23326538c848cf) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Settings/SubMechanismSettingsProvider.cs (.../SubMechanismSettingsProvider.cs) (revision fe9af51d0ecee9dc64884d9370cf951fe787a8bc) @@ -21,6 +21,8 @@ using System.Collections.Generic; using Ringtoets.HydraRing.Calculation.Data; +using Ringtoets.HydraRing.Calculation.IO; +using Ringtoets.HydraRing.Calculation.Properties; namespace Ringtoets.HydraRing.Calculation.Settings { @@ -29,13 +31,45 @@ /// public class SubMechanismSettingsProvider { - private readonly IDictionary> defaultSubMechanismSettings; + private readonly IDictionary>> fileSubMechanismSettings; + private readonly FailureMechanismDefaultsProvider failureMechanismDefaultsProvider; + private IDictionary> defaultSubMechanismSettings; /// /// Creates a new instance of the class. /// public SubMechanismSettingsProvider() { + failureMechanismDefaultsProvider = new FailureMechanismDefaultsProvider(); + + InitializeDefaultSubMechanismSettings(); + + fileSubMechanismSettings = new HydraRingSettingsCsvReader(Resources.HydraRingSettings).ReadSettings(); + } + + /// + /// Returns based on the provided and sub mechanism id. + /// + /// The to obtain the for. + /// The sub mechanism id to obtain the for. + /// The ring id to obtain the for. + /// The corresponding to the provided and sub mechanism id. + public SubMechanismSettings GetSubMechanismSettings(HydraRingFailureMechanismType failureMechanismType, int subMechanismId, string ringId) + { + var mechanismId = failureMechanismDefaultsProvider.GetFailureMechanismDefaults(failureMechanismType).MechanismId; + + if (fileSubMechanismSettings.ContainsKey(mechanismId) && + fileSubMechanismSettings[mechanismId].ContainsKey(subMechanismId) && + fileSubMechanismSettings[mechanismId][subMechanismId].ContainsKey(ringId)) + { + return fileSubMechanismSettings[mechanismId][subMechanismId][ringId]; + } + + return defaultSubMechanismSettings[failureMechanismType][subMechanismId]; + } + + private void InitializeDefaultSubMechanismSettings() + { defaultSubMechanismSettings = new Dictionary> { { @@ -177,16 +211,5 @@ } }; } - - /// - /// Returns based on the provided and sub mechanism id. - /// - /// The to obtain the for. - /// The sub mechanism id to obtain the for. - /// The corresponding to the provided and sub mechanism id. - public SubMechanismSettings GetSubMechanismSettings(HydraRingFailureMechanismType failureMechanismType, int subMechanismId) - { - return defaultSubMechanismSettings[failureMechanismType][subMechanismId]; - } } } \ No newline at end of file Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/IO/HydraRingSettingsCsvReaderTest.cs =================================================================== diff -u -r968645e02cdc2c21c899fa8099589c779138be54 -rfe9af51d0ecee9dc64884d9370cf951fe787a8bc --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/IO/HydraRingSettingsCsvReaderTest.cs (.../HydraRingSettingsCsvReaderTest.cs) (revision 968645e02cdc2c21c899fa8099589c779138be54) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/IO/HydraRingSettingsCsvReaderTest.cs (.../HydraRingSettingsCsvReaderTest.cs) (revision fe9af51d0ecee9dc64884d9370cf951fe787a8bc) @@ -21,17 +21,19 @@ using System; using System.Collections.Generic; +using System.IO; using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.HydraRing.Calculation.IO; using Ringtoets.HydraRing.Calculation.Settings; -using Ringtoets.HydraRing.Calculation.Test.Properties; namespace Ringtoets.HydraRing.Calculation.Test.IO { [TestFixture] public class HydraRingSettingsCsvReaderTest { + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.Calculation, "Settings"); + [Test] public void Constructor_PathSet_DoesNotThrowArgumentNullException() { @@ -49,14 +51,19 @@ TestDelegate call = () => new HydraRingSettingsCsvReader(null); // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "A path to a file must be set."); + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "A file must be set."); } [Test] public void ReadSettings_ValidFile_ReturnsSettings() { // Setup - var reader = new HydraRingSettingsCsvReader(Resources.TestSettings); + var testFile = Path.Combine(testDataPath, "HydraRingSettingsTest.csv"); + + var streamReader = new StreamReader(testFile); + var fileContents = streamReader.ReadToEnd(); + + var reader = new HydraRingSettingsCsvReader(fileContents); var expectedDictionary = GetDictionary(); // Call Fisheye: Tag fe9af51d0ecee9dc64884d9370cf951fe787a8bc refers to a dead (removed) revision in file `Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Properties/Resources.Designer.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag fe9af51d0ecee9dc64884d9370cf951fe787a8bc refers to a dead (removed) revision in file `Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Properties/Resources.resx'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag fe9af51d0ecee9dc64884d9370cf951fe787a8bc refers to a dead (removed) revision in file `Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Resources/Hydra-Ring settings test.csv'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Ringtoets.HydraRing.Calculation.Test.csproj =================================================================== diff -u -r968645e02cdc2c21c899fa8099589c779138be54 -rfe9af51d0ecee9dc64884d9370cf951fe787a8bc --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Ringtoets.HydraRing.Calculation.Test.csproj (.../Ringtoets.HydraRing.Calculation.Test.csproj) (revision 968645e02cdc2c21c899fa8099589c779138be54) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Ringtoets.HydraRing.Calculation.Test.csproj (.../Ringtoets.HydraRing.Calculation.Test.csproj) (revision fe9af51d0ecee9dc64884d9370cf951fe787a8bc) @@ -57,11 +57,6 @@ - - True - True - Resources.resx - @@ -92,14 +87,7 @@ Copying.licenseheader - - - - ResXFileCodeGenerator - Resources.Designer.cs - -