Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/GenericSoilLayerParameters.cs
===================================================================
diff -u -r223528aec31c0f78f0f8ff67991e43f781075931 -r6e00eba7f45883916d98df04a84f6d0dca2f61fc
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/GenericSoilLayerParameters.cs (.../GenericSoilLayerParameters.cs) (revision 223528aec31c0f78f0f8ff67991e43f781075931)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/GenericSoilLayerParameters.cs (.../GenericSoilLayerParameters.cs) (revision 6e00eba7f45883916d98df04a84f6d0dca2f61fc)
@@ -28,93 +28,99 @@
///
/// Gets or sets the name of the material that was assigned to the .
///
- public string MaterialName { get; set; }
+ internal string MaterialName { get; set; }
///
/// Gets or sets the value representing a color that was used to represent the .
///
- public double? Color { get; set; }
+ internal double? Color { get; set; }
///
/// Gets or sets the distribution for the volumic weight of the below the
/// phreatic level.
/// [kN/m³]
///
- public long? BelowPhreaticLevelDistribution { get; set; }
+ internal long? BelowPhreaticLevelDistribution { get; set; }
///
/// Gets or sets the shift of the distribution for the volumic weight of the
/// below the phreatic level.
/// [kN/m³]
///
- public double? BelowPhreaticLevelShift { get; set; }
+ internal double? BelowPhreaticLevelShift { get; set; }
///
/// Gets or sets the mean of the distribution for the volumic weight of the
/// below the phreatic level.
/// [kN/m³]
///
- public double? BelowPhreaticLevelMean { get; set; }
+ internal double? BelowPhreaticLevelMean { get; set; }
///
/// Gets or sets the deviation of the distribution for the volumic weight of the below the phreatic level.
/// [kN/m³]
///
- public double? BelowPhreaticLevelDeviation { get; set; }
+ internal double? BelowPhreaticLevelDeviation { get; set; }
///
/// Gets or sets the distribution for the mean diameter of small scale tests applied to different kinds of sand, on which the
/// formula of Sellmeijer has been fit.
/// [m]
///
- public long? DiameterD70Distribution { get; set; }
+ internal long? DiameterD70Distribution { get; set; }
///
/// Gets or sets the shift of the distribution for the mean diameter of small scale tests applied to different kinds of sand,
/// on which the formula of Sellmeijer has been fit.
/// [m]
///
- public double? DiameterD70Shift { get; set; }
+ internal double? DiameterD70Shift { get; set; }
///
/// Gets or sets the mean of the distribution for the mean diameter of small scale tests applied to different kinds of sand,
/// on which the formula of Sellmeijer has been fit.
/// [m]
///
- public double? DiameterD70Mean { get; set; }
+ internal double? DiameterD70Mean { get; set; }
///
/// Gets or sets the deviation of the distribution for the mean diameter of small scale tests applied to different kinds of sand,
/// on which the formula of Sellmeijer has been fit.
/// [m]
///
- public double? DiameterD70Deviation { get; set; }
+ internal double? DiameterD70Deviation { get; set; }
///
/// Gets or sets the distribution for the Darcy-speed with which water flows through the aquifer layer.
/// [m/s]
///
- public long? PermeabilityDistribution { get; set; }
+ internal long? PermeabilityDistribution { get; set; }
///
/// Gets or sets the shift of the distribution for the Darcy-speed with which water flows through the aquifer layer.
/// [m/s]
///
- public double? PermeabilityShift { get; set; }
+ internal double? PermeabilityShift { get; set; }
///
/// Gets or sets the mean of the distribution for the the Darcy-speed with which water flows through the aquifer layer.
/// [m/s]
///
- public double? PermeabilityMean { get; set; }
+ internal double? PermeabilityMean { get; set; }
///
/// Gets or sets the deviation of the distribution for the Darcy-speed with which water flows through the aquifer layer.
/// [m/s]
///
- public double? PermeabilityDeviation { get; set; }
+ internal double? PermeabilityDeviation { get; set; }
- protected void SetOptionalFields(PipingSoilLayer pipingSoilLayer)
+ ///
+ /// Sets the values of the optional stochastic parameters for the given .
+ ///
+ /// The to set the property values for.
+ /// This method does not perform validation. Use to
+ /// verify whether the distributions for the stochastic parameters are correctly defined.
+ protected void SetOptionalStochasticParameters(PipingSoilLayer pipingSoilLayer)
{
if (BelowPhreaticLevelMean.HasValue)
{
@@ -142,7 +148,13 @@
}
}
- protected void ValidateFieldsForPiping()
+ ///
+ /// Validates whether the values of the distribution and shift for the stochastic parameters
+ /// are correct for creating a .
+ ///
+ /// Thrown when any of the distributions of the
+ /// stochastic parameters is not defined as lognormal.
+ protected void ValidateStochasticParametersForPiping()
{
ValidateIsLogNormal(
BelowPhreaticLevelDistribution,
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer1D.cs
===================================================================
diff -u -rcb6877f670bacc7a6a896ab132d592eeef1107b5 -r6e00eba7f45883916d98df04a84f6d0dca2f61fc
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer1D.cs (.../SoilLayer1D.cs) (revision cb6877f670bacc7a6a896ab132d592eeef1107b5)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer1D.cs (.../SoilLayer1D.cs) (revision 6e00eba7f45883916d98df04a84f6d0dca2f61fc)
@@ -51,9 +51,11 @@
/// Constructs a (1D) based on the properties set for the .
///
/// The with properties corresponding to those set on the .
+ /// Thrown when any of the distributions of the
+ /// stochastic parameters is not defined as lognormal.
internal PipingSoilLayer AsPipingSoilLayer()
{
- ValidateFieldsForPiping();
+ ValidateStochasticParametersForPiping();
var pipingSoilLayer = new PipingSoilLayer(Top)
{
@@ -62,7 +64,7 @@
Color = SoilLayerColorConversionHelper.ColorFromNullableDouble(Color)
};
- SetOptionalFields(pipingSoilLayer);
+ SetOptionalStochasticParameters(pipingSoilLayer);
return pipingSoilLayer;
}
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer2D.cs
===================================================================
diff -u -rcb6877f670bacc7a6a896ab132d592eeef1107b5 -r6e00eba7f45883916d98df04a84f6d0dca2f61fc
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer2D.cs (.../SoilLayer2D.cs) (revision cb6877f670bacc7a6a896ab132d592eeef1107b5)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer2D.cs (.../SoilLayer2D.cs) (revision 6e00eba7f45883916d98df04a84f6d0dca2f61fc)
@@ -100,16 +100,22 @@
}
///
- /// Constructs a (1D) based on the and set for the .
+ /// Constructs a (1D) based on the and
+ /// set for the .
///
/// The point from which to take a 1D profile.
/// The bottom level of the .
/// A of .
- /// Thrown when any of the or
- /// contain a vertical line at .
+ /// Thrown when either:
+ ///
+ /// - any of the or contain a vertical
+ /// line at
+ /// - any of the distributions of the stochastic parameters is not defined as lognormal
+ ///
+ ///
internal IEnumerable AsPipingSoilLayers(double atX, out double bottom)
{
- ValidateFieldsForPiping();
+ ValidateStochasticParametersForPiping();
bottom = Double.MaxValue;
var result = new Collection();
@@ -137,7 +143,7 @@
Color = SoilLayerColorConversionHelper.ColorFromNullableDouble(Color)
};
- SetOptionalFields(pipingSoilLayer);
+ SetOptionalStochasticParameters(pipingSoilLayer);
result.Add(pipingSoilLayer);
}
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder2D.cs
===================================================================
diff -u -rcb6877f670bacc7a6a896ab132d592eeef1107b5 -r6e00eba7f45883916d98df04a84f6d0dca2f61fc
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder2D.cs (.../SoilProfileBuilder2D.cs) (revision cb6877f670bacc7a6a896ab132d592eeef1107b5)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder2D.cs (.../SoilProfileBuilder2D.cs) (revision 6e00eba7f45883916d98df04a84f6d0dca2f61fc)
@@ -85,9 +85,13 @@
///
/// The to add to the profile.
/// The .
- /// Thrown when the 's geometry
- /// contains vertical segments at the X-coordinate given for the construction of the
- /// .
+ /// Thrown when either:
+ ///
+ /// - the 's geometry contains vertical segments at the
+ /// X-coordinate given for the construction of the .
+ /// - any of the distributions of the stochastic parameters for is not defined
+ /// as lognormal
+ ///
internal SoilProfileBuilder2D Add(SoilLayer2D soilLayer)
{
double newBottom;
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs
===================================================================
diff -u -r223528aec31c0f78f0f8ff67991e43f781075931 -r6e00eba7f45883916d98df04a84f6d0dca2f61fc
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs (.../SoilProfile2DReader.cs) (revision 223528aec31c0f78f0f8ff67991e43f781075931)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs (.../SoilProfile2DReader.cs) (revision 6e00eba7f45883916d98df04a84f6d0dca2f61fc)
@@ -47,7 +47,8 @@
/// - a layer's geometry could not be parsed as XML;
/// - the parsed geometry did not contain loops;
/// - after reading the layers, no layers were added to be build;
- /// - unexpected values were encountered for layer properties
+ /// - unexpected values were encountered for layer properties;
+ /// - stochastic layer properties were not defined with a lognormal distribution
///
///
internal static PipingSoilProfile ReadFrom(IRowBasedDatabaseReader reader)
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/GenericSoilLayerParametersTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/GenericSoilLayerParametersTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/GenericSoilLayerParametersTest.cs (revision 6e00eba7f45883916d98df04a84f6d0dca2f61fc)
@@ -0,0 +1,55 @@
+// Copyright (C) Stichting Deltares 2016. 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 NUnit.Framework;
+using Ringtoets.Piping.IO.Builders;
+
+namespace Ringtoets.Piping.IO.Test.Builders
+{
+ [TestFixture]
+ public class GenericSoilLayerParametersTest
+ {
+ [Test]
+ public void DefaultConstructor_SetsDefaultProperties()
+ {
+ // Call
+ var parameters = new TestGenericSoilLayerParameters();
+
+ // Assert
+ Assert.IsNull(parameters.Color);
+ Assert.IsNull(parameters.MaterialName);
+ Assert.IsNull(parameters.BelowPhreaticLevelDeviation);
+ Assert.IsNull(parameters.BelowPhreaticLevelDistribution);
+ Assert.IsNull(parameters.BelowPhreaticLevelMean);
+ Assert.IsNull(parameters.BelowPhreaticLevelShift);
+ Assert.IsNull(parameters.DiameterD70Deviation);
+ Assert.IsNull(parameters.DiameterD70Distribution);
+ Assert.IsNull(parameters.DiameterD70Mean);
+ Assert.IsNull(parameters.DiameterD70Shift);
+ Assert.IsNull(parameters.PermeabilityDeviation);
+ Assert.IsNull(parameters.PermeabilityMean);
+ Assert.IsNull(parameters.PermeabilityDistribution);
+ Assert.IsNull(parameters.PermeabilityShift);
+ }
+
+ private class TestGenericSoilLayerParameters : GenericSoilLayerParameters {}
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayer1DTest.cs
===================================================================
diff -u -r223528aec31c0f78f0f8ff67991e43f781075931 -r6e00eba7f45883916d98df04a84f6d0dca2f61fc
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayer1DTest.cs (.../SoilLayer1DTest.cs) (revision 223528aec31c0f78f0f8ff67991e43f781075931)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayer1DTest.cs (.../SoilLayer1DTest.cs) (revision 6e00eba7f45883916d98df04a84f6d0dca2f61fc)
@@ -23,6 +23,7 @@
using System.Drawing;
using NUnit.Framework;
using Ringtoets.Piping.IO.Builders;
+using Ringtoets.Piping.IO.Properties;
namespace Ringtoets.Piping.IO.Test.Builders
{
@@ -65,7 +66,7 @@
[TestCase(1.0)]
[TestCase(1.0+1e-12)]
[TestCase(2.0)]
- public void AsPipingSoilLayer_PropertiesSetWithDifferentLayerParameters_PropertiesAreSetInPipingSoilLayer(double isAquifer)
+ public void AsPipingSoilLayer_PropertiesSetWithCorrectDistributionsAndDifferentLayerParameters_PropertiesAreSetInPipingSoilLayer(double isAquifer)
{
// Setup
var random = new Random(22);
@@ -127,6 +128,66 @@
}
[Test]
+ [TestCase(false, true, true, "Verzadigd gewicht")]
+ [TestCase(true, false, true, "Korrelgrootte")]
+ [TestCase(true, true, false, "Doorlatendheid")]
+ public void AsPipingSoilLayer_IncorrectDistributionType_ThrowsSoilLayerConversionException(
+ bool isBelowPhreaticLevelDistributionValid,
+ bool isDiameterD70DistributionValid,
+ bool isPermeabilityDistributionValid,
+ string expectedParameter)
+ {
+ // Setup
+ var validShift = 0.0;
+ var layer = new SoilLayer1D(0.0)
+ {
+ BelowPhreaticLevelDistribution = isBelowPhreaticLevelDistributionValid ? SoilLayerConstants.LogNormalDistributionValue : -1,
+ BelowPhreaticLevelShift = validShift,
+ DiameterD70Distribution = isDiameterD70DistributionValid ? SoilLayerConstants.LogNormalDistributionValue : -1,
+ DiameterD70Shift = validShift,
+ PermeabilityDistribution = isPermeabilityDistributionValid ? SoilLayerConstants.LogNormalDistributionValue : -1,
+ PermeabilityShift = validShift
+ };
+
+ // Call
+ TestDelegate test = () => layer.AsPipingSoilLayer();
+
+ // Assert
+ var message = Assert.Throws(test).Message;
+ Assert.AreEqual(string.Format("De parameter '{0}' is niet lognormaal verdeeld.", expectedParameter), message);
+ }
+
+ [Test]
+ [TestCase(1e-6,0.0,0.0,"Verzadigd gewicht")]
+ [TestCase(0.0,-1e-6,0.0,"Korrelgrootte")]
+ [TestCase(0.0,0.0,9,"Doorlatendheid")]
+ public void AsPipingSoilLayer_ShiftNotZero_ThrowsSoilLayerConversionException(
+ double belowPhreaticLevelShift,
+ double diameterD70Shift,
+ double permeabilityShift,
+ string expectedParameter)
+ {
+ // Setup
+ var validDistribution = SoilLayerConstants.LogNormalDistributionValue;
+ var layer = new SoilLayer1D(1.0)
+ {
+ BelowPhreaticLevelDistribution = validDistribution,
+ BelowPhreaticLevelShift = belowPhreaticLevelShift,
+ DiameterD70Distribution = validDistribution,
+ DiameterD70Shift = diameterD70Shift,
+ PermeabilityDistribution = validDistribution,
+ PermeabilityShift = permeabilityShift
+ };
+
+ // Call
+ TestDelegate test = () => layer.AsPipingSoilLayer();
+
+ // Assert
+ var message = Assert.Throws(test).Message;
+ Assert.AreEqual(string.Format("De parameter '{0}' is niet lognormaal verdeeld.", expectedParameter), message);
+ }
+
+ [Test]
public void AsPipingSoilLayer_PropertiesSetWithNullMaterialName_MaterialNameEmptyInPipingSoilLayer()
{
// Setup
Fisheye: Tag 6e00eba7f45883916d98df04a84f6d0dca2f61fc refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayer2DConversionExceptionTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayer2DTest.cs
===================================================================
diff -u -r223528aec31c0f78f0f8ff67991e43f781075931 -r6e00eba7f45883916d98df04a84f6d0dca2f61fc
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayer2DTest.cs (.../SoilLayer2DTest.cs) (revision 223528aec31c0f78f0f8ff67991e43f781075931)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayer2DTest.cs (.../SoilLayer2DTest.cs) (revision 6e00eba7f45883916d98df04a84f6d0dca2f61fc)
@@ -862,5 +862,69 @@
var exception = Assert.Throws(test);
Assert.AreEqual(String.Format(Resources.Error_Can_not_determine_1D_profile_with_vertical_segments_at_X_0_, atX), exception.Message);
}
+
+ [Test]
+ [TestCase(false, true, true, "Verzadigd gewicht")]
+ [TestCase(true, false, true, "Korrelgrootte")]
+ [TestCase(true, true, false, "Doorlatendheid")]
+ public void AsPipingSoilLayer_IncorrectDistributionType_ThrowsSoilLayerConversionException(
+ bool isBelowPhreaticLevelDistributionValid,
+ bool isDiameterD70DistributionValid,
+ bool isPermeabilityDistributionValid,
+ string expectedParameter)
+ {
+ // Setup
+ var validShift = 0.0;
+ var layer = new SoilLayer2D
+ {
+ BelowPhreaticLevelDistribution = isBelowPhreaticLevelDistributionValid ? SoilLayerConstants.LogNormalDistributionValue : -1,
+ BelowPhreaticLevelShift = validShift,
+ DiameterD70Distribution = isDiameterD70DistributionValid ? SoilLayerConstants.LogNormalDistributionValue : -1,
+ DiameterD70Shift = validShift,
+ PermeabilityDistribution = isPermeabilityDistributionValid ? SoilLayerConstants.LogNormalDistributionValue : -1,
+ PermeabilityShift = validShift
+ };
+
+ double bottom;
+
+ // Call
+ TestDelegate test = () => layer.AsPipingSoilLayers(0, out bottom);
+
+ // Assert
+ var message = Assert.Throws(test).Message;
+ Assert.AreEqual(string.Format("De parameter '{0}' is niet lognormaal verdeeld.", expectedParameter), message);
+ }
+
+ [Test]
+ [TestCase(1e-6, 0.0, 0.0, "Verzadigd gewicht")]
+ [TestCase(0.0, -1e-6, 0.0, "Korrelgrootte")]
+ [TestCase(0.0, 0.0, 9, "Doorlatendheid")]
+ public void AsPipingSoilLayer_ShiftNotZero_ThrowsSoilLayerConversionException(
+ double belowPhreaticLevelShift,
+ double diameterD70Shift,
+ double permeabilityShift,
+ string expectedParameter)
+ {
+ // Setup
+ var validDistribution = SoilLayerConstants.LogNormalDistributionValue;
+ var layer = new SoilLayer2D
+ {
+ BelowPhreaticLevelDistribution = validDistribution,
+ BelowPhreaticLevelShift = belowPhreaticLevelShift,
+ DiameterD70Distribution = validDistribution,
+ DiameterD70Shift = diameterD70Shift,
+ PermeabilityDistribution = validDistribution,
+ PermeabilityShift = permeabilityShift
+ };
+
+ double bottom;
+
+ // Call
+ TestDelegate test = () => layer.AsPipingSoilLayers(0, out bottom);
+
+ // Assert
+ var message = Assert.Throws(test).Message;
+ Assert.AreEqual(string.Format("De parameter '{0}' is niet lognormaal verdeeld.", expectedParameter), message);
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayerConversionExceptionTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayerConversionExceptionTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayerConversionExceptionTest.cs (revision 6e00eba7f45883916d98df04a84f6d0dca2f61fc)
@@ -0,0 +1,74 @@
+// Copyright (C) Stichting Deltares 2016. 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 System;
+using NUnit.Framework;
+using Ringtoets.Piping.IO.Builders;
+
+namespace Ringtoets.Piping.IO.Test.Builders
+{
+ [TestFixture]
+ public class SoilLayerConversionExceptionTest
+ {
+ [Test]
+ public void DefaultConstructor_InnerExceptionNullAndMessageDefault()
+ {
+ // Setup
+ var expectedMessage = String.Format("Exception of type '{0}' was thrown.", typeof(SoilLayerConversionException).FullName);
+
+ // Call
+ var exception = new SoilLayerConversionException();
+
+ // Assert
+ Assert.IsNull(exception.InnerException);
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+
+ [Test]
+ public void Constructor_WithCustomMessage_InnerExceptionNullAndMessageSetToCustom()
+ {
+ // Setup
+ var expectedMessage = "Some exception message";
+
+ // Call
+ var exception = new SoilLayerConversionException(expectedMessage);
+
+ // Assert
+ Assert.IsNull(exception.InnerException);
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+
+ [Test]
+ public void Constructor_WithCustomMessageAndInnerException_InnerExceptionSetAndMessageSetToCustom()
+ {
+ // Setup
+ var expectedMessage = "Some exception message";
+ var expectedInnerException = new Exception();
+
+ // Call
+ var exception = new SoilLayerConversionException(expectedMessage, expectedInnerException);
+
+ // Assert
+ Assert.AreSame(expectedInnerException, exception.InnerException);
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj
===================================================================
diff -u -r49f905d3363336d44ef828259692644dcf5f9edc -r6e00eba7f45883916d98df04a84f6d0dca2f61fc
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 49f905d3363336d44ef828259692644dcf5f9edc)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 6e00eba7f45883916d98df04a84f6d0dca2f61fc)
@@ -61,8 +61,9 @@
+
-
+
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/PipingSoilProfileReaderTest.cs
===================================================================
diff -u -r223528aec31c0f78f0f8ff67991e43f781075931 -r6e00eba7f45883916d98df04a84f6d0dca2f61fc
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/PipingSoilProfileReaderTest.cs (.../PipingSoilProfileReaderTest.cs) (revision 223528aec31c0f78f0f8ff67991e43f781075931)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/PipingSoilProfileReaderTest.cs (.../PipingSoilProfileReaderTest.cs) (revision 6e00eba7f45883916d98df04a84f6d0dca2f61fc)
@@ -376,6 +376,26 @@
}
[Test]
+ public void ReadProfile_DatabaseProfileWithLayerWithIncorrectDistributionForStochastProperty_ReturnsNoProfile()
+ {
+ // Setup
+ var testFile = "incorrect2dStochastDistributionProperty.soil";
+ string databaseFilePath = Path.Combine(testDataPath, testFile);
+ using (var pipingSoilProfilesReader = new PipingSoilProfileReader(databaseFilePath))
+ {
+ // Call
+ TestDelegate profile = () => pipingSoilProfilesReader.ReadProfile();
+
+ // Assert
+ var exceptionMessage = Assert.Throws(profile).Message;
+ var message = new FileReaderErrorMessageBuilder(databaseFilePath)
+ .WithSubject("ondergrondschematisatie 'Profile'")
+ .Build(string.Format(Resources.SoilLayer_Stochastic_parameter_0_has_no_lognormal_distribution, Resources.SoilLayer_BelowPhreaticLevelDistribution_Description));
+ Assert.AreEqual(message, exceptionMessage);
+ }
+ }
+
+ [Test]
public void ReadProfile_DatabaseWith1DProfile3Layers_ReturnsProfile()
{
// Setup
@@ -405,6 +425,36 @@
0.71,
0.21
}, profile.Layers.Select(l => l.BelowPhreaticLevelMean));
+ CollectionAssert.AreEqual(new[]
+ {
+ 0.08,
+ 0.02,
+ 0.001
+ }, profile.Layers.Select(l => l.BelowPhreaticLevelDeviation));
+ CollectionAssert.AreEqual(new[]
+ {
+ 11.3,
+ 0.01,
+ 0.51
+ }, profile.Layers.Select(l => l.DiameterD70Mean));
+ CollectionAssert.AreEqual(new[]
+ {
+ 0.2,
+ 0.001,
+ 0.015
+ }, profile.Layers.Select(l => l.DiameterD70Deviation));
+ CollectionAssert.AreEqual(new[]
+ {
+ 5.21,
+ 9.99,
+ 1.01
+ }, profile.Layers.Select(l => l.PermeabilityMean));
+ CollectionAssert.AreEqual(new[]
+ {
+ 0.3,
+ 0.1,
+ 0.025
+ }, profile.Layers.Select(l => l.PermeabilityDeviation));
}
}
@@ -438,6 +488,36 @@
0.71,
3.88
}, profile.Layers.Select(l => l.BelowPhreaticLevelMean));
+ CollectionAssert.AreEqual(new[]
+ {
+ 0.001,
+ 0.02,
+ 0.08
+ }, profile.Layers.Select(l => l.BelowPhreaticLevelDeviation));
+ CollectionAssert.AreEqual(new[]
+ {
+ 0.51,
+ 0.01,
+ 11.3
+ }, profile.Layers.Select(l => l.DiameterD70Mean));
+ CollectionAssert.AreEqual(new[]
+ {
+ 0.015,
+ 0.001,
+ 0.2
+ }, profile.Layers.Select(l => l.DiameterD70Deviation));
+ CollectionAssert.AreEqual(new[]
+ {
+ 1.01,
+ 9.99,
+ 5.21
+ }, profile.Layers.Select(l => l.PermeabilityMean));
+ CollectionAssert.AreEqual(new[]
+ {
+ 0.025,
+ 0.1,
+ 0.3
+ }, profile.Layers.Select(l => l.PermeabilityDeviation));
}
}
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs
===================================================================
diff -u -r223528aec31c0f78f0f8ff67991e43f781075931 -r6e00eba7f45883916d98df04a84f6d0dca2f61fc
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs (.../SoilProfile1DReaderTest.cs) (revision 223528aec31c0f78f0f8ff67991e43f781075931)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs (.../SoilProfile1DReaderTest.cs) (revision 6e00eba7f45883916d98df04a84f6d0dca2f61fc)
@@ -27,6 +27,7 @@
using Core.Common.Utils.Builders;
using NUnit.Framework;
using Rhino.Mocks;
+using Ringtoets.Piping.IO.Builders;
using Ringtoets.Piping.IO.Exceptions;
using Ringtoets.Piping.IO.SoilProfile;
@@ -105,7 +106,7 @@
const string profileName = "";
const string path = "A";
- SetExpectations(0, profileName, 0.0, 0.0, 1.0, string.Empty, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+ SetExpectations(0, profileName, 0.0, 0.0, null, null, null, null, null, null, null, null, null);
reader.Expect(r => r.Path).Return(path);
mocks.ReplayAll();
@@ -150,12 +151,12 @@
}
[Test]
- public void ReadFrom_NullValuesForLayer_ReturnsProfileWithNullValuesAndDefaultsOnLayer()
+ public void ReadFrom_NullValuesForLayer_ReturnsProfileWithNaNValuesAndDefaultsOnLayer()
{
// Setup
var bottom = 1.1;
var top = 1.1;
- SetExpectations(1, "", bottom, top, null, null, null, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+ SetExpectations(1, "", bottom, top, null, null, null, null, null, null, null, null, null);
mocks.ReplayAll();
@@ -173,10 +174,116 @@
Assert.AreEqual(Color.Empty, pipingSoilLayer.Color);
Assert.IsFalse(pipingSoilLayer.IsAquifer);
+ Assert.IsNaN(pipingSoilLayer.BelowPhreaticLevelMean);
+ Assert.IsNaN(pipingSoilLayer.BelowPhreaticLevelDeviation);
+ Assert.IsNaN(pipingSoilLayer.DiameterD70Mean);
+ Assert.IsNaN(pipingSoilLayer.DiameterD70Deviation);
+ Assert.IsNaN(pipingSoilLayer.PermeabilityMean);
+ Assert.IsNaN(pipingSoilLayer.PermeabilityDeviation);
+
mocks.VerifyAll();
}
[Test]
+ public void ReadFrom_InvalidBelowPhreaticLevelDistributionValue_ThrowsPipingSoilProfileReadException()
+ {
+ // Setup
+ reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution)).Return(1);
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => SoilProfile1DReader.ReadFrom(reader);
+
+ // Assert
+ Assert.Throws(test);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ReadFrom_InvalidBelowPhreaticLevelShiftValue_ThrowsPipingSoilProfileReadException()
+ {
+ // Setup
+ reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution)).Return(SoilLayerConstants.LogNormalDistributionValue);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelShift)).Return(1);
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => SoilProfile1DReader.ReadFrom(reader);
+
+ // Assert
+ Assert.Throws(test);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ReadFrom_InvalidDiameterD70DistributionValue_ThrowsPipingSoilProfileReadException()
+ {
+ // Setup
+ reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Distribution)).Return(1);
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => SoilProfile1DReader.ReadFrom(reader);
+
+ // Assert
+ Assert.Throws(test);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ReadFrom_InvalidDiameterD70ShiftValue_ThrowsPipingSoilProfileReadException()
+ {
+ // Setup
+ reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Distribution)).Return(SoilLayerConstants.LogNormalDistributionValue);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Shift)).Return(1);
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => SoilProfile1DReader.ReadFrom(reader);
+
+ // Assert
+ Assert.Throws(test);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ReadFrom_InvalidPermeabilityDistributionValue_ThrowsPipingSoilProfileReadException()
+ {
+ // Setup
+ reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityDistribution)).Return(1);
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => SoilProfile1DReader.ReadFrom(reader);
+
+ // Assert
+ Assert.Throws(test);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ReadFrom_InvalidPermeabilityShiftValue_ThrowsPipingSoilProfileReadException()
+ {
+ // Setup
+ reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityDistribution)).Return(SoilLayerConstants.LogNormalDistributionValue);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityShift)).Return(1);
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => SoilProfile1DReader.ReadFrom(reader);
+
+ // Assert
+ Assert.Throws(test);
+ mocks.VerifyAll();
+ }
+
+ [Test]
[TestCase(1)]
[TestCase(2)]
[TestCase(3)]
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs
===================================================================
diff -u -r223528aec31c0f78f0f8ff67991e43f781075931 -r6e00eba7f45883916d98df04a84f6d0dca2f61fc
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision 223528aec31c0f78f0f8ff67991e43f781075931)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision 6e00eba7f45883916d98df04a84f6d0dca2f61fc)
@@ -27,6 +27,7 @@
using Core.Common.Utils.Builders;
using NUnit.Framework;
using Rhino.Mocks;
+using Ringtoets.Piping.IO.Builders;
using Ringtoets.Piping.IO.Exceptions;
using Ringtoets.Piping.IO.SoilProfile;
using Ringtoets.Piping.IO.Test.TestHelpers;
@@ -138,7 +139,7 @@
const string path = "A";
reader.Expect(r => r.Path).Return(path);
- SetExpectations(0, name, 0.0, 1.0, string.Empty, 0, new byte[0], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+ SetExpectations(0, name, 0.0, 1.0, string.Empty, 0, new byte[0], null, null, null, null, null, null);
mocks.ReplayAll();
@@ -161,7 +162,7 @@
const string path = "A";
reader.Expect(r => r.Path).Return(path);
- SetExpectations(1, name, 0.0, 1.0, string.Empty, 0, null, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+ SetExpectations(1, name, 0.0, 1.0, string.Empty, 0, null, null, null, null, null, null, null);
mocks.ReplayAll();
@@ -183,7 +184,7 @@
const string name = "cool name";
const string path = "A";
- SetExpectations(1, name, 0.0, 1.0, string.Empty, 0, new byte[0], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+ SetExpectations(1, name, 0.0, 1.0, string.Empty, 0, new byte[0], null, null, null, null, null, null);
reader.Expect(r => r.Path).Return(path);
mocks.ReplayAll();
@@ -227,7 +228,7 @@
public void ReadFrom_NullValuesForLayer_ReturnsProfileWithNullValuesAndDefaultsOnLayer()
{
// Setup
- SetExpectations(1, "", 0.0, null, null, null, someGeometry,0.0,0.0,0.0,0.0,0.0,0.0);
+ SetExpectations(1, "", 0.0, null, null, null, someGeometry, null, null, null, null, null, null);
mocks.ReplayAll();
@@ -245,6 +246,13 @@
Assert.IsEmpty(pipingSoilLayer.MaterialName);
Assert.AreEqual(Color.Empty, pipingSoilLayer.Color);
+ Assert.IsNaN(pipingSoilLayer.BelowPhreaticLevelMean);
+ Assert.IsNaN(pipingSoilLayer.BelowPhreaticLevelDeviation);
+ Assert.IsNaN(pipingSoilLayer.DiameterD70Mean);
+ Assert.IsNaN(pipingSoilLayer.DiameterD70Deviation);
+ Assert.IsNaN(pipingSoilLayer.PermeabilityMean);
+ Assert.IsNaN(pipingSoilLayer.PermeabilityDeviation);
+
mocks.VerifyAll();
}
@@ -307,7 +315,105 @@
mocks.VerifyAll();
}
+ [Test]
+ public void ReadFrom_InvalidBelowPhreaticLevelDistributionValue_ThrowsPipingSoilProfileReadException()
+ {
+ // Setup
+ reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution)).Return(1);
+ mocks.ReplayAll();
+ // Call
+ TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader);
+
+ // Assert
+ Assert.Throws(test);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ReadFrom_InvalidBelowPhreaticLevelShiftValue_ThrowsPipingSoilProfileReadException()
+ {
+ // Setup
+ reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution)).Return(SoilLayerConstants.LogNormalDistributionValue);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelShift)).Return(1);
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader);
+
+ // Assert
+ Assert.Throws(test);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ReadFrom_InvalidDiameterD70DistributionValue_ThrowsPipingSoilProfileReadException()
+ {
+ // Setup
+ reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Distribution)).Return(1);
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader);
+
+ // Assert
+ Assert.Throws(test);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ReadFrom_InvalidDiameterD70ShiftValue_ThrowsPipingSoilProfileReadException()
+ {
+ // Setup
+ reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Distribution)).Return(SoilLayerConstants.LogNormalDistributionValue);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Shift)).Return(1);
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader);
+
+ // Assert
+ Assert.Throws(test);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ReadFrom_InvalidPermeabilityDistributionValue_ThrowsPipingSoilProfileReadException()
+ {
+ // Setup
+ reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityDistribution)).Return(1);
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader);
+
+ // Assert
+ Assert.Throws(test);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ReadFrom_InvalidPermeabilityShiftValue_ThrowsPipingSoilProfileReadException()
+ {
+ // Setup
+ reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityDistribution)).Return(SoilLayerConstants.LogNormalDistributionValue);
+ reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityShift)).Return(1);
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader);
+
+ // Assert
+ Assert.Throws(test);
+ mocks.VerifyAll();
+ }
+
private void SetExpectations(int layerCount, string profileName, double intersectionX, double? isAquifer, string materialName, double? color, byte[] geometry, double? belowPhreaticLevelMean, double? belowPhreaticLevelDeviation, double? diameterD70Mean, double? diameterD70Deviation, double? permeabilityMean, double? permeabilityDeviation)
{
reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(layerCount).Repeat.Any();
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingSoilProfilesReader/incorrect2dStochastDistributionProperty.soil
===================================================================
diff -u
Binary files differ
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingSoilProfilesReader/incorrectValue2dStochastProperty.soil
===================================================================
diff -u -r751aaf9b7623bac357cbacf4e6ddae87b2b69f1f -r6e00eba7f45883916d98df04a84f6d0dca2f61fc
Binary files differ