Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Factories/MacroStabilityInwardsExportRegistry.cs =================================================================== diff -u -rc5e749d6f198b9edd2d35bfd137ee8c5dc6b82a8 -r6234fe337ff6b2a02024a021bf29cc28b90cb6d3 --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Factories/MacroStabilityInwardsExportRegistry.cs (.../MacroStabilityInwardsExportRegistry.cs) (revision c5e749d6f198b9edd2d35bfd137ee8c5dc6b82a8) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Factories/MacroStabilityInwardsExportRegistry.cs (.../MacroStabilityInwardsExportRegistry.cs) (revision 6234fe337ff6b2a02024a021bf29cc28b90cb6d3) @@ -35,6 +35,7 @@ private readonly Dictionary soils; private readonly Dictionary geometries; private readonly Dictionary> geometryLayers; + private readonly Dictionary soilLayers; /// /// Creates a new instance of . @@ -45,6 +46,7 @@ soils = new Dictionary(); geometries = new Dictionary(); geometryLayers = new Dictionary>(); + soilLayers = new Dictionary(); } /// @@ -68,6 +70,11 @@ public IReadOnlyDictionary> GeometryLayers => geometryLayers; /// + /// Gets the soil layers and their unique identifiers. + /// + public IReadOnlyDictionary SoilLayers => soilLayers; + + /// /// Adds calculation settings to the registry. /// /// The @@ -143,6 +150,21 @@ } /// + /// Adds a soil layer to the register. + /// + /// The + /// to register the soil layer for. + /// The id of the settings. + /// Thrown when + /// has an invalid value. + public void AddSoilLayer(MacroStabilityInwardsExportStageType stageType, string id) + { + ValidateStageType(stageType); + + soilLayers.Add(stageType, id); + } + + /// /// Validates the . /// /// The stage type to validate. Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Factories/MacroStabilityInwardsExportRegistryTest.cs =================================================================== diff -u -r76b0441378930f0e6052aa3e65332dc23fe4b0be -r6234fe337ff6b2a02024a021bf29cc28b90cb6d3 --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Factories/MacroStabilityInwardsExportRegistryTest.cs (.../MacroStabilityInwardsExportRegistryTest.cs) (revision 76b0441378930f0e6052aa3e65332dc23fe4b0be) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Factories/MacroStabilityInwardsExportRegistryTest.cs (.../MacroStabilityInwardsExportRegistryTest.cs) (revision 6234fe337ff6b2a02024a021bf29cc28b90cb6d3) @@ -45,6 +45,7 @@ CollectionAssert.IsEmpty(registry.Soils); CollectionAssert.IsEmpty(registry.Geometries); CollectionAssert.IsEmpty(registry.GeometryLayers); + CollectionAssert.IsEmpty(registry.SoilLayers); } [Test] @@ -75,9 +76,9 @@ // Assert Assert.AreEqual(1, registry.Settings.Count); - KeyValuePair storedSettings = registry.Settings.Single(); - Assert.AreEqual(stageType, storedSettings.Key); - Assert.AreEqual(id, storedSettings.Value); + KeyValuePair registeredSettings = registry.Settings.Single(); + Assert.AreEqual(stageType, registeredSettings.Key); + Assert.AreEqual(id, registeredSettings.Value); } [Test] @@ -129,7 +130,7 @@ } [Test] - public void AddGeometry_WithGeometry_AddsSettings() + public void AddGeometry_WithGeometry_AddsGeometry() { // Setup var registry = new MacroStabilityInwardsExportRegistry(); @@ -141,9 +142,9 @@ // Assert Assert.AreEqual(1, registry.Geometries.Count); - KeyValuePair storedGeometry = registry.Geometries.Single(); - Assert.AreEqual(stageType, storedGeometry.Key); - Assert.AreEqual(id, storedGeometry.Value); + KeyValuePair registeredGeometry = registry.Geometries.Single(); + Assert.AreEqual(stageType, registeredGeometry.Key); + Assert.AreEqual(id, registeredGeometry.Value); } [Test] @@ -238,5 +239,38 @@ Assert.AreSame(geometryLayer2, registeredGeometry2.Key); Assert.AreEqual(id2, registeredGeometry2.Value); } + + [Test] + public void AddSoilLayer_InvalidStageType_ThrowsInvalidEnumArgumentException() + { + // Setup + var registry = new MacroStabilityInwardsExportRegistry(); + const MacroStabilityInwardsExportStageType stageType = (MacroStabilityInwardsExportStageType)99; + + // Call + void Call() => registry.AddSoilLayer(stageType, "1"); + + // Assert + string expectedMessage = $"The value of argument '{nameof(stageType)}' ({stageType}) is invalid for Enum type '{nameof(MacroStabilityInwardsExportStageType)}'."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage); + } + + [Test] + public void AddSoilLayer_WithSoilLayer_AddsSoilLayer() + { + // Setup + var registry = new MacroStabilityInwardsExportRegistry(); + var stageType = new Random(21).NextEnumValue(); + const string id = "1"; + + // Call + registry.AddSoilLayer(stageType, id); + + // Assert + Assert.AreEqual(1, registry.SoilLayers.Count); + KeyValuePair registeredSoilLayers = registry.SoilLayers.Single(); + Assert.AreEqual(stageType, registeredSoilLayers.Key); + Assert.AreEqual(id, registeredSoilLayers.Value); + } } } \ No newline at end of file