Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/MacroStabilityInwards/MacroStabilityInwardsSoilLayer2DCreateExtensions.cs =================================================================== diff -u -r1b7dec5dc5d682b37d0191d99da2ff640cc56022 -rf6dd19ee061fc2754d81eb3677c26fbdb504fc49 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/MacroStabilityInwards/MacroStabilityInwardsSoilLayer2DCreateExtensions.cs (.../MacroStabilityInwardsSoilLayer2DCreateExtensions.cs) (revision 1b7dec5dc5d682b37d0191d99da2ff640cc56022) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/MacroStabilityInwards/MacroStabilityInwardsSoilLayer2DCreateExtensions.cs (.../MacroStabilityInwardsSoilLayer2DCreateExtensions.cs) (revision f6dd19ee061fc2754d81eb3677c26fbdb504fc49) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.Linq; using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.Serializers; using Core.Common.Utils.Extensions; @@ -51,7 +52,7 @@ } IMacroStabilityInwardsSoilLayerData data = soilLayer.Data; - return new MacroStabilityInwardsSoilLayerTwoDEntity + var entity = new MacroStabilityInwardsSoilLayerTwoDEntity { OuterRingXml = new Point2DXmlSerializer().ToXml(soilLayer.OuterRing.Points), IsAquifer = Convert.ToByte(data.IsAquifer), @@ -77,6 +78,19 @@ PopCoefficientOfVariation = data.Pop.CoefficientOfVariation.ToNaNAsNull(), Order = order }; + + AddNestedLayers(entity, soilLayer); + + return entity; } + + private static void AddNestedLayers(MacroStabilityInwardsSoilLayerTwoDEntity entity, + IMacroStabilityInwardsSoilLayer2D soilLayer) + { + for (var i = 0; i < soilLayer.NestedLayers.Count(); i++) + { + entity.MacroStabilityInwardsSoilLayerTwoDEntity1.Add(((MacroStabilityInwardsSoilLayer2D) soilLayer.NestedLayers.ElementAt(i)).Create(i)); + } + } } } \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MacroStabilityInwards/MacroStabilityInwardsSoilLayerTwoDEntityReadExtensions.cs =================================================================== diff -u -ra07b01c421d15a0a1e4933e3967ac1f25d30eccc -rf6dd19ee061fc2754d81eb3677c26fbdb504fc49 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MacroStabilityInwards/MacroStabilityInwardsSoilLayerTwoDEntityReadExtensions.cs (.../MacroStabilityInwardsSoilLayerTwoDEntityReadExtensions.cs) (revision a07b01c421d15a0a1e4933e3967ac1f25d30eccc) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MacroStabilityInwards/MacroStabilityInwardsSoilLayerTwoDEntityReadExtensions.cs (.../MacroStabilityInwardsSoilLayerTwoDEntityReadExtensions.cs) (revision f6dd19ee061fc2754d81eb3677c26fbdb504fc49) @@ -20,7 +20,9 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Drawing; +using System.Linq; using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.Serializers; using Core.Common.Base.Data; @@ -52,7 +54,10 @@ var outerRing = new Ring(new Point2DXmlSerializer().FromXml(entity.OuterRingXml)); - return new MacroStabilityInwardsSoilLayer2D(outerRing, new Ring[0]) + return new MacroStabilityInwardsSoilLayer2D(outerRing, + new Ring[0], + new MacroStabilityInwardsSoilLayerData(), + ReadNestedLayers(entity).ToArray()) { Data = { @@ -101,5 +106,12 @@ } }; } + + private static IEnumerable ReadNestedLayers(MacroStabilityInwardsSoilLayerTwoDEntity entity) + { + return entity.MacroStabilityInwardsSoilLayerTwoDEntity1 + .OrderBy(e => e.Order) + .Select(e => e.Read()); + } } } \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsSemiProbabilisticOutputCreateExtensionsTest.cs =================================================================== diff -u -r7b4e976738871759292c8219091bae62b966acae -rf6dd19ee061fc2754d81eb3677c26fbdb504fc49 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsSemiProbabilisticOutputCreateExtensionsTest.cs (.../MacroStabilityInwardsSemiProbabilisticOutputCreateExtensionsTest.cs) (revision 7b4e976738871759292c8219091bae62b966acae) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsSemiProbabilisticOutputCreateExtensionsTest.cs (.../MacroStabilityInwardsSemiProbabilisticOutputCreateExtensionsTest.cs) (revision f6dd19ee061fc2754d81eb3677c26fbdb504fc49) @@ -20,12 +20,12 @@ // All rights reserved. using System; +using Application.Ringtoets.Storage.Create.MacroStabilityInwards; using Application.Ringtoets.Storage.DbContext; using Core.Common.Base.Data; using NUnit.Framework; using Ringtoets.Common.Data.TestUtil; using Ringtoets.MacroStabilityInwards.Data; -using Application.Ringtoets.Storage.Create.MacroStabilityInwards; namespace Application.Ringtoets.Storage.Test.Create.MacroStabilityInwards { Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsSoilLayer2DCreateExtensionsTest.cs =================================================================== diff -u -ra07b01c421d15a0a1e4933e3967ac1f25d30eccc -rf6dd19ee061fc2754d81eb3677c26fbdb504fc49 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsSoilLayer2DCreateExtensionsTest.cs (.../MacroStabilityInwardsSoilLayer2DCreateExtensionsTest.cs) (revision a07b01c421d15a0a1e4933e3967ac1f25d30eccc) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsSoilLayer2DCreateExtensionsTest.cs (.../MacroStabilityInwardsSoilLayer2DCreateExtensionsTest.cs) (revision f6dd19ee061fc2754d81eb3677c26fbdb504fc49) @@ -30,6 +30,7 @@ using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.MacroStabilityInwards.Data.SoilProfile; +using Ringtoets.MacroStabilityInwards.Data.TestUtil.SoilProfile; using Ringtoets.MacroStabilityInwards.Primitives; namespace Application.Ringtoets.Storage.Test.Create.MacroStabilityInwards @@ -53,90 +54,42 @@ { // Setup var random = new Random(31); - var soilLayer = new MacroStabilityInwardsSoilLayer2D(CreateRandomRing(random), new[] - { - CreateRandomRing(random) - }) - { - Data = - { - IsAquifer = random.NextBoolean(), - MaterialName = "MaterialName", - Color = Color.FromKnownColor(random.NextEnumValue()), - UsePop = random.NextBoolean(), - ShearStrengthModel = random.NextEnumValue(), - AbovePhreaticLevel = - { - Mean = random.NextRoundedDouble(), - CoefficientOfVariation = random.NextRoundedDouble(), - Shift = random.NextRoundedDouble() - }, - BelowPhreaticLevel = - { - Mean = random.NextRoundedDouble(), - CoefficientOfVariation = random.NextRoundedDouble(), - Shift = random.NextRoundedDouble() - }, - Cohesion = - { - Mean = random.NextRoundedDouble(), - CoefficientOfVariation = random.NextRoundedDouble() - }, - FrictionAngle = - { - Mean = random.NextRoundedDouble(), - CoefficientOfVariation = random.NextRoundedDouble() - }, - ShearStrengthRatio = - { - Mean = random.NextRoundedDouble(), - CoefficientOfVariation = random.NextRoundedDouble() - }, - StrengthIncreaseExponent = - { - Mean = random.NextRoundedDouble(), - CoefficientOfVariation = random.NextRoundedDouble() - }, - Pop = - { - Mean = random.NextRoundedDouble(), - CoefficientOfVariation = random.NextRoundedDouble() - } - } - }; + MacroStabilityInwardsSoilLayer2D soilLayer = CreateMacroStabilityInwardsSoilLayer2D(random); int order = random.Next(); // Call MacroStabilityInwardsSoilLayerTwoDEntity entity = soilLayer.Create(order); // Assert - Assert.IsNotNull(entity); + AssertMacroStabilityInwardsSoilLayerTwoDEntity(soilLayer, entity, order); + } - IMacroStabilityInwardsSoilLayerData data = soilLayer.Data; - Assert.AreEqual(Convert.ToByte(data.IsAquifer), entity.IsAquifer); - Assert.AreEqual(data.MaterialName, entity.MaterialName); - Assert.AreEqual(data.Color.ToArgb(), Convert.ToInt32(entity.Color)); - Assert.AreEqual(Convert.ToByte(data.UsePop), entity.UsePop); - Assert.AreEqual(Convert.ToByte(data.ShearStrengthModel), entity.ShearStrengthModel); - Assert.AreEqual(data.AbovePhreaticLevel.Mean, entity.AbovePhreaticLevelMean); - Assert.AreEqual(data.AbovePhreaticLevel.CoefficientOfVariation, entity.AbovePhreaticLevelCoefficientOfVariation); - Assert.AreEqual(data.AbovePhreaticLevel.Shift, entity.AbovePhreaticLevelShift); - Assert.AreEqual(data.BelowPhreaticLevel.Mean, entity.BelowPhreaticLevelMean); - Assert.AreEqual(data.BelowPhreaticLevel.CoefficientOfVariation, entity.BelowPhreaticLevelCoefficientOfVariation); - Assert.AreEqual(data.BelowPhreaticLevel.Shift, entity.BelowPhreaticLevelShift); - Assert.AreEqual(data.Cohesion.Mean, entity.CohesionMean); - Assert.AreEqual(data.Cohesion.CoefficientOfVariation, entity.CohesionCoefficientOfVariation); - Assert.AreEqual(data.FrictionAngle.Mean, entity.FrictionAngleMean); - Assert.AreEqual(data.FrictionAngle.CoefficientOfVariation, entity.FrictionAngleCoefficientOfVariation); - Assert.AreEqual(data.ShearStrengthRatio.Mean, entity.ShearStrengthRatioMean); - Assert.AreEqual(data.ShearStrengthRatio.CoefficientOfVariation, entity.ShearStrengthRatioCoefficientOfVariation); - Assert.AreEqual(data.StrengthIncreaseExponent.Mean, entity.StrengthIncreaseExponentMean); - Assert.AreEqual(data.StrengthIncreaseExponent.CoefficientOfVariation, entity.StrengthIncreaseExponentCoefficientOfVariation); - Assert.AreEqual(data.Pop.Mean, entity.PopMean); - Assert.AreEqual(data.Pop.CoefficientOfVariation, entity.PopCoefficientOfVariation); - Assert.AreEqual(order, entity.Order); + [Test] + public void Create_WithNestedLayers_ReturnsEntityWithNestedLayersSet() + { + // Setup + var random = new Random(31); - AssertOuterRing(soilLayer.OuterRing, entity); + MacroStabilityInwardsSoilLayer2D parentLayer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(new[] + { + CreateMacroStabilityInwardsSoilLayer2D(random), + CreateMacroStabilityInwardsSoilLayer2D(random), + CreateMacroStabilityInwardsSoilLayer2D(random) + }); + + // Call + MacroStabilityInwardsSoilLayerTwoDEntity entity = parentLayer.Create(0); + + // Assert + Assert.IsNotNull(entity); + Assert.AreEqual(parentLayer.NestedLayers.Count(), entity.MacroStabilityInwardsSoilLayerTwoDEntity1.Count); + + for (var i = 0; i < parentLayer.NestedLayers.Count(); i++) + { + AssertMacroStabilityInwardsSoilLayerTwoDEntity(parentLayer.NestedLayers.ElementAt(i), + entity.MacroStabilityInwardsSoilLayerTwoDEntity1.ElementAt(i), + i); + } } [Test] @@ -236,6 +189,95 @@ TestHelper.AssertAreEqualButNotSame(materialName, entity.MaterialName); } + private static MacroStabilityInwardsSoilLayer2D CreateMacroStabilityInwardsSoilLayer2D(Random random) + { + return new MacroStabilityInwardsSoilLayer2D(CreateRandomRing(random), new[] + { + CreateRandomRing(random), + CreateRandomRing(random) + }) + { + Data = + { + IsAquifer = random.NextBoolean(), + MaterialName = "MaterialName", + Color = Color.FromKnownColor(random.NextEnumValue()), + UsePop = random.NextBoolean(), + ShearStrengthModel = random.NextEnumValue(), + AbovePhreaticLevel = + { + Mean = random.NextRoundedDouble(2.0, 3.0), + CoefficientOfVariation = random.NextRoundedDouble(), + Shift = random.NextRoundedDouble(0.0, 1.0) + }, + BelowPhreaticLevel = + { + Mean = random.NextRoundedDouble(2.0, 3.0), + CoefficientOfVariation = random.NextRoundedDouble(), + Shift = random.NextRoundedDouble(0.0, 1.0) + }, + Cohesion = + { + Mean = random.NextRoundedDouble(), + CoefficientOfVariation = random.NextRoundedDouble() + }, + FrictionAngle = + { + Mean = random.NextRoundedDouble(), + CoefficientOfVariation = random.NextRoundedDouble() + }, + StrengthIncreaseExponent = + { + Mean = random.NextRoundedDouble(), + CoefficientOfVariation = random.NextRoundedDouble() + }, + ShearStrengthRatio = + { + Mean = random.NextRoundedDouble(), + CoefficientOfVariation = random.NextRoundedDouble() + }, + Pop = + { + Mean = random.NextRoundedDouble(), + CoefficientOfVariation = random.NextRoundedDouble() + } + } + }; + } + + private static void AssertMacroStabilityInwardsSoilLayerTwoDEntity(IMacroStabilityInwardsSoilLayer2D soilLayer, + MacroStabilityInwardsSoilLayerTwoDEntity entity, int order) + { + Assert.IsNotNull(entity); + + IMacroStabilityInwardsSoilLayerData data = soilLayer.Data; + Assert.AreEqual(Convert.ToByte(data.IsAquifer), entity.IsAquifer); + Assert.AreEqual(data.MaterialName, entity.MaterialName); + Assert.AreEqual(data.Color.ToArgb(), Convert.ToInt32(entity.Color)); + Assert.AreEqual(Convert.ToByte(data.UsePop), entity.UsePop); + Assert.AreEqual(Convert.ToByte(data.ShearStrengthModel), entity.ShearStrengthModel); + Assert.AreEqual(data.AbovePhreaticLevel.Mean, entity.AbovePhreaticLevelMean); + Assert.AreEqual(data.AbovePhreaticLevel.CoefficientOfVariation, entity.AbovePhreaticLevelCoefficientOfVariation); + Assert.AreEqual(data.AbovePhreaticLevel.Shift, entity.AbovePhreaticLevelShift); + Assert.AreEqual(data.BelowPhreaticLevel.Mean, entity.BelowPhreaticLevelMean); + Assert.AreEqual(data.BelowPhreaticLevel.CoefficientOfVariation, entity.BelowPhreaticLevelCoefficientOfVariation); + Assert.AreEqual(data.BelowPhreaticLevel.Shift, entity.BelowPhreaticLevelShift); + Assert.AreEqual(data.Cohesion.Mean, entity.CohesionMean); + Assert.AreEqual(data.Cohesion.CoefficientOfVariation, entity.CohesionCoefficientOfVariation); + Assert.AreEqual(data.FrictionAngle.Mean, entity.FrictionAngleMean); + Assert.AreEqual(data.FrictionAngle.CoefficientOfVariation, entity.FrictionAngleCoefficientOfVariation); + Assert.AreEqual(data.ShearStrengthRatio.Mean, entity.ShearStrengthRatioMean); + Assert.AreEqual(data.ShearStrengthRatio.CoefficientOfVariation, entity.ShearStrengthRatioCoefficientOfVariation); + Assert.AreEqual(data.StrengthIncreaseExponent.Mean, entity.StrengthIncreaseExponentMean); + Assert.AreEqual(data.StrengthIncreaseExponent.CoefficientOfVariation, entity.StrengthIncreaseExponentCoefficientOfVariation); + Assert.AreEqual(data.Pop.Mean, entity.PopMean); + Assert.AreEqual(data.Pop.CoefficientOfVariation, entity.PopCoefficientOfVariation); + Assert.AreEqual(order, entity.Order); + + AssertOuterRing(soilLayer.OuterRing, entity); + CollectionAssert.IsEmpty(entity.MacroStabilityInwardsSoilLayerTwoDEntity1); + } + private static void AssertOuterRing(Ring outerRing, MacroStabilityInwardsSoilLayerTwoDEntity entity) { string expectedOuterRingXml = new Point2DXmlSerializer().ToXml(outerRing.Points); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs =================================================================== diff -u -r1b7dec5dc5d682b37d0191d99da2ff640cc56022 -rf6dd19ee061fc2754d81eb3677c26fbdb504fc49 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision 1b7dec5dc5d682b37d0191d99da2ff640cc56022) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision f6dd19ee061fc2754d81eb3677c26fbdb504fc49) @@ -1501,11 +1501,15 @@ AssertMacroStabilityInwardsSoilLayerData(expectedLayer.Data, actualLayer.Data); } - private static void AssertMacroStabilityInwardsSoilLayer(MacroStabilityInwardsSoilLayer2D expectedLayer, - MacroStabilityInwardsSoilLayer2D actualLayer) + private static void AssertMacroStabilityInwardsSoilLayer(IMacroStabilityInwardsSoilLayer2D expectedLayer, + IMacroStabilityInwardsSoilLayer2D actualLayer) { Assert.AreEqual(expectedLayer.OuterRing, actualLayer.OuterRing); AssertMacroStabilityInwardsSoilLayerData(expectedLayer.Data, actualLayer.Data); + + AssertCollectionAndItems(expectedLayer.NestedLayers.Cast(), + actualLayer.NestedLayers.Cast(), + AssertMacroStabilityInwardsSoilLayer); } private static void AssertMacroStabilityInwardsSoilLayerData(IMacroStabilityInwardsSoilLayerData expectedData, Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsSemiProbabilisticOutputEntityReadExtensionsTest.cs =================================================================== diff -u -rde4ebfc961abbbcd502b9932f52c21e315a631c3 -rf6dd19ee061fc2754d81eb3677c26fbdb504fc49 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsSemiProbabilisticOutputEntityReadExtensionsTest.cs (.../MacroStabilityInwardsSemiProbabilisticOutputEntityReadExtensionsTest.cs) (revision de4ebfc961abbbcd502b9932f52c21e315a631c3) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsSemiProbabilisticOutputEntityReadExtensionsTest.cs (.../MacroStabilityInwardsSemiProbabilisticOutputEntityReadExtensionsTest.cs) (revision f6dd19ee061fc2754d81eb3677c26fbdb504fc49) @@ -21,11 +21,11 @@ using System; using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.Read.MacroStabilityInwards; using Core.Common.Base.Data; using NUnit.Framework; using Ringtoets.Common.Data.TestUtil; using Ringtoets.MacroStabilityInwards.Data; -using Application.Ringtoets.Storage.Read.MacroStabilityInwards; namespace Application.Ringtoets.Storage.Test.Read.MacroStabilityInwards { Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsSoilLayerTwoDEntityReadExtensionsTest.cs =================================================================== diff -u -r1b7dec5dc5d682b37d0191d99da2ff640cc56022 -rf6dd19ee061fc2754d81eb3677c26fbdb504fc49 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsSoilLayerTwoDEntityReadExtensionsTest.cs (.../MacroStabilityInwardsSoilLayerTwoDEntityReadExtensionsTest.cs) (revision 1b7dec5dc5d682b37d0191d99da2ff640cc56022) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsSoilLayerTwoDEntityReadExtensionsTest.cs (.../MacroStabilityInwardsSoilLayerTwoDEntityReadExtensionsTest.cs) (revision f6dd19ee061fc2754d81eb3677c26fbdb504fc49) @@ -21,9 +21,11 @@ using System; using System.Drawing; +using System.Linq; using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.Read.MacroStabilityInwards; using Application.Ringtoets.Storage.Serializers; +using Application.Ringtoets.Storage.TestUtil.MacroStabilityInwards; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.TestUtil; @@ -53,56 +55,48 @@ public void Read_WithValues_ReturnsMacroStabilityInwardsSoilLayer2DWithDoubleParameterValues() { // Setup - var random = new Random(31); - int color = Color.FromKnownColor(random.NextEnumValue()).ToArgb(); - bool isAquifer = random.NextBoolean(); - const double abovePhreaticLevelMean = 0.3; - const double abovePhreaticLevelCoefficientOfVariation = 0.2; - const double abovePhreaticLevelShift = 0.1; - const double belowPhreaticLevelMean = 0.6; - const double belowPhreaticLevelCoefficientOfVariation = 0.5; - const double belowPhreaticLevelShift = 0.4; - double cohesionMean = random.NextDouble(); - double cohesionCoefficientOfVariation = random.NextDouble(); - double frictionAngleMean = random.NextDouble(); - double frictionAngleCoefficientOfVariation = random.NextDouble(); - double shearStrengthRatioMean = random.NextDouble(); - double shearStrengthRatioCoefficientOfVariation = random.NextDouble(); - double strengthIncreaseExponentMean = random.NextDouble(); - double strengthIncreaseExponentCoefficientOfVariation = random.NextDouble(); - double popMean = random.NextDouble(); - double popCoefficientOfVariation = random.NextDouble(); + MacroStabilityInwardsSoilLayerTwoDEntity entity = CreateMacroStabilityInwardsSoilLayerTwoDEntity(); - var outerRingPoints = new[] + // Call + MacroStabilityInwardsSoilLayer2D layer = entity.Read(); + + // Assert + AssertMacroStabilityInwardsSoilLayer2D(entity, layer); + } + + [Test] + public void Read_WithNestedLayers_ReturnsMacroStabilityInwardsSoilLayer2DWithNestedLayers() + { + // Setup + MacroStabilityInwardsSoilLayerTwoDEntity entity = MacroStabilityInwardsSoilLayerTwoDEntityTestFactory.CreateMacroStabilityInwardsSoilLayerTwoDEntity(); + + entity.MacroStabilityInwardsSoilLayerTwoDEntity1.Add(CreateMacroStabilityInwardsSoilLayerTwoDEntity()); + entity.MacroStabilityInwardsSoilLayerTwoDEntity1.Add(CreateMacroStabilityInwardsSoilLayerTwoDEntity()); + entity.MacroStabilityInwardsSoilLayerTwoDEntity1.Add(CreateMacroStabilityInwardsSoilLayerTwoDEntity()); + + // Call + MacroStabilityInwardsSoilLayer2D layer = entity.Read(); + + // Assert + Assert.IsNotNull(layer); + Assert.AreEqual(entity.MacroStabilityInwardsSoilLayerTwoDEntity1.Count, + layer.NestedLayers.Count()); + + for (var i = 0; i < entity.MacroStabilityInwardsSoilLayerTwoDEntity1.Count; i++) { - CreateRandomPoint2D(random), - CreateRandomPoint2D(random), - CreateRandomPoint2D(random), - CreateRandomPoint2D(random) - }; + AssertMacroStabilityInwardsSoilLayer2D(entity.MacroStabilityInwardsSoilLayerTwoDEntity1.ElementAt(i), + layer.NestedLayers.ElementAt(i)); + } + } + [Test] + public void Read_WithNullValues_ReturnsMacroStabilityInwardsSoilLayer2DWithNaNValues() + { + // Setup var entity = new MacroStabilityInwardsSoilLayerTwoDEntity { - IsAquifer = Convert.ToByte(isAquifer), - Color = color, - MaterialName = random.Next().ToString(), - AbovePhreaticLevelMean = abovePhreaticLevelMean, - AbovePhreaticLevelCoefficientOfVariation = abovePhreaticLevelCoefficientOfVariation, - AbovePhreaticLevelShift = abovePhreaticLevelShift, - BelowPhreaticLevelMean = belowPhreaticLevelMean, - BelowPhreaticLevelCoefficientOfVariation = belowPhreaticLevelCoefficientOfVariation, - BelowPhreaticLevelShift = belowPhreaticLevelShift, - CohesionMean = cohesionMean, - CohesionCoefficientOfVariation = cohesionCoefficientOfVariation, - FrictionAngleMean = frictionAngleMean, - FrictionAngleCoefficientOfVariation = frictionAngleCoefficientOfVariation, - ShearStrengthRatioMean = shearStrengthRatioMean, - ShearStrengthRatioCoefficientOfVariation = shearStrengthRatioCoefficientOfVariation, - StrengthIncreaseExponentMean = strengthIncreaseExponentMean, - StrengthIncreaseExponentCoefficientOfVariation = strengthIncreaseExponentCoefficientOfVariation, - PopMean = popMean, - PopCoefficientOfVariation = popCoefficientOfVariation, - OuterRingXml = new Point2DXmlSerializer().ToXml(outerRingPoints) + MaterialName = nameof(MacroStabilityInwardsSoilLayerTwoDEntity), + OuterRingXml = new Point2DXmlSerializer().ToXml(CreateRandomRing(new Random(31)).Points) }; // Call @@ -111,120 +105,146 @@ // Assert Assert.IsNotNull(layer); IMacroStabilityInwardsSoilLayerData data = layer.Data; - Assert.AreEqual(isAquifer, data.IsAquifer); - Assert.AreEqual(Color.FromArgb(color), data.Color); Assert.AreEqual(entity.MaterialName, data.MaterialName); DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2) { - Mean = (RoundedDouble) abovePhreaticLevelMean, - CoefficientOfVariation = (RoundedDouble) abovePhreaticLevelCoefficientOfVariation, - Shift = (RoundedDouble) abovePhreaticLevelShift + Mean = RoundedDouble.NaN, + CoefficientOfVariation = RoundedDouble.NaN, + Shift = RoundedDouble.NaN }, data.AbovePhreaticLevel); DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2) { - Mean = (RoundedDouble) belowPhreaticLevelMean, - CoefficientOfVariation = (RoundedDouble) belowPhreaticLevelCoefficientOfVariation, - Shift = (RoundedDouble) belowPhreaticLevelShift + Mean = RoundedDouble.NaN, + CoefficientOfVariation = RoundedDouble.NaN, + Shift = RoundedDouble.NaN }, data.BelowPhreaticLevel); DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2) { - Mean = (RoundedDouble) cohesionMean, - CoefficientOfVariation = (RoundedDouble) cohesionCoefficientOfVariation + Mean = RoundedDouble.NaN, + CoefficientOfVariation = RoundedDouble.NaN }, data.Cohesion); DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2) { - Mean = (RoundedDouble) frictionAngleMean, - CoefficientOfVariation = (RoundedDouble) frictionAngleCoefficientOfVariation + Mean = RoundedDouble.NaN, + CoefficientOfVariation = RoundedDouble.NaN }, data.FrictionAngle); DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2) { - Mean = (RoundedDouble) shearStrengthRatioMean, - CoefficientOfVariation = (RoundedDouble) shearStrengthRatioCoefficientOfVariation + Mean = RoundedDouble.NaN, + CoefficientOfVariation = RoundedDouble.NaN }, data.ShearStrengthRatio); DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2) { - Mean = (RoundedDouble) strengthIncreaseExponentMean, - CoefficientOfVariation = (RoundedDouble) strengthIncreaseExponentCoefficientOfVariation + Mean = RoundedDouble.NaN, + CoefficientOfVariation = RoundedDouble.NaN }, data.StrengthIncreaseExponent); DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2) { - Mean = (RoundedDouble) popMean, - CoefficientOfVariation = (RoundedDouble) popCoefficientOfVariation + Mean = RoundedDouble.NaN, + CoefficientOfVariation = RoundedDouble.NaN }, data.Pop); - - CollectionAssert.AreEqual(outerRingPoints, layer.OuterRing.Points); } - [Test] - public void Read_WithNullValues_ReturnsMacroStabilityInwardsSoilLayer2DWithNaNValues() + private static void AssertMacroStabilityInwardsSoilLayer2D(MacroStabilityInwardsSoilLayerTwoDEntity entity, + IMacroStabilityInwardsSoilLayer2D layer) { - // Setup - var entity = new MacroStabilityInwardsSoilLayerTwoDEntity - { - MaterialName = nameof(MacroStabilityInwardsSoilLayerTwoDEntity), - OuterRingXml = new Point2DXmlSerializer().ToXml(CreateRandomRing(new Random(31)).Points) - }; - - // Call - MacroStabilityInwardsSoilLayer2D layer = entity.Read(); - - // Assert Assert.IsNotNull(layer); IMacroStabilityInwardsSoilLayerData data = layer.Data; + Assert.AreEqual(Convert.ToBoolean(entity.IsAquifer), data.IsAquifer); + Assert.AreEqual(Color.FromArgb(Convert.ToInt32(entity.Color)), data.Color); Assert.AreEqual(entity.MaterialName, data.MaterialName); DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2) { - Mean = RoundedDouble.NaN, - CoefficientOfVariation = RoundedDouble.NaN, - Shift = RoundedDouble.NaN + Mean = (RoundedDouble) entity.AbovePhreaticLevelMean.ToNullAsNaN(), + CoefficientOfVariation = (RoundedDouble) entity.AbovePhreaticLevelCoefficientOfVariation.ToNullAsNaN(), + Shift = (RoundedDouble) entity.AbovePhreaticLevelShift.ToNullAsNaN() }, data.AbovePhreaticLevel); DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2) { - Mean = RoundedDouble.NaN, - CoefficientOfVariation = RoundedDouble.NaN, - Shift = RoundedDouble.NaN + Mean = (RoundedDouble) entity.BelowPhreaticLevelMean.ToNullAsNaN(), + CoefficientOfVariation = (RoundedDouble) entity.BelowPhreaticLevelCoefficientOfVariation.ToNullAsNaN(), + Shift = (RoundedDouble) entity.BelowPhreaticLevelShift.ToNullAsNaN() }, data.BelowPhreaticLevel); DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2) { - Mean = RoundedDouble.NaN, - CoefficientOfVariation = RoundedDouble.NaN + Mean = (RoundedDouble) entity.CohesionMean.ToNullAsNaN(), + CoefficientOfVariation = (RoundedDouble) entity.CohesionCoefficientOfVariation.ToNullAsNaN() }, data.Cohesion); DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2) { - Mean = RoundedDouble.NaN, - CoefficientOfVariation = RoundedDouble.NaN + Mean = (RoundedDouble) entity.FrictionAngleMean.ToNullAsNaN(), + CoefficientOfVariation = (RoundedDouble) entity.FrictionAngleCoefficientOfVariation.ToNullAsNaN() }, data.FrictionAngle); DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2) { - Mean = RoundedDouble.NaN, - CoefficientOfVariation = RoundedDouble.NaN + Mean = (RoundedDouble) entity.ShearStrengthRatioMean.ToNullAsNaN(), + CoefficientOfVariation = (RoundedDouble) entity.ShearStrengthRatioCoefficientOfVariation.ToNullAsNaN() }, data.ShearStrengthRatio); DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2) { - Mean = RoundedDouble.NaN, - CoefficientOfVariation = RoundedDouble.NaN + Mean = (RoundedDouble) entity.StrengthIncreaseExponentMean.ToNullAsNaN(), + CoefficientOfVariation = (RoundedDouble) entity.StrengthIncreaseExponentCoefficientOfVariation.ToNullAsNaN() }, data.StrengthIncreaseExponent); DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2) { - Mean = RoundedDouble.NaN, - CoefficientOfVariation = RoundedDouble.NaN + Mean = (RoundedDouble) entity.PopMean.ToNullAsNaN(), + CoefficientOfVariation = (RoundedDouble) entity.PopCoefficientOfVariation.ToNullAsNaN() }, data.Pop); + + CollectionAssert.AreEqual(new Point2DXmlSerializer().FromXml(entity.OuterRingXml), + layer.OuterRing.Points); + CollectionAssert.IsEmpty(layer.NestedLayers); } + private static MacroStabilityInwardsSoilLayerTwoDEntity CreateMacroStabilityInwardsSoilLayerTwoDEntity() + { + var random = new Random(31); + var entity = new MacroStabilityInwardsSoilLayerTwoDEntity + { + IsAquifer = Convert.ToByte(random.NextBoolean()), + Color = Color.FromKnownColor(random.NextEnumValue()).ToArgb(), + MaterialName = random.Next().ToString(), + AbovePhreaticLevelMean = random.GetFromRange(2.0, 3.0), + AbovePhreaticLevelCoefficientOfVariation = random.NextDouble(), + AbovePhreaticLevelShift = random.GetFromRange(0.0, 1.0), + BelowPhreaticLevelMean = random.GetFromRange(2.0, 3.0), + BelowPhreaticLevelCoefficientOfVariation = random.NextDouble(), + BelowPhreaticLevelShift = random.GetFromRange(0.0, 1.0), + CohesionMean = random.NextDouble(), + CohesionCoefficientOfVariation = random.NextDouble(), + FrictionAngleMean = random.NextDouble(), + FrictionAngleCoefficientOfVariation = random.NextDouble(), + ShearStrengthRatioMean = random.NextDouble(), + ShearStrengthRatioCoefficientOfVariation = random.NextDouble(), + StrengthIncreaseExponentMean = random.NextDouble(), + StrengthIncreaseExponentCoefficientOfVariation = random.NextDouble(), + PopMean = random.NextDouble(), + PopCoefficientOfVariation = random.NextDouble(), + OuterRingXml = new Point2DXmlSerializer().ToXml(new[] + { + CreateRandomPoint2D(random), + CreateRandomPoint2D(random), + CreateRandomPoint2D(random), + CreateRandomPoint2D(random) + }) + }; + return entity; + } + private static Ring CreateRandomRing(Random random) { return new Ring(new[] Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingCalculationEntityReadExtensionsTest.cs =================================================================== diff -u -r3b2cfa62b4a0df5c5577395b7cbef40de1d7f2f9 -rf6dd19ee061fc2754d81eb3677c26fbdb504fc49 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingCalculationEntityReadExtensionsTest.cs (.../PipingCalculationEntityReadExtensionsTest.cs) (revision 3b2cfa62b4a0df5c5577395b7cbef40de1d7f2f9) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingCalculationEntityReadExtensionsTest.cs (.../PipingCalculationEntityReadExtensionsTest.cs) (revision f6dd19ee061fc2754d81eb3677c26fbdb504fc49) @@ -27,7 +27,6 @@ using Core.Common.Base.Data; using Core.Common.Base.Geometry; using NUnit.Framework; -using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Piping.Data; using Ringtoets.Piping.Data.SoilProfile; Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs =================================================================== diff -u -ra07b01c421d15a0a1e4933e3967ac1f25d30eccc -rf6dd19ee061fc2754d81eb3677c26fbdb504fc49 --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs (.../RingtoetsProjectTestHelper.cs) (revision a07b01c421d15a0a1e4933e3967ac1f25d30eccc) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs (.../RingtoetsProjectTestHelper.cs) (revision f6dd19ee061fc2754d81eb3677c26fbdb504fc49) @@ -1130,6 +1130,80 @@ new Point2D(2, 2), new Point2D(3, 3) }) + }, new MacroStabilityInwardsSoilLayerData(), new[] + { + new MacroStabilityInwardsSoilLayer2D(new Ring(new[] + { + new Point2D(3, 3), + new Point2D(4, 4) + }), new[] + { + new Ring(new[] + { + new Point2D(5, 5), + new Point2D(6, 6) + }) + }) + { + Data = + { + IsAquifer = true, + MaterialName = "Navy", + Color = Color.Navy, + UsePop = true, + ShearStrengthModel = MacroStabilityInwardsShearStrengthModel.CPhi, + AbovePhreaticLevel = new VariationCoefficientLogNormalDistribution + { + Mean = (RoundedDouble) 15.901, + CoefficientOfVariation = (RoundedDouble) 5.902, + Shift = (RoundedDouble) 5.903 + }, + BelowPhreaticLevel = new VariationCoefficientLogNormalDistribution + { + Mean = (RoundedDouble) 5.906, + CoefficientOfVariation = (RoundedDouble) 5.905, + Shift = (RoundedDouble) 5.904 + }, + Cohesion = new VariationCoefficientLogNormalDistribution + { + Mean = (RoundedDouble) 5.907, + CoefficientOfVariation = (RoundedDouble) 5.908 + }, + FrictionAngle = new VariationCoefficientLogNormalDistribution + { + Mean = (RoundedDouble) 5.909, + CoefficientOfVariation = (RoundedDouble) 5.91 + }, + ShearStrengthRatio = new VariationCoefficientLogNormalDistribution + { + Mean = (RoundedDouble) 5.911, + CoefficientOfVariation = (RoundedDouble) 5.912 + }, + StrengthIncreaseExponent = new VariationCoefficientLogNormalDistribution + { + Mean = (RoundedDouble) 5.913, + CoefficientOfVariation = (RoundedDouble) 5.914 + }, + Pop = new VariationCoefficientLogNormalDistribution + { + Mean = (RoundedDouble) 5.915, + CoefficientOfVariation = (RoundedDouble) 5.916 + } + } + }, + new MacroStabilityInwardsSoilLayer2D(new Ring(new[] + { + new Point2D(-10, -100), + new Point2D(10, 100) + }), new Ring[0]) + { + Data = + { + MaterialName = "HotPink", + Color = Color.HotPink, + ShearStrengthModel = MacroStabilityInwardsShearStrengthModel.SuCalculated + } + } }) { Data = Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/SoilProfile/MacroStabilityInwardsSoilLayer2DTestFactoryTest.cs =================================================================== diff -u -r7585d2fd78627d94d55ffa16423af90a91e4efd4 -rf6dd19ee061fc2754d81eb3677c26fbdb504fc49 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/SoilProfile/MacroStabilityInwardsSoilLayer2DTestFactoryTest.cs (.../MacroStabilityInwardsSoilLayer2DTestFactoryTest.cs) (revision 7585d2fd78627d94d55ffa16423af90a91e4efd4) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/SoilProfile/MacroStabilityInwardsSoilLayer2DTestFactoryTest.cs (.../MacroStabilityInwardsSoilLayer2DTestFactoryTest.cs) (revision f6dd19ee061fc2754d81eb3677c26fbdb504fc49) @@ -44,7 +44,30 @@ new Point2D(0, 0), new Point2D(1, 1) }), soilLayer.OuterRing); - CollectionAssert.IsEmpty(soilLayer.Holes); + CollectionAssert.IsEmpty(soilLayer.NestedLayers); } + + [Test] + public void CreateMacroStabilityInwardsSoilLayer2D_WithNestedLayers_ReturnsExpectedMacroStabilityInwardsSoilLayer2D() + { + // Setup + var nestedLayers = new[] + { + MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D() + }; + + // Call + MacroStabilityInwardsSoilLayer2D soilLayer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(nestedLayers); + + // Assert + Assert.IsNotNull(soilLayer); + Assert.AreEqual(typeof(MacroStabilityInwardsSoilLayer2D), soilLayer.GetType()); + Assert.AreEqual(new Ring(new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + }), soilLayer.OuterRing); + Assert.AreSame(nestedLayers, soilLayer.NestedLayers); + } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/SoilProfile/MacroStabilityInwardsSoilLayer2DTestFactory.cs =================================================================== diff -u -ra07b01c421d15a0a1e4933e3967ac1f25d30eccc -rf6dd19ee061fc2754d81eb3677c26fbdb504fc49 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/SoilProfile/MacroStabilityInwardsSoilLayer2DTestFactory.cs (.../MacroStabilityInwardsSoilLayer2DTestFactory.cs) (revision a07b01c421d15a0a1e4933e3967ac1f25d30eccc) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/SoilProfile/MacroStabilityInwardsSoilLayer2DTestFactory.cs (.../MacroStabilityInwardsSoilLayer2DTestFactory.cs) (revision f6dd19ee061fc2754d81eb3677c26fbdb504fc49) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Collections.Generic; using Core.Common.Base.Geometry; using Ringtoets.MacroStabilityInwards.Data.SoilProfile; using Ringtoets.MacroStabilityInwards.Primitives; @@ -37,11 +38,23 @@ /// The created . public static MacroStabilityInwardsSoilLayer2D CreateMacroStabilityInwardsSoilLayer2D() { + return CreateMacroStabilityInwardsSoilLayer2D(new IMacroStabilityInwardsSoilLayer2D[0]); + } + + /// + /// Creates a new instance of . + /// + /// The nested . + /// The created . + public static MacroStabilityInwardsSoilLayer2D CreateMacroStabilityInwardsSoilLayer2D(IEnumerable nestedLayers) + { return new MacroStabilityInwardsSoilLayer2D(new Ring(new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - }), new Ring[0]); + { + new Point2D(0, 0), + new Point2D(1, 1) + }), new Ring[0], + new MacroStabilityInwardsSoilLayerData(), + nestedLayers); } } } \ No newline at end of file