Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/PipingStochasticSoilModelCreateExtensions.cs =================================================================== diff -u -r8ff26e0d7885f432a6e470e8d68ce325bdc6a9bc -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/PipingStochasticSoilModelCreateExtensions.cs (.../PipingStochasticSoilModelCreateExtensions.cs) (revision 8ff26e0d7885f432a6e470e8d68ce325bdc6a9bc) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/PipingStochasticSoilModelCreateExtensions.cs (.../PipingStochasticSoilModelCreateExtensions.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -76,10 +76,10 @@ PersistenceRegistry registry, StochasticSoilModelEntity entity) { - for (var i = 0; i < model.StochasticSoilProfiles.Count; i++) + var i = 0; + foreach (PipingStochasticSoilProfile stochasticSoilProfile in model.StochasticSoilProfiles) { - PipingStochasticSoilProfile stochasticSoilProfile = model.StochasticSoilProfiles[i]; - entity.PipingStochasticSoilProfileEntities.Add(stochasticSoilProfile.Create(registry, i)); + entity.PipingStochasticSoilProfileEntities.Add(stochasticSoilProfile.Create(registry, i++)); } } } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/StochasticSoilModelEntityReadExtensions.cs =================================================================== diff -u -rb13759ad077f9e2b4104de000b5bdeafa9abe358 -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/StochasticSoilModelEntityReadExtensions.cs (.../StochasticSoilModelEntityReadExtensions.cs) (revision b13759ad077f9e2b4104de000b5bdeafa9abe358) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/StochasticSoilModelEntityReadExtensions.cs (.../StochasticSoilModelEntityReadExtensions.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -66,8 +66,8 @@ } Point2D[] geometry = ReadSegmentPoints(entity.StochasticSoilModelSegmentPointXml).ToArray(); - var model = new PipingStochasticSoilModel(entity.Name, geometry); - entity.ReadStochasticSoilProfiles(model, collector); + PipingStochasticSoilProfile[] stochasticSoilProfiles = ReadPipingStochasticSoilProfiles(entity, collector).ToArray(); + var model = new PipingStochasticSoilModel(entity.Name, geometry, stochasticSoilProfiles); collector.Read(entity, model); @@ -111,14 +111,13 @@ return model; } - private static void ReadStochasticSoilProfiles(this StochasticSoilModelEntity entity, - PipingStochasticSoilModel model, - ReadConversionCollector collector) + private static IEnumerable ReadPipingStochasticSoilProfiles(this StochasticSoilModelEntity entity, + ReadConversionCollector collector) { foreach (PipingStochasticSoilProfileEntity stochasticSoilProfileEntity in entity.PipingStochasticSoilProfileEntities .OrderBy(ssp => ssp.Order)) { - model.StochasticSoilProfiles.Add(stochasticSoilProfileEntity.Read(collector)); + yield return stochasticSoilProfileEntity.Read(collector); } } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingFailureMechanismCreateExtensionsTest.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingFailureMechanismCreateExtensionsTest.cs (.../PipingFailureMechanismCreateExtensionsTest.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingFailureMechanismCreateExtensionsTest.cs (.../PipingFailureMechanismCreateExtensionsTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -258,7 +258,7 @@ private static void AssertStochasticSoilModel(PipingStochasticSoilModel model, StochasticSoilModelEntity entity) { Assert.AreEqual(model.Name, entity.Name); - Assert.AreEqual(model.StochasticSoilProfiles.Count, entity.PipingStochasticSoilProfileEntities.Count); + Assert.AreEqual(model.StochasticSoilProfiles.Count(), entity.PipingStochasticSoilProfileEntities.Count); CollectionAssert.IsEmpty(entity.MacroStabilityInwardsStochasticSoilProfileEntities); } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingStochasticSoilModelCreateExtensionsTest.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingStochasticSoilModelCreateExtensionsTest.cs (.../PipingStochasticSoilModelCreateExtensionsTest.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingStochasticSoilModelCreateExtensionsTest.cs (.../PipingStochasticSoilModelCreateExtensionsTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -72,10 +72,8 @@ var random = new Random(1); int order = random.Next(); const string testName = "testName"; - var stochasticSoilModel = new PipingStochasticSoilModel(testName, new[] - { - new Point2D(random.NextDouble(), random.NextDouble()) - }); + PipingStochasticSoilModel stochasticSoilModel = + PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(testName); var registry = new PersistenceRegistry(); // Call @@ -85,11 +83,7 @@ Assert.IsNotNull(entity); Assert.AreEqual(testName, entity.Name); Assert.AreEqual(order, entity.Order); - CollectionAssert.IsEmpty(entity.PipingStochasticSoilProfileEntities); CollectionAssert.IsEmpty(entity.MacroStabilityInwardsStochasticSoilProfileEntities); - - string expectedXml = new Point2DXmlSerializer().ToXml(stochasticSoilModel.Geometry); - Assert.AreEqual(expectedXml, entity.StochasticSoilModelSegmentPointXml); } [Test] @@ -122,7 +116,7 @@ // Assert Assert.IsNotNull(entity); - Assert.AreEqual(stochasticSoilModel.StochasticSoilProfiles.Count, entity.PipingStochasticSoilProfileEntities.Count); + Assert.AreEqual(stochasticSoilModel.StochasticSoilProfiles.Count(), entity.PipingStochasticSoilProfileEntities.Count); PipingStochasticSoilProfileEntity stochastEntity = entity.PipingStochasticSoilProfileEntities.Single(); Assert.AreEqual(stochasticSoilModel.StochasticSoilProfiles.Single().Probability, stochastEntity.Probability); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityReadExtensionsTest.cs =================================================================== diff -u -raf575930a392dbf1fb1d5073f3df48110af72686 -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityReadExtensionsTest.cs (.../AssessmentSectionEntityReadExtensionsTest.cs) (revision af575930a392dbf1fb1d5073f3df48110af72686) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityReadExtensionsTest.cs (.../AssessmentSectionEntityReadExtensionsTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -25,9 +25,7 @@ using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.Read; using Application.Ringtoets.Storage.Serializers; -using Application.Ringtoets.Storage.TestUtil; using Application.Ringtoets.Storage.TestUtil.MacroStabilityInwards; -using Application.Ringtoets.Storage.TestUtil.Test.MacroStabilityInwards; using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs =================================================================== diff -u -raf575930a392dbf1fb1d5073f3df48110af72686 -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs (.../FailureMechanismEntityReadExtensionsTest.cs) (revision af575930a392dbf1fb1d5073f3df48110af72686) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs (.../FailureMechanismEntityReadExtensionsTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -24,9 +24,7 @@ using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.Read; using Application.Ringtoets.Storage.Serializers; -using Application.Ringtoets.Storage.TestUtil; using Application.Ringtoets.Storage.TestUtil.MacroStabilityInwards; -using Application.Ringtoets.Storage.TestUtil.Test.MacroStabilityInwards; using Core.Common.Base; using Core.Common.Base.Geometry; using Core.Common.TestUtil; Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsStochasticSoilProfileEntityReadExtensionsTest.cs =================================================================== diff -u -raf575930a392dbf1fb1d5073f3df48110af72686 -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsStochasticSoilProfileEntityReadExtensionsTest.cs (.../MacroStabilityInwardsStochasticSoilProfileEntityReadExtensionsTest.cs) (revision af575930a392dbf1fb1d5073f3df48110af72686) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsStochasticSoilProfileEntityReadExtensionsTest.cs (.../MacroStabilityInwardsStochasticSoilProfileEntityReadExtensionsTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -23,7 +23,6 @@ using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.Read; using Application.Ringtoets.Storage.Read.MacroStabilityInwards; -using Application.Ringtoets.Storage.TestUtil; using Application.Ringtoets.Storage.TestUtil.MacroStabilityInwards; using NUnit.Framework; using Ringtoets.MacroStabilityInwards.Data.SoilProfile; Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StochasticSoilModelEntityReadExtensionsTest.cs =================================================================== diff -u -raf575930a392dbf1fb1d5073f3df48110af72686 -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StochasticSoilModelEntityReadExtensionsTest.cs (.../StochasticSoilModelEntityReadExtensionsTest.cs) (revision af575930a392dbf1fb1d5073f3df48110af72686) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StochasticSoilModelEntityReadExtensionsTest.cs (.../StochasticSoilModelEntityReadExtensionsTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -24,9 +24,7 @@ using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.Read; using Application.Ringtoets.Storage.Serializers; -using Application.Ringtoets.Storage.TestUtil; using Application.Ringtoets.Storage.TestUtil.MacroStabilityInwards; -using Application.Ringtoets.Storage.TestUtil.Test.MacroStabilityInwards; using Core.Common.Base.Geometry; using NUnit.Framework; using Ringtoets.MacroStabilityInwards.Data.SoilProfile; @@ -156,7 +154,7 @@ PipingStochasticSoilModel model = entity.ReadAsPipingStochasticSoilModel(collector); // Assert - Assert.AreEqual(entity.PipingStochasticSoilProfileEntities.Count, model.StochasticSoilProfiles.Count); + Assert.AreEqual(entity.PipingStochasticSoilProfileEntities.Count, model.StochasticSoilProfiles.Count()); CollectionAssert.AreEqual(new[] { "B", Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/MacroStabilityInwards/MacroStabilityInwardsSoilLayerTwoDEntityTestFactoryTest.cs =================================================================== diff -u -raf575930a392dbf1fb1d5073f3df48110af72686 -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/MacroStabilityInwards/MacroStabilityInwardsSoilLayerTwoDEntityTestFactoryTest.cs (.../MacroStabilityInwardsSoilLayerTwoDEntityTestFactoryTest.cs) (revision af575930a392dbf1fb1d5073f3df48110af72686) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/MacroStabilityInwards/MacroStabilityInwardsSoilLayerTwoDEntityTestFactoryTest.cs (.../MacroStabilityInwardsSoilLayerTwoDEntityTestFactoryTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -26,7 +26,7 @@ using NUnit.Framework; using Ringtoets.MacroStabilityInwards.Data.SoilProfile; -namespace Application.Ringtoets.Storage.TestUtil.Test +namespace Application.Ringtoets.Storage.TestUtil.Test.MacroStabilityInwards { [TestFixture] public class MacroStabilityInwardsSoilLayerTwoDEntityTestFactoryTest Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/RingtoetsProjectTestHelperTest.cs =================================================================== diff -u -rb13759ad077f9e2b4104de000b5bdeafa9abe358 -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/RingtoetsProjectTestHelperTest.cs (.../RingtoetsProjectTestHelperTest.cs) (revision b13759ad077f9e2b4104de000b5bdeafa9abe358) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/RingtoetsProjectTestHelperTest.cs (.../RingtoetsProjectTestHelperTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -105,10 +105,12 @@ Assert.AreEqual(1, failureMechanism.StochasticSoilModels.Count); PipingStochasticSoilModel soilModel = failureMechanism.StochasticSoilModels[0]; Assert.AreEqual("modelName", soilModel.Name); - Assert.AreEqual(2, soilModel.StochasticSoilProfiles.Count); - PipingStochasticSoilProfile stochasticSoilProfile1 = soilModel.StochasticSoilProfiles[0]; + + PipingStochasticSoilProfile[] stochasticSoilProfiles = soilModel.StochasticSoilProfiles.ToArray(); + Assert.AreEqual(2, stochasticSoilProfiles.Length); + PipingStochasticSoilProfile stochasticSoilProfile1 = stochasticSoilProfiles[0]; Assert.AreEqual(0.2, stochasticSoilProfile1.Probability); - PipingStochasticSoilProfile stochasticSoilProfile2 = soilModel.StochasticSoilProfiles[1]; + PipingStochasticSoilProfile stochasticSoilProfile2 = stochasticSoilProfiles[1]; Assert.AreEqual(0.8, stochasticSoilProfile2.Probability); Assert.AreEqual("some/path/to/surfaceLineFile", failureMechanism.SurfaceLines.SourcePath); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs =================================================================== diff -u -rb13759ad077f9e2b4104de000b5bdeafa9abe358 -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs (.../RingtoetsProjectTestHelper.cs) (revision b13759ad077f9e2b4104de000b5bdeafa9abe358) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs (.../RingtoetsProjectTestHelper.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -883,14 +883,11 @@ referenceLineGeometryPoints[1], referenceLineGeometryPoints[2], referenceLineGeometryPoints[3] - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.2, pipingSoilProfile), - new PipingStochasticSoilProfile(0.8, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) - } - } + new PipingStochasticSoilProfile(0.2, pipingSoilProfile), + new PipingStochasticSoilProfile(0.8, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }) }, "some/path/to/stochasticSoilModelFile"); pipingFailureMechanism.SurfaceLines.AddRange(new[] { Index: Ringtoets/Integration/test/Ringtoets.Integration.TestUtils.Test/DataUpdateHelperTest.cs =================================================================== diff -u -rb13759ad077f9e2b4104de000b5bdeafa9abe358 -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Integration/test/Ringtoets.Integration.TestUtils.Test/DataUpdateHelperTest.cs (.../DataUpdateHelperTest.cs) (revision b13759ad077f9e2b4104de000b5bdeafa9abe358) +++ Ringtoets/Integration/test/Ringtoets.Integration.TestUtils.Test/DataUpdateHelperTest.cs (.../DataUpdateHelperTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -55,7 +55,7 @@ 1, 2, 1 - }, dikeSection.Piping.StochasticSoilModels.Select(sm => sm.StochasticSoilProfiles.Count)); + }, dikeSection.Piping.StochasticSoilModels.Select(sm => sm.StochasticSoilProfiles.Count())); CollectionAssert.AreEqual(new[] { 0.5, Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformer.cs =================================================================== diff -u -rb13759ad077f9e2b4104de000b5bdeafa9abe358 -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformer.cs (.../MacroStabilityInwardsStochasticSoilModelTransformer.cs) (revision b13759ad077f9e2b4104de000b5bdeafa9abe358) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformer.cs (.../MacroStabilityInwardsStochasticSoilModelTransformer.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -58,11 +58,10 @@ { MacroStabilityInwardsStochasticSoilProfile[] stochasticSoilProfiles = TransformStochasticSoilProfiles(stochasticSoilModel.StochasticSoilProfiles, stochasticSoilModel.Name).ToArray(); - var macroStabilityInwardsModel = new MacroStabilityInwardsStochasticSoilModel(stochasticSoilModel.Name, - stochasticSoilModel.Geometry, - stochasticSoilProfiles); - return macroStabilityInwardsModel; + return new MacroStabilityInwardsStochasticSoilModel(stochasticSoilModel.Name, + stochasticSoilModel.Geometry, + stochasticSoilProfiles); } catch (ArgumentException e) { Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModel.cs =================================================================== diff -u -rb1cb91cbc7d2332a1a82c5d1361c25cd5a4a6ddc -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModel.cs (.../PipingStochasticSoilModel.cs) (revision b1cb91cbc7d2332a1a82c5d1361c25cd5a4a6ddc) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModel.cs (.../PipingStochasticSoilModel.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -37,16 +37,19 @@ /// public class PipingStochasticSoilModel : Observable, IMechanismStochasticSoilModel { + private readonly List stochasticSoilProfiles = new List(); + /// /// Creates a new instance of . /// /// Name of the segment soil model. - /// + /// The geometry of the stochastic soil model. + /// The stochastic soil profiles of the model. /// Thrown when any parameter is /// null. /// Thrown when - /// is empty. - public PipingStochasticSoilModel(string name, IEnumerable geometry) + /// or is empty. + public PipingStochasticSoilModel(string name, IEnumerable geometry, IEnumerable stochasticSoilProfiles) { if (name == null) { @@ -56,6 +59,10 @@ { throw new ArgumentNullException(nameof(geometry)); } + if (stochasticSoilProfiles == null) + { + throw new ArgumentNullException(nameof(stochasticSoilProfiles)); + } if (!geometry.Any()) { string message = string.Format(RingtoetsCommonDataResources.StochasticSoilModel_Geometry_of_StochasticSoilModelName_0_must_contain_a_geometry, name); @@ -64,7 +71,7 @@ Name = name; Geometry = geometry; - StochasticSoilProfiles = new List(); + this.stochasticSoilProfiles.AddRange(stochasticSoilProfiles); } /// @@ -78,9 +85,15 @@ public IEnumerable Geometry { get; private set; } /// - /// Gets the list of . + /// Gets the collection of . /// - public List StochasticSoilProfiles { get; } + public IEnumerable StochasticSoilProfiles + { + get + { + return stochasticSoilProfiles; + } + } /// /// Updates the with the properties from . @@ -124,7 +137,7 @@ } else { - StochasticSoilProfiles.Add(fromProfile); + stochasticSoilProfiles.Add(fromProfile); addedProfiles.Add(fromProfile); } newSoilProfiles.Add(fromProfile.SoilProfile); @@ -134,7 +147,7 @@ sp => !newSoilProfiles.Any(newSp => IsSame(newSp, sp.SoilProfile))).ToArray(); foreach (PipingStochasticSoilProfile profileToRemove in remainingProfiles) { - StochasticSoilProfiles.Remove(profileToRemove); + stochasticSoilProfiles.Remove(profileToRemove); removedProfiles.Add(profileToRemove); } Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingStochasticSoilModelProperties.cs =================================================================== diff -u -ra1eaf8e666afb92642d3efc6877c8e5ac0bdf455 -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingStochasticSoilModelProperties.cs (.../PipingStochasticSoilModelProperties.cs) (revision a1eaf8e666afb92642d3efc6877c8e5ac0bdf455) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingStochasticSoilModelProperties.cs (.../PipingStochasticSoilModelProperties.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -86,7 +86,7 @@ { get { - return data.StochasticSoilProfiles.Count > 0 + return data.StochasticSoilProfiles.Any() ? data.StochasticSoilProfiles.Select(ssp => new PipingStochasticSoilProfileProperties(ssp)).ToArray() : new PipingStochasticSoilProfileProperties[0]; } Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelTransformer.cs =================================================================== diff -u -rc5c91f8ca724aef52a6cd9055a2a32bcd6bc0c03 -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelTransformer.cs (.../PipingStochasticSoilModelTransformer.cs) (revision c5c91f8ca724aef52a6cd9055a2a32bcd6bc0c03) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelTransformer.cs (.../PipingStochasticSoilModelTransformer.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -56,11 +56,10 @@ try { - var pipingModel = new PipingStochasticSoilModel(stochasticSoilModel.Name, stochasticSoilModel.Geometry); - pipingModel.StochasticSoilProfiles.AddRange( - TransformStochasticSoilProfiles(stochasticSoilModel.StochasticSoilProfiles, stochasticSoilModel.Name).ToArray()); + PipingStochasticSoilProfile[] pipingStochasticSoilProfiles = + TransformStochasticSoilProfiles(stochasticSoilModel.StochasticSoilProfiles, stochasticSoilModel.Name).ToArray(); - return pipingModel; + return new PipingStochasticSoilModel(stochasticSoilModel.Name, stochasticSoilModel.Geometry, pipingStochasticSoilProfiles); } catch (ArgumentException e) { Index: Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingInputService.cs =================================================================== diff -u -r26f527fb809a2325c8f883ece9da01a8f8040eb3 -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingInputService.cs (.../PipingInputService.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) +++ Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingInputService.cs (.../PipingInputService.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -63,7 +63,7 @@ { if (pipingInput.StochasticSoilModel != null) { - if (pipingInput.StochasticSoilModel.StochasticSoilProfiles.Count == 1) + if (pipingInput.StochasticSoilModel.StochasticSoilProfiles.Count() == 1) { pipingInput.StochasticSoilProfile = pipingInput.StochasticSoilModel.StochasticSoilProfiles.First(); return; Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilModelTest.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilModelTest.cs (.../PipingStochasticSoilModelTest.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilModelTest.cs (.../PipingStochasticSoilModelTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -41,43 +41,54 @@ { // Call TestDelegate test = () => new PipingStochasticSoilModel(null, new[] - { - new Point2D(1, 1) - }); + { + new Point2D(1, 1) + }, + new[] + { + CreateStochasticSoilProfile() + }); // Assert var exception = Assert.Throws(test); Assert.AreEqual("name", exception.ParamName); } [Test] - public void Constructor_ValidName_ExpectedValues() + public void Constructor_ValidParameters_ExpectedValues() { // Setup const string name = "name"; var geometry = new[] { new Point2D(1, 1) }; + var stochasticSoilProfiles = new[] + { + CreateStochasticSoilProfile() + }; // Call - var model = new PipingStochasticSoilModel(name, geometry); + var model = new PipingStochasticSoilModel(name, geometry, stochasticSoilProfiles); // Assert Assert.IsInstanceOf(model); Assert.IsInstanceOf(model); Assert.AreEqual(name, model.Name); Assert.AreSame(geometry, model.Geometry); - CollectionAssert.IsEmpty(model.StochasticSoilProfiles); + CollectionAssert.AreEqual(stochasticSoilProfiles, model.StochasticSoilProfiles); Assert.AreEqual(name, model.ToString()); } [Test] public void Constructor_WithGeometryNull_ThrowsArgumentNullException() { // Call - TestDelegate call = () => new PipingStochasticSoilModel(string.Empty, null); + TestDelegate call = () => new PipingStochasticSoilModel(string.Empty, null, new[] + { + CreateStochasticSoilProfile() + }); // Assert var exception = Assert.Throws(call); @@ -91,23 +102,48 @@ const string name = "modelName"; // Call - TestDelegate call = () => new PipingStochasticSoilModel(name, Enumerable.Empty()); + TestDelegate call = () => new PipingStochasticSoilModel(name, Enumerable.Empty(), new[] + { + CreateStochasticSoilProfile() + }); // Assert string expectedMessage = $"Het stochastische ondergrondmodel '{name}' moet een geometrie bevatten."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); } [Test] - public void Update_WithNullModel_ThrowsArgumentNullException() + public void Constructor_StochasticSoilProfilesNull_ThrowsArgumentNullException() { // Setup - var model = new PipingStochasticSoilModel("name", new[] + const string name = "name"; + var geometry = new[] { new Point2D(1, 1) - }); + }; // Call + TestDelegate call = () => new PipingStochasticSoilModel(name, geometry, null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("stochasticSoilProfiles", exception.ParamName); + } + + [Test] + public void Update_WithNullModel_ThrowsArgumentNullException() + { + // Setup + var model = new PipingStochasticSoilModel("name", new[] + { + new Point2D(1, 1) + }, + new[] + { + CreateStochasticSoilProfile() + }); + + // Call TestDelegate test = () => model.Update(null); // Assert @@ -123,6 +159,9 @@ { new Point2D(1, 2), new Point2D(4, 5) + }, new[] + { + CreateStochasticSoilProfile() }); const string expectedName = "otherName"; @@ -131,7 +170,10 @@ new Point2D(4, 2) }; - var otherModel = new PipingStochasticSoilModel(expectedName, expectedGeometry); + var otherModel = new PipingStochasticSoilModel(expectedName, expectedGeometry, new[] + { + CreateStochasticSoilProfile() + }); // Call PipingStochasticSoilModelProfileDifference difference = model.Update(otherModel); @@ -149,17 +191,24 @@ public void Update_ModelWithAddedProfile_ProfileAdded() { // Setup - PipingStochasticSoilModel model = CreateValidModel(); - PipingStochasticSoilModel otherModel = CreateValidModel(); + PipingStochasticSoilModel model = CreateValidModel(new[] + { + CreateStochasticSoilProfile() + }); + var expectedAddedProfile = new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); - otherModel.StochasticSoilProfiles.Add(expectedAddedProfile); + PipingStochasticSoilModel otherModel = CreateValidModel(new[] + { + expectedAddedProfile, + CreateStochasticSoilProfile() + }); // Call PipingStochasticSoilModelProfileDifference difference = model.Update(otherModel); // Assert - Assert.AreEqual(1, otherModel.StochasticSoilProfiles.Count); - Assert.AreEqual(expectedAddedProfile, otherModel.StochasticSoilProfiles[0]); + Assert.AreEqual(2, otherModel.StochasticSoilProfiles.Count()); + Assert.AreEqual(expectedAddedProfile, otherModel.StochasticSoilProfiles.First()); CollectionAssert.AreEqual(new[] { @@ -177,19 +226,22 @@ var expectedUpdatedProfile = new PipingStochasticSoilProfile( 0.2, new PipingSoilProfile(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile1D)); - PipingStochasticSoilModel model = CreateValidModel(); - model.StochasticSoilProfiles.Add(expectedUpdatedProfile); - PipingStochasticSoilModel otherModel = CreateValidModel(); - otherModel.StochasticSoilProfiles.Add(new PipingStochasticSoilProfile( - 0.2, - new PipingSoilProfile(profileName, -1, CreateLayers(), SoilProfileType.SoilProfile1D))); + PipingStochasticSoilModel model = CreateValidModel(new[] + { + expectedUpdatedProfile + }); + PipingStochasticSoilModel otherModel = CreateValidModel(new[] + { + new PipingStochasticSoilProfile(0.2, + new PipingSoilProfile(profileName, -1, CreateLayers(), SoilProfileType.SoilProfile1D)) + }); // Call PipingStochasticSoilModelProfileDifference difference = model.Update(otherModel); // Assert - Assert.AreEqual(1, otherModel.StochasticSoilProfiles.Count); - Assert.AreEqual(expectedUpdatedProfile, otherModel.StochasticSoilProfiles[0]); + Assert.AreEqual(1, otherModel.StochasticSoilProfiles.Count()); + Assert.AreEqual(expectedUpdatedProfile, otherModel.StochasticSoilProfiles.First()); CollectionAssert.IsEmpty(difference.AddedProfiles); CollectionAssert.AreEqual(new[] @@ -206,11 +258,15 @@ const string profileName = "A"; var soilProfile = new PipingSoilProfile(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile1D); var expectedUpdatedProfile = new PipingStochasticSoilProfile(0.2, soilProfile); - PipingStochasticSoilModel model = CreateValidModel(); - model.StochasticSoilProfiles.Add(expectedUpdatedProfile); + PipingStochasticSoilModel model = CreateValidModel(new[] + { + expectedUpdatedProfile + }); - PipingStochasticSoilModel otherModel = CreateValidModel(); - otherModel.StochasticSoilProfiles.Add(new PipingStochasticSoilProfile(0.5, soilProfile)); + PipingStochasticSoilModel otherModel = CreateValidModel(new[] + { + new PipingStochasticSoilProfile(0.5, soilProfile) + }); // Call PipingStochasticSoilModelProfileDifference difference = model.Update(otherModel); @@ -231,10 +287,16 @@ const string profileName = "A"; var soilProfile = new PipingSoilProfile(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile1D); var expectedRemovedProfile = new PipingStochasticSoilProfile(0.2, soilProfile); - PipingStochasticSoilModel model = CreateValidModel(); - model.StochasticSoilProfiles.Add(expectedRemovedProfile); + PipingStochasticSoilModel model = CreateValidModel(new[] + { + CreateStochasticSoilProfile(), + expectedRemovedProfile + }); - PipingStochasticSoilModel otherModel = CreateValidModel(); + PipingStochasticSoilModel otherModel = CreateValidModel(new[] + { + CreateStochasticSoilProfile() + }); // Call PipingStochasticSoilModelProfileDifference difference = model.Update(otherModel); @@ -258,11 +320,17 @@ var newProfile = new PipingStochasticSoilProfile( 0.2, new PipingSoilProfile(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile2D)); - PipingStochasticSoilModel model = CreateValidModel(); - model.StochasticSoilProfiles.Add(expectedRemovedProfile); + PipingStochasticSoilModel model = CreateValidModel(new[] + { + CreateStochasticSoilProfile(), + expectedRemovedProfile + }); - PipingStochasticSoilModel otherModel = CreateValidModel(); - otherModel.StochasticSoilProfiles.Add(newProfile); + PipingStochasticSoilModel otherModel = CreateValidModel(new[] + { + CreateStochasticSoilProfile(), + newProfile + }); // Call PipingStochasticSoilModelProfileDifference difference = model.Update(otherModel); @@ -284,42 +352,46 @@ { // Setup const string equalProfileName = "nameA"; - PipingStochasticSoilModel model = CreateValidModel(); - var stochasticProfileA = new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile(equalProfileName)); var stochasticProfileB = new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("nameB")); - model.StochasticSoilProfiles.Add(stochasticProfileA); - model.StochasticSoilProfiles.Add(stochasticProfileB); + PipingStochasticSoilModel model = CreateValidModel(new[] + { + stochasticProfileA, + stochasticProfileB + }); const string otherName = "other name"; var otherGeometry = new[] { new Point2D(2, 0), new Point2D(3, 0) }; - var otherModel = new PipingStochasticSoilModel(otherName, otherGeometry); - var otherStochasticProfileA = new PipingStochasticSoilProfile( 0.7, new PipingSoilProfile(equalProfileName, -1, new[] { new PipingSoilLayer(0) }, SoilProfileType.SoilProfile1D)); var otherStochasticProfileB = new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile("other profile name")); - otherModel.StochasticSoilProfiles.Add(otherStochasticProfileA); - otherModel.StochasticSoilProfiles.Add(otherStochasticProfileB); + var otherModel = new PipingStochasticSoilModel(otherName, otherGeometry, new[] + { + otherStochasticProfileA, + otherStochasticProfileB + }); // Call PipingStochasticSoilModelProfileDifference difference = model.Update(otherModel); // Assert Assert.AreEqual(otherName, model.Name); Assert.AreSame(otherGeometry, model.Geometry); - Assert.AreEqual(2, model.StochasticSoilProfiles.Count); - Assert.AreSame(stochasticProfileA, model.StochasticSoilProfiles[0]); - Assert.AreSame(otherStochasticProfileA.SoilProfile, model.StochasticSoilProfiles[0].SoilProfile); - Assert.AreNotSame(stochasticProfileB, model.StochasticSoilProfiles[1]); - Assert.AreSame(otherStochasticProfileB.SoilProfile, model.StochasticSoilProfiles[1].SoilProfile); + PipingStochasticSoilProfile[] stochasticSoilProfiles = model.StochasticSoilProfiles.ToArray(); + Assert.AreEqual(2, stochasticSoilProfiles.Length); + Assert.AreSame(stochasticProfileA, stochasticSoilProfiles[0]); + Assert.AreSame(otherStochasticProfileA.SoilProfile, stochasticSoilProfiles[0].SoilProfile); + Assert.AreNotSame(stochasticProfileB, stochasticSoilProfiles[1]); + Assert.AreSame(otherStochasticProfileB.SoilProfile, stochasticSoilProfiles[1].SoilProfile); + CollectionAssert.AreEqual(new[] { stochasticProfileA @@ -340,33 +412,43 @@ // Setup const string profileName = "Name of the profile"; var addedProfile = new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile(profileName)); - PipingStochasticSoilModel otherModel = CreateValidModel(); - otherModel.StochasticSoilProfiles.Add(addedProfile); + PipingStochasticSoilModel otherModel = CreateValidModel(new[] + { + addedProfile + }); PipingSoilProfile soilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile(profileName); var existingStochasticSoilProfileOne = new PipingStochasticSoilProfile(0.2, soilProfile); var existingStochasticSoilProfileTwo = new PipingStochasticSoilProfile(0.3, soilProfile); - PipingStochasticSoilModel model = CreateValidModel(); - model.StochasticSoilProfiles.Add(existingStochasticSoilProfileOne); - model.StochasticSoilProfiles.Add(existingStochasticSoilProfileTwo); + PipingStochasticSoilModel model = CreateValidModel(new[] + { + existingStochasticSoilProfileOne, + existingStochasticSoilProfileTwo + }); // Call TestDelegate call = () => model.Update(otherModel); // Assert Assert.Throws(call); - Assert.AreEqual(1, otherModel.StochasticSoilProfiles.Count); - Assert.AreEqual(addedProfile, otherModel.StochasticSoilProfiles[0]); + Assert.AreEqual(1, otherModel.StochasticSoilProfiles.Count()); + Assert.AreEqual(addedProfile, otherModel.StochasticSoilProfiles.First()); - Assert.AreEqual(2, model.StochasticSoilProfiles.Count); + Assert.AreEqual(2, model.StochasticSoilProfiles.Count()); CollectionAssert.AreEqual(new[] { existingStochasticSoilProfileOne, existingStochasticSoilProfileTwo }, model.StochasticSoilProfiles); } + private static PipingStochasticSoilProfile CreateStochasticSoilProfile() + { + var random = new Random(21); + return new PipingStochasticSoilProfile(random.NextDouble(), PipingSoilProfileTestFactory.CreatePipingSoilProfile(string.Empty)); + } + private static IEnumerable CreateLayers() { return new[] @@ -375,14 +457,14 @@ }; } - private static PipingStochasticSoilModel CreateValidModel() + private static PipingStochasticSoilModel CreateValidModel(IEnumerable stochasticSoilProfiles) { var random = new Random(21); var geometry = new[] { new Point2D(random.NextDouble(), random.NextDouble()) }; - return new PipingStochasticSoilModel("name", geometry); + return new PipingStochasticSoilModel("name", geometry, stochasticSoilProfiles); } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil.Test/PipingStochasticSoilModelTestFactoryTest.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil.Test/PipingStochasticSoilModelTestFactoryTest.cs (.../PipingStochasticSoilModelTestFactoryTest.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil.Test/PipingStochasticSoilModelTestFactoryTest.cs (.../PipingStochasticSoilModelTestFactoryTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -40,7 +40,7 @@ // Assert Assert.AreEqual(typeof(PipingStochasticSoilModel), model.GetType()); Assert.IsEmpty(model.Name); - Assert.AreEqual(2, model.StochasticSoilProfiles.Count); + Assert.AreEqual(2, model.StochasticSoilProfiles.Count()); CollectionAssert.AreEquivalent(new[] { @@ -67,7 +67,7 @@ // Assert Assert.AreEqual(typeof(PipingStochasticSoilModel), model.GetType()); Assert.AreEqual(name, model.Name); - Assert.AreEqual(2, model.StochasticSoilProfiles.Count); + Assert.AreEqual(2, model.StochasticSoilProfiles.Count()); CollectionAssert.AreEquivalent(new[] { 0.5, @@ -98,7 +98,7 @@ // Assert Assert.AreEqual(typeof(PipingStochasticSoilModel), model.GetType()); Assert.AreEqual(name, model.Name); - Assert.AreEqual(2, model.StochasticSoilProfiles.Count); + Assert.AreEqual(2, model.StochasticSoilProfiles.Count()); CollectionAssert.AreEquivalent(new[] { 0.5, @@ -133,5 +133,30 @@ new Point2D(2, 2) }, model.Geometry); } + + [Test] + public void CreatePipingStochasticSoilModel_WithStochasticSoilProfiles_ExpectedPropertiesSet() + { + // Setup + var random = new Random(21); + var stochasticProfiles = new[] + { + new PipingStochasticSoilProfile(random.NextDouble(), PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }; + + // Call + PipingStochasticSoilModel model = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(stochasticProfiles); + + // Assert + Assert.AreEqual(typeof(PipingStochasticSoilModel), model.GetType()); + Assert.IsEmpty(model.Name); + CollectionAssert.AreEqual(stochasticProfiles, model.StochasticSoilProfiles); + CollectionAssert.AllItemsAreNotNull(model.StochasticSoilProfiles.Select(p => p.SoilProfile)); + CollectionAssert.AreEqual(new[] + { + new Point2D(1, 1), + new Point2D(2, 2) + }, model.Geometry); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingStochasticSoilModelTestFactory.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingStochasticSoilModelTestFactory.cs (.../PipingStochasticSoilModelTestFactory.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingStochasticSoilModelTestFactory.cs (.../PipingStochasticSoilModelTestFactory.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -69,14 +69,11 @@ /// Thrown when is empty. public static PipingStochasticSoilModel CreatePipingStochasticSoilModel(string name, IEnumerable geometry) { - return new PipingStochasticSoilModel(name, geometry) + return new PipingStochasticSoilModel(name, geometry, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("A")), - new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("B")) - } - }; + new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("A")), + new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("B")) + }); } /// @@ -90,14 +87,26 @@ /// Thrown when is empty. public static PipingStochasticSoilModel CreatePipingStochasticSoilModel(string name, IEnumerable pipingStochasticSoilProfiles) { - var model = new PipingStochasticSoilModel(name, new[] + return new PipingStochasticSoilModel(name, new[] { new Point2D(1, 1), new Point2D(2, 2) - }); - model.StochasticSoilProfiles.AddRange(pipingStochasticSoilProfiles); + }, pipingStochasticSoilProfiles); + } - return model; + /// + /// Creates an instance of + /// with specified stochastic soil profiles and an empty name. + /// + /// The geometry of the soil model. + /// A valid configured with the + /// specified . + /// Thrown when is null. + /// Thrown when is + /// empty. + public static PipingStochasticSoilModel CreatePipingStochasticSoilModel(IEnumerable stochasticSoilProfiles) + { + return CreatePipingStochasticSoilModel(string.Empty, stochasticSoilProfiles); } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingTestDataGenerator.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingTestDataGenerator.cs (.../PipingTestDataGenerator.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingTestDataGenerator.cs (.../PipingTestDataGenerator.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.Linq; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.TestUtil; @@ -270,24 +271,19 @@ { new Point2D(-5, 5), new Point2D(5, 5) - }) + }, new[] + { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) - } - }; + new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }); var stochasticSoilModel2 = new PipingStochasticSoilModel("C", new[] { new Point2D(5, 5), new Point2D(15, 5) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) - } - }; + new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }); failureMechanism.StochasticSoilModels.AddRange(new[] { @@ -314,7 +310,7 @@ HydraulicBoundaryLocation = hydraulicBoundaryLocation, SurfaceLine = surfaceLine1, StochasticSoilModel = stochasticSoilModel1, - StochasticSoilProfile = stochasticSoilModel1.StochasticSoilProfiles[0] + StochasticSoilProfile = stochasticSoilModel1.StochasticSoilProfiles.First() } }; var calculationWithOutputAndHydraulicBoundaryLocation = new PipingCalculationScenario(new GeneralPipingInput()) @@ -341,7 +337,7 @@ { SurfaceLine = surfaceLine1, StochasticSoilModel = stochasticSoilModel2, - StochasticSoilProfile = stochasticSoilModel2.StochasticSoilProfiles[0] + StochasticSoilProfile = stochasticSoilModel2.StochasticSoilProfiles.First() } }; @@ -353,7 +349,7 @@ HydraulicBoundaryLocation = hydraulicBoundaryLocation, SurfaceLine = surfaceLine2, StochasticSoilModel = stochasticSoilModel2, - StochasticSoilProfile = stochasticSoilModel2.StochasticSoilProfiles[0] + StochasticSoilProfile = stochasticSoilModel2.StochasticSoilProfiles.First() }, Output = new TestPipingOutput(), SemiProbabilisticOutput = new TestPipingSemiProbabilisticOutput() @@ -365,7 +361,7 @@ HydraulicBoundaryLocation = hydraulicBoundaryLocation, SurfaceLine = surfaceLine1, StochasticSoilModel = stochasticSoilModel1, - StochasticSoilProfile = stochasticSoilModel1.StochasticSoilProfiles[0] + StochasticSoilProfile = stochasticSoilModel1.StochasticSoilProfiles.First() }, Output = new TestPipingOutput(), SemiProbabilisticOutput = new TestPipingSemiProbabilisticOutput() @@ -383,7 +379,7 @@ { SurfaceLine = surfaceLine1, StochasticSoilModel = stochasticSoilModel2, - StochasticSoilProfile = stochasticSoilModel2.StochasticSoilProfiles[0] + StochasticSoilProfile = stochasticSoilModel2.StochasticSoilProfiles.First() } }; Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PipingCalculationConfigurationHelperTest.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PipingCalculationConfigurationHelperTest.cs (.../PipingCalculationConfigurationHelperTest.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PipingCalculationConfigurationHelperTest.cs (.../PipingCalculationConfigurationHelperTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -76,14 +76,11 @@ { new Point2D(1.0, 0.0), new Point2D(5.0, 0.0) - }) + }, new[] { - StochasticSoilProfiles = - { - soilProfile1, - soilProfile2 - } - }; + soilProfile1, + soilProfile2 + }); PipingStochasticSoilModel[] availableSoilModels = { @@ -132,14 +129,11 @@ { new Point2D(1.0, 0.0), new Point2D(5.0, 0.0) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.3, soilProfile1), - new PipingStochasticSoilProfile(0.7, soilProfile2) - } - }; + new PipingStochasticSoilProfile(0.3, soilProfile1), + new PipingStochasticSoilProfile(0.7, soilProfile2) + }); PipingStochasticSoilModel[] availableSoilModels = { @@ -184,7 +178,7 @@ { new Point2D(1.0, 0.0), new Point2D(5.0, 0.0) - }); + }, Enumerable.Empty()); var availableSoilModels = new[] { @@ -229,14 +223,11 @@ { new Point2D(1.0, 0.0), new Point2D(5.0, 0.0) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.3, soilProfile1), - new PipingStochasticSoilProfile(0.7, soilProfile2) - } - }; + new PipingStochasticSoilProfile(0.3, soilProfile1), + new PipingStochasticSoilProfile(0.7, soilProfile2) + }); PipingStochasticSoilModel[] availableSoilModels = { @@ -263,6 +254,7 @@ public void GetStochasticSoilModelsForSurfaceLine_SurfaceLineOverlappingSoilModels_ReturnSoilModels() { // Setup + const double y = 1.1; var soilProfile1 = new PipingStochasticSoilProfile( 1.0, new PipingSoilProfile("Profile 1", -10.0, new[] { @@ -271,6 +263,15 @@ new PipingSoilLayer(1.0) }, SoilProfileType.SoilProfile1D) ); + var soilModel1 = new PipingStochasticSoilModel("A", new[] + { + new Point2D(1.0, y), + new Point2D(2.0, y) + }, new[] + { + soilProfile1 + }); + var soilProfile2 = new PipingStochasticSoilProfile( 1.0, new PipingSoilProfile("Profile 2", -8.0, new[] { @@ -279,31 +280,14 @@ new PipingSoilLayer(4.0) }, SoilProfileType.SoilProfile1D) ); - - const double y = 1.1; - var soilModel1 = new PipingStochasticSoilModel("A", new[] - { - new Point2D(1.0, y), - new Point2D(2.0, y) - }) - { - StochasticSoilProfiles = - { - soilProfile1 - } - }; - var soilModel2 = new PipingStochasticSoilModel("A", new[] { new Point2D(3.0, y), new Point2D(4.0, y) - }) + }, new[] { - StochasticSoilProfiles = - { - soilProfile2 - } - }; + soilProfile2 + }); var availableSoilModels = new[] { @@ -443,14 +427,11 @@ { new Point2D(1.0, 0.0), new Point2D(5.0, 0.0) - }) + }, new[] { - StochasticSoilProfiles = - { - soilProfile1, - soilProfile2 - } - }; + soilProfile1, + soilProfile2 + }); var availableSoilModels = new[] { @@ -507,7 +488,7 @@ { new Point2D(1.0, 0.0), new Point2D(5.0, 0.0) - }); + }, Enumerable.Empty()); var availableSoilModels = new[] { @@ -568,14 +549,11 @@ { new Point2D(1.0, 0.0), new Point2D(5.0, 0.0) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.3, soilProfile1), - new PipingStochasticSoilProfile(0.7, soilProfile2) - } - }; + new PipingStochasticSoilProfile(0.3, soilProfile1), + new PipingStochasticSoilProfile(0.7, soilProfile2) + }); PipingStochasticSoilModel[] availableSoilModels = { @@ -620,6 +598,7 @@ public void GenerateCalculationItemsStructure_SurfaceLineOverlappingSoilModel_ReturnOneGroupWithProfilesFromBothSoilModels() { // Setup + const double y = 1.1; var soilProfile1 = new PipingStochasticSoilProfile( 1.0, new PipingSoilProfile("Profile 1", -10.0, new[] { @@ -628,6 +607,15 @@ new PipingSoilLayer(1.0) }, SoilProfileType.SoilProfile1D) ); + var soilModel1 = new PipingStochasticSoilModel("A", new[] + { + new Point2D(1.0, y), + new Point2D(2.0, y) + }, new[] + { + soilProfile1 + }); + var soilProfile2 = new PipingStochasticSoilProfile( 1.0, new PipingSoilProfile("Profile 2", -8.0, new[] { @@ -636,31 +624,14 @@ new PipingSoilLayer(4.0) }, SoilProfileType.SoilProfile1D) ); - - const double y = 1.1; - var soilModel1 = new PipingStochasticSoilModel("A", new[] - { - new Point2D(1.0, y), - new Point2D(2.0, y) - }) - { - StochasticSoilProfiles = - { - soilProfile1 - } - }; - var soilModel2 = new PipingStochasticSoilModel("A", new[] { new Point2D(3.0, y), new Point2D(4.0, y) - }) + }, new[] { - StochasticSoilProfiles = - { - soilProfile2 - } - }; + soilProfile2 + }); var availableSoilModels = new[] { @@ -736,26 +707,21 @@ { new Point2D(1.0, y), new Point2D(2.0, y) - }) + }, new[] { - StochasticSoilProfiles = - { - soilProfile1, - soilProfile2 - } - }; + soilProfile1, + soilProfile2 + }); var soilModel2 = new PipingStochasticSoilModel("A", new[] { new Point2D(3.0, y), new Point2D(4.0, y) - }) + }, new[] { - StochasticSoilProfiles = - { - soilProfile2 - } - }; + soilProfile2 + }); + var availableSoilModels = new[] { soilModel1, @@ -851,26 +817,20 @@ { new Point2D(1.0, y), new Point2D(2.0, y) - }) + }, new[] { - StochasticSoilProfiles = - { - soilProfile1, - soilProfile2 - } - }; + soilProfile1, + soilProfile2 + }); var soilModel2 = new PipingStochasticSoilModel("A", new[] { new Point2D(3.0, y), new Point2D(4.0, y) - }) + }, new[] { - StochasticSoilProfiles = - { - soilProfile2 - } - }; + soilProfile2 + }); var availableSoilModels = new[] { soilModel1, @@ -957,14 +917,12 @@ { new Point2D(1.0, 0.0), new Point2D(5.0, 0.0) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.3, soilProfile1), - new PipingStochasticSoilProfile(0.7, soilProfile2) - } - }; + new PipingStochasticSoilProfile(0.3, soilProfile1), + new PipingStochasticSoilProfile(0.7, soilProfile2) + }); + var availableSoilModels = new[] { soilModel @@ -1031,15 +989,13 @@ { new Point2D(1.0, 0.0), new Point2D(5.0, 0.0) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.3, soilProfile1), - new PipingStochasticSoilProfile(0.2, soilProfile2), - new PipingStochasticSoilProfile(0.5, soilProfile3) - } - }; + new PipingStochasticSoilProfile(0.3, soilProfile1), + new PipingStochasticSoilProfile(0.2, soilProfile2), + new PipingStochasticSoilProfile(0.5, soilProfile3) + }); + var availableSoilModels = new[] { soilModel Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -1487,35 +1487,26 @@ { new Point2D(2, -1), new Point2D(2, 1) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) - } - }, + new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }), new PipingStochasticSoilModel("C", new[] { new Point2D(-2, -1), new Point2D(-2, 1) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) - } - }, + new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }), new PipingStochasticSoilModel("E", new[] { new Point2D(6, -1), new Point2D(6, 1) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) - } - } + new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }) }; failureMechanism.StochasticSoilModels.AddRange(soilModels, "path"); var calculation = new PipingCalculationScenario(failureMechanism.GeneralInput) @@ -2021,13 +2012,10 @@ { new Point2D(xMin, 1.0), new Point2D(xMax, 0.0) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) - } - }; + new PipingStochasticSoilProfile(0.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }); } private static PipingSurfaceLine ValidSurfaceLine(double xMin, double xMax) Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingStochasticSoilModelPropertiesTest.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingStochasticSoilModelPropertiesTest.cs (.../PipingStochasticSoilModelPropertiesTest.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingStochasticSoilModelPropertiesTest.cs (.../PipingStochasticSoilModelPropertiesTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -21,6 +21,7 @@ using System; using System.ComponentModel; +using System.Linq; using Core.Common.Base.Geometry; using Core.Common.Gui.Converters; using Core.Common.Gui.PropertyBag; @@ -74,13 +75,10 @@ var stochasticSoilModel = new PipingStochasticSoilModel("Name", new[] { new Point2D(1.0, 2.0) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) - } - }; + new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }); // Call var properties = new PipingStochasticSoilModelProperties(stochasticSoilModel); @@ -89,8 +87,9 @@ Assert.AreEqual(stochasticSoilModel.Name, properties.Name); CollectionAssert.AreEqual(stochasticSoilModel.Geometry, properties.Geometry); - Assert.AreEqual(1, properties.StochasticSoilProfiles.Length); - Assert.AreSame(stochasticSoilModel.StochasticSoilProfiles[0], properties.StochasticSoilProfiles[0].Data); + PipingStochasticSoilProfile[] stochasticSoilProfiles = stochasticSoilModel.StochasticSoilProfiles.ToArray(); + Assert.AreEqual(stochasticSoilProfiles.Length, properties.StochasticSoilProfiles.Length); + Assert.AreSame(stochasticSoilProfiles[0], properties.StochasticSoilProfiles[0].Data); } [Test] Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilModelSelectionEditorTest.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilModelSelectionEditorTest.cs (.../PipingInputContextStochasticSoilModelSelectionEditorTest.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilModelSelectionEditorTest.cs (.../PipingInputContextStochasticSoilModelSelectionEditorTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -108,13 +108,11 @@ { new Point2D(0, 2), new Point2D(4, 2) - }) + }, new[] { - StochasticSoilProfiles = - { - stochasticSoilProfile - } - }; + stochasticSoilProfile + }); + var surfaceLine = new PipingSurfaceLine(string.Empty); surfaceLine.SetGeometry(new[] { Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilProfileSelectionEditorTest.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilProfileSelectionEditorTest.cs (.../PipingInputContextStochasticSoilProfileSelectionEditorTest.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilProfileSelectionEditorTest.cs (.../PipingInputContextStochasticSoilProfileSelectionEditorTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -108,13 +108,11 @@ { new Point2D(0, 2), new Point2D(4, 2) - }) + }, new[] { - StochasticSoilProfiles = - { - stochasticSoilProfile - } - }; + stochasticSoilProfile + }); + var surfaceLine = new PipingSurfaceLine(string.Empty); surfaceLine.SetGeometry(new[] { Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -40,7 +40,6 @@ using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.Views; -using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Primitives; using Ringtoets.Piping.Primitives.TestUtil; @@ -1478,14 +1477,11 @@ { new Point2D(0.0, 0.0), new Point2D(5.0, 0.0) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("A")), - new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("B")) - } - } + new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("A")), + new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("B")) + }) }, arbirtraryFilePath); pipingFailureMechanism.AddSection(new FailureMechanismSection("Section 1", new List @@ -1613,19 +1609,16 @@ { new Point2D(0.0, 0.0), new Point2D(5.0, 0.0) - }) + }, new[] { - StochasticSoilProfiles = + stochasticSoilProfile1, + new PipingStochasticSoilProfile(0.7, new PipingSoilProfile("Profile 2", -8.0, new[] { - stochasticSoilProfile1, - new PipingStochasticSoilProfile(0.7, new PipingSoilProfile("Profile 2", -8.0, new[] - { - new PipingSoilLayer(-4.0), - new PipingSoilLayer(0.0), - new PipingSoilLayer(4.0) - }, SoilProfileType.SoilProfile1D)) - } - }; + new PipingSoilLayer(-4.0), + new PipingSoilLayer(0.0), + new PipingSoilLayer(4.0) + }, SoilProfileType.SoilProfile1D)) + }); var stochasticSoilProfile5 = new PipingStochasticSoilProfile( 0.3, new PipingSoilProfile("Profile 5", -10.0, new[] @@ -1639,13 +1632,10 @@ { new Point2D(1.0, 0.0), new Point2D(6.0, 0.0) - }) + }, new[] { - StochasticSoilProfiles = - { - stochasticSoilProfile5 - } - }; + stochasticSoilProfile5 + }); pipingFailureMechanism.StochasticSoilModels.AddRange(new[] { @@ -1654,24 +1644,21 @@ { new Point2D(1.0, 0.0), new Point2D(4.0, 0.0) - }) + }, new[] { - StochasticSoilProfiles = + new PipingStochasticSoilProfile(0.3, new PipingSoilProfile("Profile 3", -10.0, new[] { - new PipingStochasticSoilProfile(0.3, new PipingSoilProfile("Profile 3", -10.0, new[] - { - new PipingSoilLayer(-5.0), - new PipingSoilLayer(-2.0), - new PipingSoilLayer(1.0) - }, SoilProfileType.SoilProfile1D)), - new PipingStochasticSoilProfile(0.7, new PipingSoilProfile("Profile 4", -8.0, new[] - { - new PipingSoilLayer(-4.0), - new PipingSoilLayer(0.0), - new PipingSoilLayer(4.0) - }, SoilProfileType.SoilProfile1D)) - } - }, + new PipingSoilLayer(-5.0), + new PipingSoilLayer(-2.0), + new PipingSoilLayer(1.0) + }, SoilProfileType.SoilProfile1D)), + new PipingStochasticSoilProfile(0.7, new PipingSoilProfile("Profile 4", -8.0, new[] + { + new PipingSoilLayer(-4.0), + new PipingSoilLayer(0.0), + new PipingSoilLayer(4.0) + }, SoilProfileType.SoilProfile1D)) + }), stochasticSoilModelE }, arbitraryFilePath); return pipingFailureMechanism; Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationImporterTest.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationImporterTest.cs (.../PipingCalculationConfigurationImporterTest.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationImporterTest.cs (.../PipingCalculationConfigurationImporterTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -586,8 +586,10 @@ { new Point2D(1.0, 0.0), new Point2D(5.0, 0.0) + }, new[] + { + stochasticSoilProfile }); - stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfile); var pipingFailureMechanism = new PipingFailureMechanism(); pipingFailureMechanism.SurfaceLines.AddRange(new[] Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs =================================================================== diff -u -r30baf70ea42def18e66d1ec3c71aa0e54a89229a -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs (.../PipingStochasticSoilModelTransformerTest.cs) (revision 30baf70ea42def18e66d1ec3c71aa0e54a89229a) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs (.../PipingStochasticSoilModelTransformerTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -178,14 +178,14 @@ // Assert Assert.AreEqual(name, transformed.Name); - Assert.AreEqual(1, transformed.StochasticSoilProfiles.Count); + Assert.AreEqual(1, transformed.StochasticSoilProfiles.Count()); CollectionAssert.AreEqual(soilModel.Geometry, transformed.Geometry); - var expectedPipingSoilProfile = new List + var expectedPipingSoilProfile = new[] { new PipingStochasticSoilProfile(probability, PipingSoilProfileTransformer.Transform(profile)) }; - AssertPipingStochasticSoilProfiles(expectedPipingSoilProfile, transformed.StochasticSoilProfiles); + AssertPipingStochasticSoilProfiles(expectedPipingSoilProfile, transformed.StochasticSoilProfiles.ToArray()); } [Test] @@ -220,10 +220,10 @@ PipingStochasticSoilModel transformed2 = transformer.Transform(soilModel2); // Assert - List transformedStochasticSoilProfiles1 = transformed1.StochasticSoilProfiles; - List transformedStochasticSoilProfiles2 = transformed2.StochasticSoilProfiles; - Assert.AreEqual(1, transformedStochasticSoilProfiles1.Count); - Assert.AreEqual(1, transformedStochasticSoilProfiles2.Count); + PipingStochasticSoilProfile[] transformedStochasticSoilProfiles1 = transformed1.StochasticSoilProfiles.ToArray(); + PipingStochasticSoilProfile[] transformedStochasticSoilProfiles2 = transformed2.StochasticSoilProfiles.ToArray(); + Assert.AreEqual(1, transformedStochasticSoilProfiles1.Length); + Assert.AreEqual(1, transformedStochasticSoilProfiles2.Length); PipingStochasticSoilProfile pipingStochasticSoilProfile1 = transformedStochasticSoilProfiles1[0]; PipingStochasticSoilProfile pipingStochasticSoilProfile2 = transformedStochasticSoilProfiles2[0]; @@ -266,8 +266,8 @@ "Kansen van voorkomen worden opgeteld."; TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Warn)); - List transformedStochasticSoilProfiles = transformed.StochasticSoilProfiles; - Assert.AreEqual(1, transformedStochasticSoilProfiles.Count); + PipingStochasticSoilProfile[] transformedStochasticSoilProfiles = transformed.StochasticSoilProfiles.ToArray(); + Assert.AreEqual(1, transformedStochasticSoilProfiles.Length); const double expectedProbability = originalProfileOneProbability + originalProfileTwoProbability; Assert.AreEqual(expectedProbability, transformedStochasticSoilProfiles[0].Probability, 1e-6); } @@ -359,17 +359,17 @@ PipingStochasticSoilModel transformed = transformer.Transform(soilModel); // Assert - List transformedStochasticSoilProfiles = transformed.StochasticSoilProfiles; - Assert.AreEqual(2, transformedStochasticSoilProfiles.Count); + PipingStochasticSoilProfile[] transformedStochasticSoilProfiles = transformed.StochasticSoilProfiles.ToArray(); + Assert.AreEqual(2, transformedStochasticSoilProfiles.Length); Assert.AreEqual(stochasticSoilProfile2D.Probability, transformedStochasticSoilProfiles[0].Probability, 1e-6); Assert.AreEqual(stochasticSoilProfile1D.Probability, transformedStochasticSoilProfiles[1].Probability, 1e-6); } - private static void AssertPipingStochasticSoilProfiles(IList expected, - IList actual) + private static void AssertPipingStochasticSoilProfiles(PipingStochasticSoilProfile[] expected, + PipingStochasticSoilProfile[] actual) { - Assert.AreEqual(expected.Count, actual.Count); - for (var i = 0; i < expected.Count; i++) + Assert.AreEqual(expected.Length, actual.Length); + for (var i = 0; i < expected.Length; i++) { AssertPipingStochasticSoilProfile(expected[i], actual[i]); } Index: Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/PipingCalculationsViewIntegrationTest.cs =================================================================== diff -u -r1f0cd3fafaa7340a446612870810629587474302 -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/PipingCalculationsViewIntegrationTest.cs (.../PipingCalculationsViewIntegrationTest.cs) (revision 1f0cd3fafaa7340a446612870810629587474302) +++ Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/PipingCalculationsViewIntegrationTest.cs (.../PipingCalculationsViewIntegrationTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -151,7 +151,7 @@ listBox.SelectedItem = assessmentSection.Piping.Sections.First(s => s.Name == "6-3_22"); pipingCalculation1.InputParameters.StochasticSoilModel = stochasticSoilModelCollection[0]; - pipingCalculation1.InputParameters.StochasticSoilProfile = stochasticSoilModelCollection[0].StochasticSoilProfiles[0]; + pipingCalculation1.InputParameters.StochasticSoilProfile = stochasticSoilModelCollection[0].StochasticSoilProfiles.First(); pipingCalculation1.InputParameters.NotifyObservers(); Assert.AreEqual("PK001_0001_Piping", dataGridView.Rows[0].Cells[stochasticSoilModelsColumnIndex].FormattedValue); Assert.AreEqual("W1-6_0_1D1", dataGridView.Rows[0].Cells[stochasticSoilProfilesColumnIndex].FormattedValue); @@ -160,7 +160,7 @@ listBox.SelectedItem = assessmentSection.Piping.Sections.First(s => s.Name == "6-3_19"); pipingCalculation2.InputParameters.SurfaceLine = assessmentSection.Piping.SurfaceLines.First(sl => sl.Name == "PK001_0002"); pipingCalculation2.InputParameters.StochasticSoilModel = stochasticSoilModelCollection[1]; - pipingCalculation2.InputParameters.StochasticSoilProfile = stochasticSoilModelCollection[1].StochasticSoilProfiles[0]; + pipingCalculation2.InputParameters.StochasticSoilProfile = stochasticSoilModelCollection[1].StochasticSoilProfiles.First(); pipingCalculation2.InputParameters.NotifyObservers(); Assert.AreEqual("PK001_0002_Piping", dataGridView.Rows[0].Cells[stochasticSoilModelsColumnIndex].FormattedValue); Assert.AreEqual("W1-6_4_1D1", dataGridView.Rows[0].Cells[stochasticSoilProfilesColumnIndex].FormattedValue); @@ -169,7 +169,7 @@ listBox.SelectedItem = assessmentSection.Piping.Sections.First(s => s.Name == "6-3_16"); pipingCalculation3.InputParameters.SurfaceLine = assessmentSection.Piping.SurfaceLines.First(sl => sl.Name == "PK001_0003"); pipingCalculation3.InputParameters.StochasticSoilModel = stochasticSoilModelCollection[2]; - pipingCalculation3.InputParameters.StochasticSoilProfile = stochasticSoilModelCollection[2].StochasticSoilProfiles[0]; + pipingCalculation3.InputParameters.StochasticSoilProfile = stochasticSoilModelCollection[2].StochasticSoilProfiles.First(); pipingCalculation3.InputParameters.NotifyObservers(); Assert.AreEqual("PK001_0003_Piping", dataGridView.Rows[0].Cells[stochasticSoilModelsColumnIndex].FormattedValue); Assert.AreEqual("W1-7_0_1D1", dataGridView.Rows[0].Cells[stochasticSoilProfilesColumnIndex].FormattedValue); @@ -178,7 +178,7 @@ listBox.SelectedItem = assessmentSection.Piping.Sections.First(s => s.Name == "6-3_8"); pipingCalculation4.InputParameters.SurfaceLine = assessmentSection.Piping.SurfaceLines.First(sl => sl.Name == "PK001_0004"); pipingCalculation4.InputParameters.StochasticSoilModel = stochasticSoilModelCollection[3]; - pipingCalculation4.InputParameters.StochasticSoilProfile = stochasticSoilModelCollection[3].StochasticSoilProfiles[0]; + pipingCalculation4.InputParameters.StochasticSoilProfile = stochasticSoilModelCollection[3].StochasticSoilProfiles.First(); pipingCalculation4.InputParameters.NotifyObservers(); Assert.AreEqual("PK001_0004_Piping", dataGridView.Rows[0].Cells[stochasticSoilModelsColumnIndex].FormattedValue); Assert.AreEqual("W1-8_6_1D1", dataGridView.Rows[0].Cells[stochasticSoilProfilesColumnIndex].FormattedValue); Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingStochasticSoilModelReplaceDataStrategyTest.cs =================================================================== diff -u -r42357a100d1a75baca233aa44b866a5009f48e00 -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingStochasticSoilModelReplaceDataStrategyTest.cs (.../PipingStochasticSoilModelReplaceDataStrategyTest.cs) (revision 42357a100d1a75baca233aa44b866a5009f48e00) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingStochasticSoilModelReplaceDataStrategyTest.cs (.../PipingStochasticSoilModelReplaceDataStrategyTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -176,7 +176,7 @@ InputParameters = { StochasticSoilModel = existingModel, - StochasticSoilProfile = existingModel.StochasticSoilProfiles[0] + StochasticSoilProfile = existingModel.StochasticSoilProfiles.First() }, Output = new PipingOutput(new PipingOutput.ConstructionProperties()) }; Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingStochasticSoilModelUpdateDataStrategyTest.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingStochasticSoilModelUpdateDataStrategyTest.cs (.../PipingStochasticSoilModelUpdateDataStrategyTest.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingStochasticSoilModelUpdateDataStrategyTest.cs (.../PipingStochasticSoilModelUpdateDataStrategyTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -247,7 +247,7 @@ // Assert Assert.AreEqual(1, targetCollection.Count); Assert.AreSame(existingModel, targetCollection[0]); - Assert.AreEqual(2, targetCollection[0].StochasticSoilProfiles.Count); + Assert.AreEqual(2, targetCollection[0].StochasticSoilProfiles.Count()); CollectionAssert.AreEquivalent(new IObservable[] { targetCollection, @@ -260,7 +260,7 @@ { // Setup const string modelsName = "same model"; - PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName); + PipingStochasticSoilModel existingModel = CreateSimpleModel(modelsName, "Unaffected Profile", "Removed Profile"); var failureMechanism = new PipingFailureMechanism(); PipingStochasticSoilModelCollection targetCollection = failureMechanism.StochasticSoilModels; @@ -269,17 +269,17 @@ existingModel }, sourceFilePath); - PipingStochasticSoilProfile firstExistingProfile = existingModel.StochasticSoilProfiles[0]; + PipingStochasticSoilProfile firstExistingProfile = existingModel.StochasticSoilProfiles.First(); PipingStochasticSoilModel readModel = CreateSimpleModel(modelsName, firstExistingProfile.SoilProfile.Name); var calculationWithNotUpdatedProfile = new PipingCalculationScenario(new GeneralPipingInput()); calculationWithNotUpdatedProfile.InputParameters.StochasticSoilModel = existingModel; - calculationWithNotUpdatedProfile.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles[0]; + calculationWithNotUpdatedProfile.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles.ElementAt(0); calculationWithNotUpdatedProfile.Output = new PipingOutput(new PipingOutput.ConstructionProperties()); var calculationWithDeletedProfile = new PipingCalculationScenario(new GeneralPipingInput()); calculationWithDeletedProfile.InputParameters.StochasticSoilModel = existingModel; - calculationWithDeletedProfile.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles[1]; + calculationWithDeletedProfile.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles.ElementAt(1); calculationWithDeletedProfile.Output = new PipingOutput(new PipingOutput.ConstructionProperties()); failureMechanism.CalculationsGroup.Children.Add(calculationWithDeletedProfile); @@ -296,8 +296,7 @@ // Assert PipingStochasticSoilModel firstSoilModel = targetCollection[0]; Assert.AreSame(existingModel, firstSoilModel); - Assert.AreEqual(1, firstSoilModel.StochasticSoilProfiles.Count); - Assert.AreSame(firstExistingProfile, firstSoilModel.StochasticSoilProfiles[0]); + Assert.AreSame(firstExistingProfile, firstSoilModel.StochasticSoilProfiles.ElementAt(0)); Assert.IsTrue(calculationWithNotUpdatedProfile.HasOutput); CollectionAssert.DoesNotContain(affectedObjects, calculationWithNotUpdatedProfile); @@ -314,7 +313,11 @@ { // Setup const string modelsName = "same model"; - PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName); + PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName, new[] + { + CreateStochasticSoilProfile("Updated Profile"), + CreateStochasticSoilProfile("Unaffected Profile") + }); var failureMechanism = new PipingFailureMechanism(); PipingStochasticSoilModelCollection targetCollection = failureMechanism.StochasticSoilModels; @@ -323,18 +326,21 @@ existingModel }, sourceFilePath); - PipingStochasticSoilModel readModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName); - PipingStochasticSoilProfile changedProfile = CloneAndSlightlyModify(readModel.StochasticSoilProfiles.ElementAt(0)); - readModel.StochasticSoilProfiles[0] = changedProfile; + PipingStochasticSoilProfile changedProfile = CloneAndSlightlyModify(existingModel.StochasticSoilProfiles.ElementAt(0)); + PipingStochasticSoilModel readModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName, new[] + { + changedProfile, + CreateStochasticSoilProfile("Unaffected Profile") + }); var calculationWithUpdatedProfile = new PipingCalculationScenario(new GeneralPipingInput()); calculationWithUpdatedProfile.InputParameters.StochasticSoilModel = existingModel; - calculationWithUpdatedProfile.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles[0]; + calculationWithUpdatedProfile.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles.ElementAt(0); calculationWithUpdatedProfile.Output = new PipingOutput(new PipingOutput.ConstructionProperties()); var calculationWithNotUpdatedProfile = new PipingCalculationScenario(new GeneralPipingInput()); calculationWithNotUpdatedProfile.InputParameters.StochasticSoilModel = existingModel; - calculationWithNotUpdatedProfile.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles[1]; + calculationWithNotUpdatedProfile.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles.ElementAt(1); calculationWithNotUpdatedProfile.Output = new PipingOutput(new PipingOutput.ConstructionProperties()); failureMechanism.CalculationsGroup.Children.Add(calculationWithNotUpdatedProfile); @@ -349,17 +355,22 @@ }, sourceFilePath).ToArray(); // Assert + Assert.AreEqual(1, targetCollection.Count); PipingStochasticSoilModel firstSoilModel = targetCollection[0]; Assert.AreSame(existingModel, firstSoilModel); - Assert.AreEqual(2, firstSoilModel.StochasticSoilProfiles.Count); - Assert.AreSame(existingModel.StochasticSoilProfiles[0], firstSoilModel.StochasticSoilProfiles[0]); - Assert.AreSame(existingModel.StochasticSoilProfiles[1], firstSoilModel.StochasticSoilProfiles[1]); + PipingStochasticSoilProfile[] stochasticSoilProfiles = firstSoilModel.StochasticSoilProfiles.ToArray(); + Assert.AreEqual(2, stochasticSoilProfiles.Length); + + PipingStochasticSoilProfile updatedStochasticSoilProfile = existingModel.StochasticSoilProfiles.ElementAt(0); + Assert.AreSame(updatedStochasticSoilProfile, stochasticSoilProfiles[0]); Assert.IsFalse(calculationWithUpdatedProfile.HasOutput); - Assert.AreSame(existingModel.StochasticSoilProfiles[0], calculationWithUpdatedProfile.InputParameters.StochasticSoilProfile); + Assert.AreSame(updatedStochasticSoilProfile, calculationWithUpdatedProfile.InputParameters.StochasticSoilProfile); + PipingStochasticSoilProfile unaffectedStochasticSoilProfile = existingModel.StochasticSoilProfiles.ElementAt(1); + Assert.AreSame(unaffectedStochasticSoilProfile, stochasticSoilProfiles[1]); Assert.IsTrue(calculationWithNotUpdatedProfile.HasOutput); - Assert.AreSame(existingModel.StochasticSoilProfiles[1], calculationWithNotUpdatedProfile.InputParameters.StochasticSoilProfile); + Assert.AreSame(unaffectedStochasticSoilProfile, calculationWithNotUpdatedProfile.InputParameters.StochasticSoilProfile); CollectionAssert.AreEquivalent(new IObservable[] { @@ -378,13 +389,13 @@ PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(); var calculation = new PipingCalculationScenario(new GeneralPipingInput()); calculation.InputParameters.StochasticSoilModel = existingModel; - calculation.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles[0]; + calculation.InputParameters.StochasticSoilProfile = existingModel.StochasticSoilProfiles.First(); calculation.Output = new PipingOutput(new PipingOutput.ConstructionProperties()); var failureMechanism = new PipingFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(calculation); - PipingStochasticSoilModelCollection PipingStochasticSoilModelCollection = failureMechanism.StochasticSoilModels; - PipingStochasticSoilModelCollection.AddRange(new[] + PipingStochasticSoilModelCollection pipingStochasticSoilModelCollection = failureMechanism.StochasticSoilModels; + pipingStochasticSoilModelCollection.AddRange(new[] { existingModel }, sourceFilePath); @@ -400,7 +411,7 @@ Assert.IsNull(calculation.InputParameters.StochasticSoilProfile); CollectionAssert.AreEquivalent(new IObservable[] { - PipingStochasticSoilModelCollection, + pipingStochasticSoilModelCollection, calculation, calculation.InputParameters }, affectedObjects); @@ -411,19 +422,25 @@ { // Setup const string modelsName = "same model"; - PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName); + PipingStochasticSoilModel existingModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName, new[] + { + CreateStochasticSoilProfile("Removed Profile"), + CreateStochasticSoilProfile("Unaffected Profile") + }); var failureMechanism = new PipingFailureMechanism(); PipingStochasticSoilModelCollection targetCollection = failureMechanism.StochasticSoilModels; targetCollection.AddRange(new[] { existingModel }, sourceFilePath); - PipingStochasticSoilProfile removedProfile = existingModel.StochasticSoilProfiles[0]; - PipingStochasticSoilProfile unaffectedProfile = existingModel.StochasticSoilProfiles[1]; + PipingStochasticSoilProfile removedProfile = existingModel.StochasticSoilProfiles.ElementAt(0); + PipingStochasticSoilProfile unaffectedProfile = existingModel.StochasticSoilProfiles.ElementAt(1); - PipingStochasticSoilModel readModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName); - readModel.StochasticSoilProfiles.RemoveAt(0); + PipingStochasticSoilModel readModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelsName, new[] + { + CreateStochasticSoilProfile("Unaffected Profile") + }); var calculationWithRemovedProfile = new PipingCalculationScenario(new GeneralPipingInput()); calculationWithRemovedProfile.InputParameters.StochasticSoilModel = existingModel; @@ -449,8 +466,8 @@ // Assert PipingStochasticSoilModel firstSoilModel = targetCollection[0]; Assert.AreSame(existingModel, firstSoilModel); - Assert.AreEqual(1, firstSoilModel.StochasticSoilProfiles.Count); - Assert.AreSame(unaffectedProfile, firstSoilModel.StochasticSoilProfiles[0]); + Assert.AreEqual(1, firstSoilModel.StochasticSoilProfiles.Count()); + Assert.AreSame(unaffectedProfile, firstSoilModel.StochasticSoilProfiles.First()); Assert.IsFalse(calculationWithRemovedProfile.HasOutput); Assert.IsNull(calculationWithRemovedProfile.InputParameters.StochasticSoilProfile); @@ -495,5 +512,11 @@ profile.SoilProfile.Layers, profile.SoilProfile.SoilProfileSourceType)); } + + private static PipingStochasticSoilProfile CreateStochasticSoilProfile(string profileName) + { + var random = new Random(21); + return new PipingStochasticSoilProfile(random.NextDouble(), PipingSoilProfileTestFactory.CreatePipingSoilProfile(profileName)); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLineUpdateDataStrategyTest.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLineUpdateDataStrategyTest.cs (.../PipingSurfaceLineUpdateDataStrategyTest.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLineUpdateDataStrategyTest.cs (.../PipingSurfaceLineUpdateDataStrategyTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -662,24 +662,18 @@ { new Point2D(2, -1), new Point2D(2, 1) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) - } - }, + new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }), new PipingStochasticSoilModel("C", new[] { new Point2D(-2, -1), new Point2D(-2, 1) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) - } - } + new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }) }; var failureMechanism = new PipingFailureMechanism(); @@ -728,35 +722,26 @@ { new Point2D(2, -1), new Point2D(2, 1) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) - } - }, + new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }), new PipingStochasticSoilModel("C", new[] { new Point2D(-2, -1), new Point2D(-2, 1) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) - } - }, + new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }), new PipingStochasticSoilModel("E", new[] { new Point2D(6, -1), new Point2D(6, 1) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) - } - } + new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }) }; PipingSurfaceLine surfaceLine = CreateValidSurfaceLineForCalculations(); @@ -813,13 +798,10 @@ { new Point2D(2, -1), new Point2D(2, 1) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) - } - }; + new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }); PipingSurfaceLine surfaceLine = CreateValidSurfaceLineForCalculations(); var calculation = new PipingCalculation(new GeneralPipingInput()) @@ -828,7 +810,7 @@ { SurfaceLine = surfaceLine, StochasticSoilModel = soilModel, - StochasticSoilProfile = soilModel.StochasticSoilProfiles[0] + StochasticSoilProfile = soilModel.StochasticSoilProfiles.First() } }; @@ -858,7 +840,7 @@ }, affectedObjects); Assert.IsNull(calculationInput.SurfaceLine); Assert.AreSame(soilModel, calculationInput.StochasticSoilModel); - Assert.AreSame(soilModel.StochasticSoilProfiles[0], calculationInput.StochasticSoilProfile); + Assert.AreSame(soilModel.StochasticSoilProfiles.First(), calculationInput.StochasticSoilProfile); } [Test] @@ -951,24 +933,18 @@ { new Point2D(2, -1), new Point2D(2, 1) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) - } - }, + new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }), new PipingStochasticSoilModel("C", new[] { new Point2D(-2, -1), new Point2D(-2, 1) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) - } - } + new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }) }; var failureMechanism = new PipingFailureMechanism(); Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -1302,14 +1302,11 @@ { new Point2D(0.0, 0.0), new Point2D(5.0, 0.0) - }) + }, new[] { - StochasticSoilProfiles = - { - new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("A")), - new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("B")) - } - } + new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("A")), + new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("B")) + }) }, pipingFailureMechanism, assessmentSection); Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingInputServiceTest.cs =================================================================== diff -u -r57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd --- Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingInputServiceTest.cs (.../PipingInputServiceTest.cs) (revision 57bc6a475f6cdd57b1a0ebf70cdf533014afd1ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingInputServiceTest.cs (.../PipingInputServiceTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) @@ -117,12 +117,12 @@ public void SyncStochasticSoilProfileWithStochasticSoilModel_MultipleStochasticSoilProfilesInStochasticSoilModel_DoesNotSetStochasticSoilProfile() { // Setup - PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(); - soilModel.StochasticSoilProfiles.AddRange(new[] + PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(new[] { new PipingStochasticSoilProfile(0.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()), new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) }); + var pipingInput = new PipingInput(new GeneralPipingInput()) { StochasticSoilModel = soilModel @@ -140,10 +140,11 @@ { // Setup var soilProfile = new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); + PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(new[] + { + soilProfile + }); - PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(); - soilModel.StochasticSoilProfiles.Add(soilProfile); - var pipingInput = new PipingInput(new GeneralPipingInput()) { StochasticSoilModel = soilModel,