Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityReadExtensionsTest.cs
===================================================================
diff -u -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd -r5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityReadExtensionsTest.cs (.../AssessmentSectionEntityReadExtensionsTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityReadExtensionsTest.cs (.../AssessmentSectionEntityReadExtensionsTest.cs) (revision 5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1)
@@ -25,6 +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 Core.Common.Base.Geometry;
using Core.Common.TestUtil;
@@ -286,12 +287,20 @@
new StochasticSoilModelEntity
{
Name = "modelA",
- StochasticSoilModelSegmentPointXml = segmentPointXml
+ StochasticSoilModelSegmentPointXml = segmentPointXml,
+ PipingStochasticSoilProfileEntities =
+ {
+ PipingStochasticSoilProfileEntityTestFactory.CreateStochasticSoilProfileEntity()
+ }
},
new StochasticSoilModelEntity
{
Name = "modelB",
- StochasticSoilModelSegmentPointXml = segmentPointXml
+ StochasticSoilModelSegmentPointXml = segmentPointXml,
+ PipingStochasticSoilProfileEntities =
+ {
+ PipingStochasticSoilProfileEntityTestFactory.CreateStochasticSoilProfileEntity()
+ }
}
},
PipingFailureMechanismMetaEntities =
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs
===================================================================
diff -u -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd -r5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs (.../FailureMechanismEntityReadExtensionsTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs (.../FailureMechanismEntityReadExtensionsTest.cs) (revision 5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1)
@@ -24,6 +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 Core.Common.Base;
using Core.Common.Base.Geometry;
@@ -367,12 +368,20 @@
new StochasticSoilModelEntity
{
StochasticSoilModelSegmentPointXml = segmentPointsXml,
+ PipingStochasticSoilProfileEntities =
+ {
+ PipingStochasticSoilProfileEntityTestFactory.CreateStochasticSoilProfileEntity()
+ },
Name = "A",
Order = 1
},
new StochasticSoilModelEntity
{
StochasticSoilModelSegmentPointXml = segmentPointsXml,
+ PipingStochasticSoilProfileEntities =
+ {
+ PipingStochasticSoilProfileEntityTestFactory.CreateStochasticSoilProfileEntity()
+ },
Name = "B",
Order = 0
}
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StochasticSoilModelEntityReadExtensionsTest.cs
===================================================================
diff -u -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd -r5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StochasticSoilModelEntityReadExtensionsTest.cs (.../StochasticSoilModelEntityReadExtensionsTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StochasticSoilModelEntityReadExtensionsTest.cs (.../StochasticSoilModelEntityReadExtensionsTest.cs) (revision 5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1)
@@ -24,6 +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 Core.Common.Base.Geometry;
using NUnit.Framework;
@@ -93,7 +94,11 @@
var entity = new StochasticSoilModelEntity
{
Name = "testName",
- StochasticSoilModelSegmentPointXml = new Point2DXmlSerializer().ToXml(geometry)
+ StochasticSoilModelSegmentPointXml = new Point2DXmlSerializer().ToXml(geometry),
+ PipingStochasticSoilProfileEntities =
+ {
+ PipingStochasticSoilProfileEntityTestFactory.CreateStochasticSoilProfileEntity()
+ }
};
var collector = new ReadConversionCollector();
@@ -103,8 +108,6 @@
// Assert
Assert.IsNotNull(model);
Assert.AreEqual(entity.Name, model.Name);
- CollectionAssert.AreEqual(geometry, model.Geometry);
- CollectionAssert.IsEmpty(model.StochasticSoilProfiles);
}
[Test]
@@ -175,7 +178,11 @@
var entity = new StochasticSoilModelEntity
{
Name = "StochasticSoilModel",
- StochasticSoilModelSegmentPointXml = new Point2DXmlSerializer().ToXml(segmentPoints)
+ StochasticSoilModelSegmentPointXml = new Point2DXmlSerializer().ToXml(segmentPoints),
+ PipingStochasticSoilProfileEntities =
+ {
+ PipingStochasticSoilProfileEntityTestFactory.CreateStochasticSoilProfileEntity()
+ }
};
var collector = new ReadConversionCollector();
@@ -198,7 +205,11 @@
var entity = new StochasticSoilModelEntity
{
Name = "StochasticSoilModel",
- StochasticSoilModelSegmentPointXml = new Point2DXmlSerializer().ToXml(geometry)
+ StochasticSoilModelSegmentPointXml = new Point2DXmlSerializer().ToXml(geometry),
+ PipingStochasticSoilProfileEntities =
+ {
+ PipingStochasticSoilProfileEntityTestFactory.CreateStochasticSoilProfileEntity()
+ }
};
var collector = new ReadConversionCollector();
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/Application.Ringtoets.Storage.TestUtil.Test.csproj
===================================================================
diff -u -raf575930a392dbf1fb1d5073f3df48110af72686 -r5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1
--- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/Application.Ringtoets.Storage.TestUtil.Test.csproj (.../Application.Ringtoets.Storage.TestUtil.Test.csproj) (revision af575930a392dbf1fb1d5073f3df48110af72686)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/Application.Ringtoets.Storage.TestUtil.Test.csproj (.../Application.Ringtoets.Storage.TestUtil.Test.csproj) (revision 5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1)
@@ -60,6 +60,7 @@
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/PipingStochasticSoilProfileEntityTestFactoryTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/PipingStochasticSoilProfileEntityTestFactoryTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/PipingStochasticSoilProfileEntityTestFactoryTest.cs (revision 5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1)
@@ -0,0 +1,48 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using Application.Ringtoets.Storage.DbContext;
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Storage.TestUtil.Test
+{
+ [TestFixture]
+ public class PipingStochasticSoilProfileEntityTestFactoryTest
+ {
+ [Test]
+ public void CreateStochasticSoilProfileEntity_Always_ReturnsEntityWithExpectedProperties()
+ {
+ // Call
+ PipingStochasticSoilProfileEntity entity = PipingStochasticSoilProfileEntityTestFactory.CreateStochasticSoilProfileEntity();
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreEqual(typeof(PipingStochasticSoilProfileEntity), entity.GetType());
+
+ Assert.AreEqual(0.34, entity.Probability);
+
+ PipingSoilProfileEntity soilProfileEntity = entity.PipingSoilProfileEntity;
+ Assert.IsNotNull(soilProfileEntity);
+ Assert.AreEqual("Profile Name", soilProfileEntity.Name);
+ CollectionAssert.IsNotEmpty(soilProfileEntity.PipingSoilLayerEntities);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/Application.Ringtoets.Storage.TestUtil.csproj
===================================================================
diff -u -raf575930a392dbf1fb1d5073f3df48110af72686 -r5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1
--- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/Application.Ringtoets.Storage.TestUtil.csproj (.../Application.Ringtoets.Storage.TestUtil.csproj) (revision af575930a392dbf1fb1d5073f3df48110af72686)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/Application.Ringtoets.Storage.TestUtil.csproj (.../Application.Ringtoets.Storage.TestUtil.csproj) (revision 5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1)
@@ -57,6 +57,7 @@
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/PipingStochasticSoilProfileEntityTestFactory.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/PipingStochasticSoilProfileEntityTestFactory.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/PipingStochasticSoilProfileEntityTestFactory.cs (revision 5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1)
@@ -0,0 +1,52 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using Application.Ringtoets.Storage.DbContext;
+
+namespace Application.Ringtoets.Storage.TestUtil
+{
+ ///
+ /// Factory for creating a that can
+ /// be used for testing.
+ ///
+ public static class PipingStochasticSoilProfileEntityTestFactory
+ {
+ ///
+ /// Creates a valid .
+ ///
+ /// A valid .
+ public static PipingStochasticSoilProfileEntity CreateStochasticSoilProfileEntity()
+ {
+ return new PipingStochasticSoilProfileEntity
+ {
+ Probability = 0.34,
+ PipingSoilProfileEntity = new PipingSoilProfileEntity
+ {
+ Name = "Profile Name",
+ PipingSoilLayerEntities =
+ {
+ new PipingSoilLayerEntity()
+ }
+ }
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModel.cs
===================================================================
diff -u -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd -r5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModel.cs (.../PipingStochasticSoilModel.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/SoilProfile/PipingStochasticSoilModel.cs (.../PipingStochasticSoilModel.cs) (revision 5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1)
@@ -45,8 +45,7 @@
/// 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 any parameter is null.
/// Thrown when
/// or is empty.
public PipingStochasticSoilModel(string name, IEnumerable geometry, IEnumerable stochasticSoilProfiles)
@@ -68,6 +67,11 @@
string message = string.Format(RingtoetsCommonDataResources.StochasticSoilModel_Geometry_of_StochasticSoilModelName_0_must_contain_a_geometry, name);
throw new ArgumentException(message);
}
+ if (!stochasticSoilProfiles.Any())
+ {
+ string message = string.Format(RingtoetsCommonDataResources.StochasticSoilModel_No_stochasticSoilProfiles_found_for_StochasticSoilModelName_0, name);
+ throw new ArgumentException(message);
+ }
Name = name;
Geometry = geometry;
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilModelTest.cs
===================================================================
diff -u -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd -r5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilModelTest.cs (.../PipingStochasticSoilModelTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/SoilProfile/PipingStochasticSoilModelTest.cs (.../PipingStochasticSoilModelTest.cs) (revision 5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1)
@@ -131,6 +131,27 @@
}
[Test]
+ public void Constructor_StochasticSoilProfilesEmpty_ThrowsArgumentException()
+ {
+ // Setup
+ var random = new Random(21);
+ const string name = "name";
+ var geometry = new[]
+ {
+ new Point2D(random.NextDouble(), random.NextDouble())
+ };
+
+ // Call
+ TestDelegate call = () => new PipingStochasticSoilModel(name,
+ geometry,
+ Enumerable.Empty());
+
+ // Assert
+ string expectedMessage = $"Er zijn geen ondergrondschematisaties gevonden in het stochastische ondergrondmodel '{name}'.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+ }
+
+ [Test]
public void Update_WithNullModel_ThrowsArgumentNullException()
{
// Setup
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PipingCalculationConfigurationHelperTest.cs
===================================================================
diff -u -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd -r5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PipingCalculationConfigurationHelperTest.cs (.../PipingCalculationConfigurationHelperTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PipingCalculationConfigurationHelperTest.cs (.../PipingCalculationConfigurationHelperTest.cs) (revision 5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1)
@@ -171,38 +171,6 @@
}
[Test]
- public void GetStochasticSoilModelsForSurfaceLine_NoSoilProfiles_ReturnEmpty()
- {
- // Setup
- var soilModel = new PipingStochasticSoilModel("A", new[]
- {
- new Point2D(1.0, 0.0),
- new Point2D(5.0, 0.0)
- }, Enumerable.Empty());
-
- var availableSoilModels = new[]
- {
- soilModel
- };
-
- var surfaceLine = new PipingSurfaceLine("surface line");
- surfaceLine.SetGeometry(new[]
- {
- new Point3D(3.0, 5.0, 0.0),
- new Point3D(3.0, 0.0, 1.0),
- new Point3D(3.0, -5.0, 0.0)
- });
-
- // Call
- IEnumerable result = PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine(
- surfaceLine,
- availableSoilModels);
-
- // Assert
- CollectionAssert.IsEmpty(result);
- }
-
- [Test]
public void GetStochasticSoilModelsForSurfaceLine_SoilModelGeometryNotIntersecting_ReturnEmpty()
{
// Setup
@@ -481,54 +449,6 @@
}
[Test]
- public void GenerateCalculationItemsStructure_NoSoilProfiles_LogWarning()
- {
- // Setup
- var soilModel = new PipingStochasticSoilModel("A", new[]
- {
- new Point2D(1.0, 0.0),
- new Point2D(5.0, 0.0)
- }, Enumerable.Empty());
-
- var availableSoilModels = new[]
- {
- soilModel
- };
-
- const string testName = "testName";
- var surfaceLine = new PipingSurfaceLine(testName);
- surfaceLine.SetGeometry(new[]
- {
- new Point3D(3.0, 5.0, 0.0),
- new Point3D(3.0, 0.0, 1.0),
- new Point3D(3.0, -5.0, 0.0)
- });
-
- PipingSurfaceLine[] surfaceLines =
- {
- surfaceLine
- };
-
- IEnumerable result = null;
- // Call
- Action call = () =>
- {
- result = PipingCalculationConfigurationHelper.GenerateCalculationItemsStructure(
- surfaceLines,
- availableSoilModels,
- new GeneralPipingInput()).ToArray();
- };
-
- // Assert
- Tuple expectedMessage = Tuple.Create(
- string.Format("Geen ondergrondschematisaties gevonden voor profielschematisatie '{0}'. De profielschematisatie is overgeslagen.",
- testName),
- LogLevelConstant.Warn);
- TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedMessage);
- CollectionAssert.IsEmpty(result);
- }
-
- [Test]
public void GenerateCalculationItemsStructure_SoilModelGeometryNotIntersecting_LogWarning()
{
// Setup
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs
===================================================================
diff -u -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd -r5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs (.../PipingStochasticSoilModelTransformerTest.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs (.../PipingStochasticSoilModelTransformerTest.cs) (revision 5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1)
@@ -142,6 +142,28 @@
}
[Test]
+ public void Transform_StochasticSoilModelWithoutStochasticSoilProfiles_ThrowsImportedDataException()
+ {
+ // Setup
+ StochasticSoilModel stochasticSoilModel = StochasticSoilModelTestFactory.CreateStochasticSoilModelWithGeometry("name",
+ FailureMechanismType.Piping,
+ Enumerable.Empty());
+
+ var transformer = new PipingStochasticSoilModelTransformer();
+
+ // Call
+ TestDelegate test = () => transformer.Transform(stochasticSoilModel);
+
+ // Assert
+ var exception = Assert.Throws(test);
+
+ Exception innerException = exception.InnerException;
+ Assert.IsNotNull(innerException);
+ Assert.IsInstanceOf(innerException);
+ Assert.AreEqual(innerException.Message, exception.Message);
+ }
+
+ [Test]
public void Transform_ValidStochasticSoilModelWithSoilProfile2D_ReturnsExpectedPipingStochasticSoilModel()
{
// Setup