Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsSoilLayer.cs =================================================================== diff -u -r5906f61fff270a7526253bea07dfecdf680898ed -r9caa7daa14d0070e2a3f68c4b9e66109318bd9ab --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsSoilLayer.cs (.../MacroStabilityInwardsSoilLayer.cs) (revision 5906f61fff270a7526253bea07dfecdf680898ed) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsSoilLayer.cs (.../MacroStabilityInwardsSoilLayer.cs) (revision 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab) @@ -30,45 +30,388 @@ /// public class MacroStabilityInwardsSoilLayer { - private string materialName; - /// /// Creates a new instance of , where the top is set to . /// /// The top level of the layer. public MacroStabilityInwardsSoilLayer(double top) { Top = top; - MaterialName = string.Empty; + Properties = new SoilLayerProperties(); } /// + /// Gets the properties of the . + /// + public SoilLayerProperties Properties { get; } + + /// /// Gets the top level of the . /// public double Top { get; } /// /// Gets or sets a value indicating whether or not the is an aquifer. /// - public bool IsAquifer { get; set; } + public bool IsAquifer + { + get + { + return Properties.IsAquifer; + } + set + { + Properties.IsAquifer = value; + } + } /// + /// Gets or sets a value indicating whether or not to use POP for the . + /// + public bool UsePop + { + get + { + return Properties.UsePop; + } + set + { + Properties.UsePop = value; + } + } + + /// + /// Gets or sets the shear strength model used for the . + /// + public ShearStrengthModel ShearStrengthModel + { + get + { + return Properties.ShearStrengthModel; + } + set + { + Properties.ShearStrengthModel = value; + } + } + + /// + /// Gets or sets the mean of the distrubtion for the volumic weight of the above the phreatic level. + /// [kN/m³] + /// + public double AbovePhreaticLevelMean + { + get + { + return Properties.AbovePhreaticLevelMean; + } + set + { + Properties.AbovePhreaticLevelMean = value; + } + } + + /// + /// Gets or sets the deviation of the distrubtion for the volumic weight of the above the phreatic level. + /// [kN/m³] + /// + public double AbovePhreaticLevelDeviation + { + get + { + return Properties.AbovePhreaticLevelDeviation; + } + set + { + Properties.AbovePhreaticLevelDeviation = value; + } + } + + /// + /// Gets or sets the mean of the distrubtion for the volumic weight of the below the phreatic level. + /// [kN/m³] + /// + public double BelowPhreaticLevelMean + { + get + { + return Properties.BelowPhreaticLevelMean; + } + set + { + Properties.BelowPhreaticLevelMean = value; + } + } + + /// + /// Gets or sets the deviation of the distrubtion for the volumic weight of the below the phreatic level. + /// [kN/m³] + /// + public double BelowPhreaticLevelDeviation + { + get + { + return Properties.BelowPhreaticLevelDeviation; + } + set + { + Properties.BelowPhreaticLevelDeviation = value; + } + } + + /// + /// Gets or sets the mean of the distribution for the friction angle of the + /// [°] + /// + public double FrictionAngleMean + { + get + { + return Properties.FrictionAngleMean; + } + set + { + Properties.FrictionAngleMean = value; + } + } + + /// + /// Gets or sets the deviation of the distribution for the friction angle of the . + /// [°] + /// + public double FrictionAngleDeviation + { + get + { + return Properties.FrictionAngleDeviation; + } + set + { + Properties.FrictionAngleDeviation = value; + } + } + + /// + /// Gets or sets the shift of the distrubtion for the friction angle of the . + /// [°] + /// + public double FrictionAngleShift + { + get + { + return Properties.FrictionAngleShift; + } + set + { + Properties.FrictionAngleShift = value; + } + } + + /// + /// Gets or sets the mean of the distribution for the ratio of shear strength S of the + /// [-] + /// + public double ShearStrengthRatioMean + { + get + { + return Properties.ShearStrengthRatioMean; + } + set + { + Properties.ShearStrengthRatioMean = value; + } + } + + /// + /// Gets or sets the deviation of the distribution for the ratio of shear strength S of the . + /// [-] + /// + public double ShearStrengthRatioDeviation + { + get + { + return Properties.ShearStrengthRatioDeviation; + } + set + { + Properties.ShearStrengthRatioDeviation = value; + } + } + + /// + /// Gets or sets the shift of the distrubtion for the ratio of shear strength S of the . + /// [-] + /// + public double ShearStrengthRatioShift + { + get + { + return Properties.ShearStrengthRatioShift; + } + set + { + Properties.ShearStrengthRatioShift = value; + } + } + + /// + /// Gets or sets the mean of the distribution for the strength increase exponent (m) of the + /// [-] + /// + public double StrengthIncreaseExponentMean + { + get + { + return Properties.StrengthIncreaseExponentMean; + } + set + { + Properties.StrengthIncreaseExponentMean = value; + } + } + + /// + /// Gets or sets the deviation of the distribution for the strength increase exponent (m) of the . + /// [-] + /// + public double StrengthIncreaseExponentDeviation + { + get + { + return Properties.StrengthIncreaseExponentDeviation; + } + set + { + Properties.StrengthIncreaseExponentDeviation = value; + } + } + + /// + /// Gets or sets the shift of the distrubtion for the strength increase exponent (m) of the . + /// [-] + /// + public double StrengthIncreaseExponentShift + { + get + { + return Properties.StrengthIncreaseExponentShift; + } + set + { + Properties.StrengthIncreaseExponentShift = value; + } + } + + /// + /// Gets or sets the mean of the distribution for the cohesion of the + /// [kN/m³] + /// + public double CohesionMean + { + get + { + return Properties.CohesionMean; + } + set + { + Properties.CohesionMean = value; + } + } + + /// + /// Gets or sets the deviation of the distribution for the cohesion of the . + /// [kN/m³] + /// + public double CohesionDeviation + { + get + { + return Properties.CohesionDeviation; + } + set + { + Properties.CohesionDeviation = value; + } + } + + /// + /// Gets or sets the shift of the distrubtion for the cohesion of the . + /// [kN/m³] + /// + public double CohesionShift + { + get + { + return Properties.CohesionShift; + } + set + { + Properties.CohesionShift = value; + } + } + + /// + /// Gets or sets the mean of the distribution for the POP of the + /// [kN/m²] + /// + public double PopMean + { + get + { + return Properties.PopMean; + } + set + { + Properties.PopMean = value; + } + } + + /// + /// Gets or sets the deviation of the distribution for the POP of the . + /// [kN/m²] + /// + public double PopDeviation + { + get + { + return Properties.PopDeviation; + } + set + { + Properties.PopDeviation = value; + } + } + + /// + /// Gets or sets the shift of the distrubtion for the POP of the . + /// [kN/m²] + /// + public double PopShift + { + get + { + return Properties.PopShift; + } + set + { + Properties.PopShift = value; + } + } + + /// /// Gets or sets the name of the material that was assigned to the . /// /// Thrown when is null. public string MaterialName { get { - return materialName; + return Properties.MaterialName; } set { - if (value == null) - { - throw new ArgumentNullException(nameof(value)); - } - materialName = value; + Properties.MaterialName = value; } } @@ -98,7 +441,7 @@ { unchecked { - int hashCode = materialName?.GetHashCode() ?? 0; + int hashCode = MaterialName?.GetHashCode() ?? 0; hashCode = (hashCode * 397) ^ Top.GetHashCode(); hashCode = (hashCode * 397) ^ IsAquifer.GetHashCode(); hashCode = (hashCode * 397) ^ Color.GetHashCode(); @@ -108,7 +451,7 @@ private bool Equals(MacroStabilityInwardsSoilLayer other) { - return string.Equals(materialName, other.materialName) + return string.Equals(MaterialName, other.MaterialName) && Top.Equals(other.Top) && IsAquifer == other.IsAquifer && Color.Equals(other.Color); Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/Ringtoets.MacroStabilityInwards.Primitives.csproj =================================================================== diff -u -ra940166534b3dd6e778de2e7c8e7e5241f3d3381 -r9caa7daa14d0070e2a3f68c4b9e66109318bd9ab --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/Ringtoets.MacroStabilityInwards.Primitives.csproj (.../Ringtoets.MacroStabilityInwards.Primitives.csproj) (revision a940166534b3dd6e778de2e7c8e7e5241f3d3381) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/Ringtoets.MacroStabilityInwards.Primitives.csproj (.../Ringtoets.MacroStabilityInwards.Primitives.csproj) (revision 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab) @@ -52,6 +52,8 @@ True + + Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/ShearStrengthModel.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/ShearStrengthModel.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/ShearStrengthModel.cs (revision 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab) @@ -0,0 +1,31 @@ +// 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. + +namespace Ringtoets.MacroStabilityInwards.Primitives +{ + public enum ShearStrengthModel + { + None, + SuCalculated, + CPhi, + CPhiOrSuCalculated + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/SoilLayerProperties.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/SoilLayerProperties.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/SoilLayerProperties.cs (revision 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab) @@ -0,0 +1,71 @@ +// 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 System; +using System.Drawing; + +namespace Ringtoets.MacroStabilityInwards.Primitives +{ + public class SoilLayerProperties + { + private string materialName = string.Empty; + public bool IsAquifer { get; set; } + + public string MaterialName + { + get + { + return materialName; + } + set + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + materialName = value; + } + } + + public Color Color { get; set; } + public bool UsePop { get; set; } + public ShearStrengthModel ShearStrengthModel { get; set; } + public double AbovePhreaticLevelMean { get; set; } = double.NaN; + public double AbovePhreaticLevelDeviation { get; set; } = double.NaN; + public double BelowPhreaticLevelMean { get; set; } = double.NaN; + public double BelowPhreaticLevelDeviation { get; set; } = double.NaN; + public double CohesionMean { get; set; } = double.NaN; + public double CohesionDeviation { get; set; } = double.NaN; + public double CohesionShift { get; set; } = double.NaN; + public double FrictionAngleMean { get; set; } = double.NaN; + public double FrictionAngleDeviation { get; set; } = double.NaN; + public double FrictionAngleShift { get; set; } = double.NaN; + public double ShearStrengthRatioMean { get; set; } = double.NaN; + public double ShearStrengthRatioDeviation { get; set; } = double.NaN; + public double ShearStrengthRatioShift { get; set; } = double.NaN; + public double StrengthIncreaseExponentMean { get; set; } = double.NaN; + public double StrengthIncreaseExponentDeviation { get; set; } = double.NaN; + public double StrengthIncreaseExponentShift { get; set; } = double.NaN; + public double PopMean { get; set; } = double.NaN; + public double PopDeviation { get; set; } = double.NaN; + public double PopShift { get; set; } = double.NaN; + } +} \ No newline at end of file Fisheye: Tag 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Exceptions/RingtoetsMacroStabilityInwardsSurfaceLineExceptionTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsSoilLayerTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsSoilProfileTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj =================================================================== diff -u -r650fc7b43cb6729baee51d079f0377df8d7a3de9 -r9caa7daa14d0070e2a3f68c4b9e66109318bd9ab --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.Test.csproj) (revision 650fc7b43cb6729baee51d079f0377df8d7a3de9) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.Test.csproj) (revision 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab) @@ -57,7 +57,6 @@ Properties\GlobalAssembly.cs - @@ -68,11 +67,8 @@ - - - Fisheye: Tag 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/RingtoetsMacroStabilityInwardsSurfaceLineTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/Exceptions/RingtoetsMacroStabilityInwardsSurfaceLineExceptionTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/Exceptions/RingtoetsMacroStabilityInwardsSurfaceLineExceptionTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/Exceptions/RingtoetsMacroStabilityInwardsSurfaceLineExceptionTest.cs (revision 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab) @@ -0,0 +1,32 @@ +// 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 System; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.MacroStabilityInwards.Primitives.Exceptions; + +namespace Ringtoets.MacroStabilityInwards.Primitives.Test.Exceptions +{ + [TestFixture] + public class RingtoetsMacroStabilityInwardsSurfaceLineExceptionTest : + CustomExceptionDesignGuidelinesTestFixture {} +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSoilLayerTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSoilLayerTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSoilLayerTest.cs (revision 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab) @@ -0,0 +1,174 @@ +// 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 System; +using System.Drawing; +using System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; + +namespace Ringtoets.MacroStabilityInwards.Primitives.Test +{ + [TestFixture] + public class MacroStabilityInwardsSoilLayerTest + { + [Test] + public void Constructor_WithTop_ReturnsNewInstanceWithTopSet() + { + // Setup + double top = new Random(22).NextDouble(); + + // Call + var layer = new MacroStabilityInwardsSoilLayer(top); + + // Assert + Assert.NotNull(layer); + Assert.AreEqual(top, layer.Top); + Assert.IsFalse(layer.IsAquifer); + Assert.IsEmpty(layer.MaterialName); + Assert.AreEqual(Color.Empty, layer.Color); + + Assert.IsFalse(layer.UsePop); + Assert.AreEqual(ShearStrengthModel.None, layer.ShearStrengthModel); + + Assert.IsNaN(layer.AbovePhreaticLevelMean); + Assert.IsNaN(layer.AbovePhreaticLevelDeviation); + + Assert.IsNaN(layer.BelowPhreaticLevelMean); + Assert.IsNaN(layer.BelowPhreaticLevelDeviation); + + Assert.IsNaN(layer.CohesionMean); + Assert.IsNaN(layer.CohesionDeviation); + Assert.IsNaN(layer.CohesionShift); + + Assert.IsNaN(layer.FrictionAngleMean); + Assert.IsNaN(layer.FrictionAngleDeviation); + Assert.IsNaN(layer.FrictionAngleShift); + + Assert.IsNaN(layer.ShearStrengthRatioMean); + Assert.IsNaN(layer.ShearStrengthRatioDeviation); + Assert.IsNaN(layer.ShearStrengthRatioShift); + + Assert.IsNaN(layer.StrengthIncreaseExponentMean); + Assert.IsNaN(layer.StrengthIncreaseExponentDeviation); + Assert.IsNaN(layer.StrengthIncreaseExponentShift); + + Assert.IsNaN(layer.PopMean); + Assert.IsNaN(layer.PopDeviation); + Assert.IsNaN(layer.PopShift); + } + + [Test] + public void MaterialName_Null_ThrowsArgumentNullException() + { + // Setup + double top = new Random(22).NextDouble(); + var layer = new MacroStabilityInwardsSoilLayer(top); + + // Call + TestDelegate test = () => layer.MaterialName = null; + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("value", paramName); + } + + [Test] + [TestCase("")] + [TestCase("A name")] + public void MaterialName_NotNullValue_ValueSet(string materialName) + { + // Setup + double top = new Random(22).NextDouble(); + var layer = new MacroStabilityInwardsSoilLayer(top); + + // Call + layer.MaterialName = materialName; + + // Assert + Assert.AreEqual(materialName, layer.MaterialName); + } + + [Test] + public void Equals_Null_ReturnsFalse() + { + // Setup + MacroStabilityInwardsSoilLayer layer = CreateRandomLayer(21); + + // Call + bool areEqual = layer.Equals(null); + + // Assert + Assert.IsFalse(areEqual); + } + + [Test] + [TestCaseSource(nameof(LayerCombinations))] + public void Equals_DifferentScenarios_ReturnsExpectedResult(MacroStabilityInwardsSoilLayer layer, MacroStabilityInwardsSoilLayer otherLayer, bool expectedEqual) + { + // Call + bool areEqualOne = layer.Equals(otherLayer); + bool areEqualTwo = otherLayer.Equals(layer); + + // Assert + Assert.AreEqual(expectedEqual, areEqualOne); + Assert.AreEqual(expectedEqual, areEqualTwo); + } + + private static TestCaseData[] LayerCombinations() + { + MacroStabilityInwardsSoilLayer layerA = CreateRandomLayer(21); + MacroStabilityInwardsSoilLayer layerB = CreateRandomLayer(21); + MacroStabilityInwardsSoilLayer layerC = CreateRandomLayer(73); + + return new[] + { + new TestCaseData(layerA, layerA, true) + { + TestName = "Equals_LayerALayerA_True" + }, + new TestCaseData(layerA, layerB, true) + { + TestName = "Equals_LayerALayerB_True" + }, + new TestCaseData(layerB, layerC, false) + { + TestName = "Equals_LayerBLayerC_False" + }, + new TestCaseData(layerC, layerC, true) + { + TestName = "Equals_LayerCLayerC_True" + } + }; + } + + private static MacroStabilityInwardsSoilLayer CreateRandomLayer(int randomSeed) + { + var random = new Random(randomSeed); + return new MacroStabilityInwardsSoilLayer(random.NextDouble()) + { + MaterialName = string.Join("", Enumerable.Repeat('x', random.Next(0, 40))), + Color = Color.FromKnownColor(random.NextEnumValue()), + IsAquifer = random.NextBoolean() + }; + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSoilProfileTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSoilProfileTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSoilProfileTest.cs (revision 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab) @@ -0,0 +1,337 @@ +// 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 System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Drawing; +using System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; + +namespace Ringtoets.MacroStabilityInwards.Primitives.Test +{ + [TestFixture] + public class MacroStabilityInwardsSoilProfileTest + { + private static readonly Random profileIdRandom = new Random(32); + + [Test] + [TestCase(SoilProfileType.SoilProfile1D)] + [TestCase(SoilProfileType.SoilProfile2D)] + public void Constructor_WithNameBottomLayersAndAquifer_ReturnsInstanceWithPropsAndEquivalentLayerCollection(SoilProfileType type) + { + // Setup + const string name = "Profile"; + var random = new Random(22); + double bottom = random.NextDouble(); + var layers = new Collection + { + new MacroStabilityInwardsSoilLayer(bottom) + }; + const long soilProfileId = 1234L; + + // Call + var profile = new MacroStabilityInwardsSoilProfile(name, bottom, layers, type, soilProfileId); + + // Assert + Assert.AreNotSame(layers, profile.Layers); + Assert.AreEqual(name, profile.Name); + Assert.AreEqual(bottom, profile.Bottom); + Assert.AreEqual(type, profile.SoilProfileType); + Assert.AreEqual(soilProfileId, profile.MacroStabilityInwardsSoilProfileId); + } + + [Test] + public void Constructor_WithNameBottomLayersEmpty_ThrowsArgumentException() + { + // Call + TestDelegate test = () => new MacroStabilityInwardsSoilProfile(string.Empty, double.NaN, new Collection(), SoilProfileType.SoilProfile1D, 0); + + // Assert + const string expectedMessage = "Geen lagen gevonden voor de ondergrondschematisatie."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + public void Constructor_WithNameBottomLayersNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new MacroStabilityInwardsSoilProfile(string.Empty, double.NaN, null, SoilProfileType.SoilProfile1D, 0); + + // Assert + const string expectedMessage = "Geen lagen gevonden voor de ondergrondschematisatie."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + [TestCase(1)] + [TestCase(5)] + [TestCase(15)] + public void Layers_Always_ReturnsDescendingByTopOrderedList(int layerCount) + { + // Setup + var random = new Random(21); + const double bottom = 0.0; + var equivalentLayers = new List(layerCount); + for (var i = 0; i < layerCount; i++) + { + equivalentLayers.Add(new MacroStabilityInwardsSoilLayer(random.NextDouble()) + { + IsAquifer = i == 0 + }); + } + + var profile = new MacroStabilityInwardsSoilProfile(string.Empty, bottom, equivalentLayers, SoilProfileType.SoilProfile1D, 0); + + // Call + MacroStabilityInwardsSoilLayer[] result = profile.Layers.ToArray(); + + // Assert + CollectionAssert.AreEquivalent(equivalentLayers, result); + CollectionAssert.AreEqual(equivalentLayers.OrderByDescending(l => l.Top).Select(l => l.Top), result.Select(l => l.Top)); + } + + [Test] + [TestCase(1e-6)] + [TestCase(4)] + public void Constructor_WithNameBottomLayersBelowBottom_ThrowsArgumentException(double deltaBelowBottom) + { + // Setup + const double bottom = 0.0; + var soilLayers = new[] + { + new MacroStabilityInwardsSoilLayer(bottom - deltaBelowBottom), + new MacroStabilityInwardsSoilLayer(1.1) + }; + + // Call + TestDelegate test = () => new MacroStabilityInwardsSoilProfile(string.Empty, bottom, soilLayers, SoilProfileType.SoilProfile1D, 0); + + // Assert + const string expectedMessage = "Eén of meerdere lagen hebben een top onder de bodem van de ondergrondschematisatie."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + [TestCase(0, 0)] + [TestCase(1, 1.1)] + public void GetLayerThickness_LayerInProfile_ReturnsThicknessOfLayer(int layerIndex, double expectedThickness) + { + // Setup + var soilLayers = new[] + { + new MacroStabilityInwardsSoilLayer(0.0), + new MacroStabilityInwardsSoilLayer(1.1) + }; + var profile = new MacroStabilityInwardsSoilProfile(string.Empty, 0.0, soilLayers, SoilProfileType.SoilProfile1D, 0); + + // Call + double thickness = profile.GetLayerThickness(soilLayers[layerIndex]); + + // Assert + Assert.AreEqual(expectedThickness, thickness); + } + + [Test] + public void GetLayerThickness_LayerNotInProfile_ThrowsArgumentException() + { + // Setup + var soilLayers = new[] + { + new MacroStabilityInwardsSoilLayer(0.0), + new MacroStabilityInwardsSoilLayer(1.1) + }; + var profile = new MacroStabilityInwardsSoilProfile(string.Empty, 0.0, soilLayers, SoilProfileType.SoilProfile1D, 0); + + // Call + TestDelegate test = () => profile.GetLayerThickness(new MacroStabilityInwardsSoilLayer(1.1)); + + // Assert + const string expectedMessage = "Layer not found in profile."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + public void ToString_WithNullName_ReturnsStringEmpty() + { + // Setup + var profile = new MacroStabilityInwardsSoilProfile(null, 0.0, new[] + { + new MacroStabilityInwardsSoilLayer(0.0) + }, SoilProfileType.SoilProfile1D, 0); + + // Call + string text = profile.ToString(); + + // Assert + Assert.IsEmpty(text); + } + + [Test] + [TestCase("")] + [TestCase("some name")] + public void ToString_WithName_ReturnsName(string name) + { + // Setup + var profile = new MacroStabilityInwardsSoilProfile(name, 0.0, new[] + { + new MacroStabilityInwardsSoilLayer(0.0) + }, SoilProfileType.SoilProfile1D, 0); + + // Call + string text = profile.ToString(); + + // Assert + Assert.AreEqual(name, text); + } + + [Test] + public void Equals_Null_ReturnsFalse() + { + // Setup + var profile = new MacroStabilityInwardsSoilProfile("name", 0, new[] + { + CreateRandomLayer(new Random(21)) + }, SoilProfileType.SoilProfile1D, -1); + + // Call + bool areEqual = profile.Equals(null); + + // Assert + Assert.IsFalse(areEqual); + } + + [Test] + [TestCaseSource(nameof(ProfileCombinations))] + public void Equals_DifferentScenarios_ReturnsExpectedResult(MacroStabilityInwardsSoilProfile profile, MacroStabilityInwardsSoilProfile otherProfile, bool expectedEqual) + { + // Call + bool areEqualOne = profile.Equals(otherProfile); + bool areEqualTwo = otherProfile.Equals(profile); + + // Assert + Assert.AreEqual(expectedEqual, areEqualOne); + Assert.AreEqual(expectedEqual, areEqualTwo); + } + + private static TestCaseData[] ProfileCombinations() + { + MacroStabilityInwardsSoilProfile profileA = CreateRandomProfile(21); + MacroStabilityInwardsSoilProfile profileB = CreateRandomProfile(21); + MacroStabilityInwardsSoilProfile profileC = CreateRandomProfile(73); + + MacroStabilityInwardsSoilProfile profileD = CreateSingleLayerProfile("A", -3, SoilProfileType.SoilProfile1D); + MacroStabilityInwardsSoilProfile profileE = CreateSingleLayerProfile("A", -3, SoilProfileType.SoilProfile2D); + MacroStabilityInwardsSoilProfile profileF = CreateSingleLayerProfile("A", -2, SoilProfileType.SoilProfile1D); + MacroStabilityInwardsSoilProfile profileG = CreateSingleLayerProfile("B", -3, SoilProfileType.SoilProfile1D); + + const int seed = 78; + var random = new Random(seed); + var profileH = new MacroStabilityInwardsSoilProfile(GetRandomName(random), -random.NextDouble(), new[] + { + CreateRandomLayer(random) + }, random.NextEnumValue(), random.Next()); + + random = new Random(seed); + var profileI = new MacroStabilityInwardsSoilProfile(GetRandomName(random), -random.NextDouble(), new[] + { + CreateRandomLayer(random), + CreateRandomLayer(random) + }, random.NextEnumValue(), random.Next()); + + var profileJ = new MacroStabilityInwardsSoilProfile("A", -3, new[] + { + new MacroStabilityInwardsSoilLayer(-2) + }, SoilProfileType.SoilProfile1D, 35); + var profileK = new MacroStabilityInwardsSoilProfile("A", -3, new[] + { + new MacroStabilityInwardsSoilLayer(-2) + }, SoilProfileType.SoilProfile1D, 56); + + return new[] + { + new TestCaseData(profileA, profileB, true) + { + TestName = "Equals_ProfileAProfileB_True" + }, + new TestCaseData(profileB, profileC, false) + { + TestName = "Equals_ProfileBProfileC_False" + }, + new TestCaseData(profileD, profileE, false) + { + TestName = "Equals_ProfileDProfileE_False" + }, + new TestCaseData(profileD, profileF, false) + { + TestName = "Equals_ProfileDProfileF_False" + }, + new TestCaseData(profileD, profileG, false) + { + TestName = "Equals_ProfileDProfileG_False" + }, + new TestCaseData(profileH, profileI, false) + { + TestName = "Equals_ProfileHProfileI_False" + }, + new TestCaseData(profileJ, profileK, true) + { + TestName = "Equals_DifferentIds_True" + } + }; + } + + private static MacroStabilityInwardsSoilProfile CreateSingleLayerProfile(string name, double bottom, SoilProfileType type) + { + return new MacroStabilityInwardsSoilProfile(name, bottom, new[] + { + new MacroStabilityInwardsSoilLayer(bottom + 1.0) + }, type, profileIdRandom.Next()); + } + + private static MacroStabilityInwardsSoilProfile CreateRandomProfile(int randomSeed) + { + var random = new Random(randomSeed); + var layers = new Collection(); + for (var i = 0; i < random.Next(2, 6); i++) + { + layers.Add(CreateRandomLayer(random)); + } + return new MacroStabilityInwardsSoilProfile(GetRandomName(random), -1.0 - random.NextDouble(), layers, random.NextEnumValue(), profileIdRandom.Next()); + } + + private static MacroStabilityInwardsSoilLayer CreateRandomLayer(Random random) + { + return new MacroStabilityInwardsSoilLayer(random.NextDouble()) + { + MaterialName = GetRandomName(random), + Color = Color.FromKnownColor(random.NextEnumValue()), + IsAquifer = random.NextBoolean() + }; + } + + private static string GetRandomName(Random random) + { + return new string('x', random.Next(0, 40)); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/Ringtoets.MacroStabilityInwards.Primitives.Test.csproj =================================================================== diff -u -r650fc7b43cb6729baee51d079f0377df8d7a3de9 -r9caa7daa14d0070e2a3f68c4b9e66109318bd9ab --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/Ringtoets.MacroStabilityInwards.Primitives.Test.csproj (.../Ringtoets.MacroStabilityInwards.Primitives.Test.csproj) (revision 650fc7b43cb6729baee51d079f0377df8d7a3de9) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/Ringtoets.MacroStabilityInwards.Primitives.Test.csproj (.../Ringtoets.MacroStabilityInwards.Primitives.Test.csproj) (revision 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab) @@ -41,20 +41,53 @@ MinimumRecommendedRules.ruleset + + ..\..\..\..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll + True + + Properties\GlobalAssembly.cs + + + + + Copying.licenseheader + + + + {3BBFD65B-B277-4E50-AE6D-BD24C3434609} + Core.Common.Base + + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + + + {d4200f43-3f72-4f42-af0a-8ced416a38ec} + Ringtoets.Common.Data + + + {4843D6E5-066F-4795-94F5-1D53932DD03C} + Ringtoets.Common.Data.TestUtil + + + {E9B39743-2DC9-4922-9E0F-6BA3E0E54189} + Ringtoets.MacroStabilityInwards.Primitives + + + + + \ No newline at end of file Fisheye: Tag 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Exceptions/RingtoetsPipingSurfaceLineExceptionTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilLayerTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilProfileTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj =================================================================== diff -u -r257b5b8c4e053ff875f75e0940a0f9d8775ef083 -r9caa7daa14d0070e2a3f68c4b9e66109318bd9ab --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj (.../Ringtoets.Piping.Data.Test.csproj) (revision 257b5b8c4e053ff875f75e0940a0f9d8775ef083) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj (.../Ringtoets.Piping.Data.Test.csproj) (revision 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab) @@ -58,7 +58,6 @@ Properties\GlobalAssembly.cs - @@ -69,11 +68,8 @@ - - - Fisheye: Tag 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/Exceptions/RingtoetsPipingSurfaceLineExceptionTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/Exceptions/RingtoetsPipingSurfaceLineExceptionTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/Exceptions/RingtoetsPipingSurfaceLineExceptionTest.cs (revision 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab) @@ -0,0 +1,32 @@ +// 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 System; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Piping.Primitives.Exceptions; + +namespace Ringtoets.Piping.Primitives.Test.Exceptions +{ + [TestFixture] + public class RingtoetsPipingSurfaceLineExceptionTest : + CustomExceptionDesignGuidelinesTestFixture {} +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/PipingSoilLayerTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/PipingSoilLayerTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/PipingSoilLayerTest.cs (revision 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab) @@ -0,0 +1,196 @@ +// 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 System; +using System.Drawing; +using System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; + +namespace Ringtoets.Piping.Primitives.Test +{ + [TestFixture] + public class PipingSoilLayerTest + { + [Test] + public void Constructor_WithTop_ReturnsNewInstanceWithTopSet() + { + // Setup + double top = new Random(22).NextDouble(); + + // Call + var layer = new PipingSoilLayer(top); + + // Assert + Assert.NotNull(layer); + Assert.AreEqual(top, layer.Top); + Assert.IsFalse(layer.IsAquifer); + Assert.IsEmpty(layer.MaterialName); + Assert.AreEqual(Color.Empty, layer.Color); + + Assert.IsNaN(layer.BelowPhreaticLevelMean); + Assert.IsNaN(layer.BelowPhreaticLevelDeviation); + Assert.IsNaN(layer.BelowPhreaticLevelShift); + + Assert.IsNaN(layer.DiameterD70Mean); + Assert.IsNaN(layer.DiameterD70CoefficientOfVariation); + + Assert.IsNaN(layer.PermeabilityMean); + Assert.IsNaN(layer.PermeabilityCoefficientOfVariation); + } + + [Test] + public void MaterialName_Null_ThrowsArgumentNullException() + { + // Setup + double top = new Random(22).NextDouble(); + var layer = new PipingSoilLayer(top); + + // Call + TestDelegate test = () => layer.MaterialName = null; + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("value", paramName); + } + + [Test] + [TestCase("")] + [TestCase("A name")] + public void MaterialName_NotNullValue_ValueSet(string materialName) + { + // Setup + double top = new Random(22).NextDouble(); + var layer = new PipingSoilLayer(top); + + // Call + layer.MaterialName = materialName; + + // Assert + Assert.AreEqual(materialName, layer.MaterialName); + } + + [Test] + public void Equals_Null_ReturnsFalse() + { + // Setup + PipingSoilLayer layer = CreateRandomLayer(21); + + // Call + bool areEqual = layer.Equals(null); + + // Assert + Assert.IsFalse(areEqual); + } + + [Test] + [TestCaseSource(nameof(LayerCombinations))] + public void Equals_DifferentScenarios_ReturnsExpectedResult(PipingSoilLayer layer, PipingSoilLayer otherLayer, bool expectedEqual) + { + // Call + bool areEqualOne = layer.Equals(otherLayer); + bool areEqualTwo = otherLayer.Equals(layer); + + // Assert + Assert.AreEqual(expectedEqual, areEqualOne); + Assert.AreEqual(expectedEqual, areEqualTwo); + } + + private static TestCaseData[] LayerCombinations() + { + PipingSoilLayer layerA = CreateRandomLayer(21); + PipingSoilLayer layerB = CreateRandomLayer(21); + PipingSoilLayer layerC = CreateRandomLayer(73); + + PipingSoilLayer layerD = CreateNaNLayer("C", Color.Aqua, true); + PipingSoilLayer layerE = CreateNaNLayer("C", Color.Aqua, false); + PipingSoilLayer layerF = CreateNaNLayer("C", Color.AliceBlue, false); + PipingSoilLayer layerG = CreateNaNLayer("A", Color.Aqua, false); + + return new[] + { + new TestCaseData(layerA, layerA, true) + { + TestName = "Equals_LayerALayerA_True" + }, + new TestCaseData(layerA, layerB, true) + { + TestName = "Equals_LayerALayerB_True" + }, + new TestCaseData(layerB, layerC, false) + { + TestName = "Equals_LayerBLayerC_False" + }, + new TestCaseData(layerC, layerC, true) + { + TestName = "Equals_LayerCLayerC_True" + }, + new TestCaseData(layerD, layerE, false) + { + TestName = "Equals_LayerDLayerE_False" + }, + new TestCaseData(layerD, layerF, false) + { + TestName = "Equals_LayerDLayerF_False" + }, + new TestCaseData(layerD, layerG, false) + { + TestName = "Equals_LayerDLayerG_False" + } + }; + } + + private static PipingSoilLayer CreateRandomLayer(int randomSeed) + { + var random = new Random(randomSeed); + return new PipingSoilLayer(random.NextDouble()) + { + MaterialName = string.Join("", Enumerable.Repeat('x', random.Next(0, 40))), + Color = Color.FromKnownColor(random.NextEnumValue()), + IsAquifer = random.NextBoolean(), + BelowPhreaticLevelDeviation = random.NextDouble(), + BelowPhreaticLevelMean = random.NextDouble(), + BelowPhreaticLevelShift = random.NextDouble(), + DiameterD70CoefficientOfVariation = random.NextDouble(), + DiameterD70Mean = random.NextDouble(), + PermeabilityCoefficientOfVariation = random.NextDouble(), + PermeabilityMean = random.NextDouble() + }; + } + + private static PipingSoilLayer CreateNaNLayer(string name, Color color, bool isAquifer) + { + return new PipingSoilLayer(double.NaN) + { + MaterialName = name, + Color = color, + IsAquifer = isAquifer, + BelowPhreaticLevelDeviation = double.NaN, + BelowPhreaticLevelMean = double.NaN, + BelowPhreaticLevelShift = double.NaN, + DiameterD70CoefficientOfVariation = double.NaN, + DiameterD70Mean = double.NaN, + PermeabilityCoefficientOfVariation = double.NaN, + PermeabilityMean = double.NaN + }; + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/PipingSoilProfileTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/PipingSoilProfileTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/PipingSoilProfileTest.cs (revision 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab) @@ -0,0 +1,344 @@ +// 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 System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Drawing; +using System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; + +namespace Ringtoets.Piping.Primitives.Test +{ + [TestFixture] + public class PipingSoilProfileTest + { + private static readonly Random profileIdRandom = new Random(32); + + [Test] + [TestCase(SoilProfileType.SoilProfile1D)] + [TestCase(SoilProfileType.SoilProfile2D)] + public void Constructor_WithNameBottomLayersAndAquifer_ReturnsInstanceWithPropsAndEquivalentLayerCollection(SoilProfileType type) + { + // Setup + const string name = "Profile"; + var random = new Random(22); + double bottom = random.NextDouble(); + var layers = new Collection + { + new PipingSoilLayer(bottom) + }; + const long pipingSoilProfileId = 1234L; + + // Call + var profile = new PipingSoilProfile(name, bottom, layers, type, pipingSoilProfileId); + + // Assert + Assert.AreNotSame(layers, profile.Layers); + Assert.AreEqual(name, profile.Name); + Assert.AreEqual(bottom, profile.Bottom); + Assert.AreEqual(type, profile.SoilProfileType); + Assert.AreEqual(pipingSoilProfileId, profile.PipingSoilProfileId); + } + + [Test] + public void Constructor_WithNameBottomLayersEmpty_ThrowsArgumentException() + { + // Call + TestDelegate test = () => new PipingSoilProfile(string.Empty, double.NaN, new Collection(), SoilProfileType.SoilProfile1D, 0); + + // Assert + const string expectedMessage = "Geen lagen gevonden voor de ondergrondschematisatie."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + public void Constructor_WithNameBottomLayersNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new PipingSoilProfile(string.Empty, double.NaN, null, SoilProfileType.SoilProfile1D, 0); + + // Assert + const string expectedMessage = "Geen lagen gevonden voor de ondergrondschematisatie."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + [TestCase(1)] + [TestCase(5)] + [TestCase(15)] + public void Layers_Always_ReturnsDescendingByTopOrderedList(int layerCount) + { + // Setup + var random = new Random(21); + const double bottom = 0.0; + var equivalentLayers = new List(layerCount); + for (var i = 0; i < layerCount; i++) + { + equivalentLayers.Add(new PipingSoilLayer(random.NextDouble()) + { + IsAquifer = i == 0 + }); + } + + var profile = new PipingSoilProfile(string.Empty, bottom, equivalentLayers, SoilProfileType.SoilProfile1D, 0); + + // Call + PipingSoilLayer[] result = profile.Layers.ToArray(); + + // Assert + CollectionAssert.AreEquivalent(equivalentLayers, result); + CollectionAssert.AreEqual(equivalentLayers.OrderByDescending(l => l.Top).Select(l => l.Top), result.Select(l => l.Top)); + } + + [Test] + [TestCase(1e-6)] + [TestCase(4)] + public void Constructor_WithNameBottomLayersBelowBottom_ThrowsArgumentException(double deltaBelowBottom) + { + // Setup + const double bottom = 0.0; + var pipingSoilLayers = new[] + { + new PipingSoilLayer(bottom - deltaBelowBottom), + new PipingSoilLayer(1.1) + }; + + // Call + TestDelegate test = () => new PipingSoilProfile(string.Empty, bottom, pipingSoilLayers, SoilProfileType.SoilProfile1D, 0); + + // Assert + const string expectedMessage = "Eén of meerdere lagen hebben een top onder de bodem van de ondergrondschematisatie."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + [TestCase(0, 0)] + [TestCase(1, 1.1)] + public void GetLayerThickness_LayerInProfile_ReturnsThicknessOfLayer(int layerIndex, double expectedThickness) + { + // Setup + var pipingSoilLayers = new[] + { + new PipingSoilLayer(0.0), + new PipingSoilLayer(1.1) + }; + var profile = new PipingSoilProfile(string.Empty, 0.0, pipingSoilLayers, SoilProfileType.SoilProfile1D, 0); + + // Call + double thickness = profile.GetLayerThickness(pipingSoilLayers[layerIndex]); + + // Assert + Assert.AreEqual(expectedThickness, thickness); + } + + [Test] + public void GetLayerThickness_LayerNotInProfile_ThrowsArgumentException() + { + // Setup + var pipingSoilLayers = new[] + { + new PipingSoilLayer(0.0), + new PipingSoilLayer(1.1) + }; + var profile = new PipingSoilProfile(string.Empty, 0.0, pipingSoilLayers, SoilProfileType.SoilProfile1D, 0); + + // Call + TestDelegate test = () => profile.GetLayerThickness(new PipingSoilLayer(1.1)); + + // Assert + const string expectedMessage = "Layer not found in profile."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + public void ToString_WithNullName_ReturnsStringEmpty() + { + // Setup + var profile = new PipingSoilProfile(null, 0.0, new[] + { + new PipingSoilLayer(0.0) + }, SoilProfileType.SoilProfile1D, 0); + + // Call + string text = profile.ToString(); + + // Assert + Assert.IsEmpty(text); + } + + [Test] + [TestCase("")] + [TestCase("some name")] + public void ToString_WithName_ReturnsName(string name) + { + // Setup + var profile = new PipingSoilProfile(name, 0.0, new[] + { + new PipingSoilLayer(0.0) + }, SoilProfileType.SoilProfile1D, 0); + + // Call + string text = profile.ToString(); + + // Assert + Assert.AreEqual(name, text); + } + + [Test] + public void Equals_Null_ReturnsFalse() + { + // Setup + var profile = new PipingSoilProfile("name", 0, new[] + { + CreateRandomLayer(new Random(21)) + }, SoilProfileType.SoilProfile1D, -1); + + // Call + bool areEqual = profile.Equals(null); + + // Assert + Assert.IsFalse(areEqual); + } + + [Test] + [TestCaseSource(nameof(ProfileCombinations))] + public void Equals_DifferentScenarios_ReturnsExpectedResult(PipingSoilProfile profile, PipingSoilProfile otherProfile, bool expectedEqual) + { + // Call + bool areEqualOne = profile.Equals(otherProfile); + bool areEqualTwo = otherProfile.Equals(profile); + + // Assert + Assert.AreEqual(expectedEqual, areEqualOne); + Assert.AreEqual(expectedEqual, areEqualTwo); + } + + private static TestCaseData[] ProfileCombinations() + { + PipingSoilProfile profileA = CreateRandomProfile(21); + PipingSoilProfile profileB = CreateRandomProfile(21); + PipingSoilProfile profileC = CreateRandomProfile(73); + + PipingSoilProfile profileD = CreateSingleLayerProfile("A", -3, SoilProfileType.SoilProfile1D); + PipingSoilProfile profileE = CreateSingleLayerProfile("A", -3, SoilProfileType.SoilProfile2D); + PipingSoilProfile profileF = CreateSingleLayerProfile("A", -2, SoilProfileType.SoilProfile1D); + PipingSoilProfile profileG = CreateSingleLayerProfile("B", -3, SoilProfileType.SoilProfile1D); + + const int seed = 78; + var random = new Random(seed); + var profileH = new PipingSoilProfile(GetRandomName(random), -random.NextDouble(), new[] + { + CreateRandomLayer(random) + }, random.NextEnumValue(), random.Next()); + + random = new Random(seed); + var profileI = new PipingSoilProfile(GetRandomName(random), -random.NextDouble(), new[] + { + CreateRandomLayer(random), + CreateRandomLayer(random) + }, random.NextEnumValue(), random.Next()); + + var profileJ = new PipingSoilProfile("A", -3, new[] + { + new PipingSoilLayer(-2) + }, SoilProfileType.SoilProfile1D, 35); + var profileK = new PipingSoilProfile("A", -3, new[] + { + new PipingSoilLayer(-2) + }, SoilProfileType.SoilProfile1D, 56); + + return new[] + { + new TestCaseData(profileA, profileB, true) + { + TestName = "Equals_ProfileAProfileB_True" + }, + new TestCaseData(profileB, profileC, false) + { + TestName = "Equals_ProfileBProfileC_False" + }, + new TestCaseData(profileD, profileE, false) + { + TestName = "Equals_ProfileDProfileE_False" + }, + new TestCaseData(profileD, profileF, false) + { + TestName = "Equals_ProfileDProfileF_False" + }, + new TestCaseData(profileD, profileG, false) + { + TestName = "Equals_ProfileDProfileG_False" + }, + new TestCaseData(profileH, profileI, false) + { + TestName = "Equals_ProfileHProfileI_False" + }, + new TestCaseData(profileJ, profileK, true) + { + TestName = "Equals_DifferentIds_True" + } + }; + } + + private static PipingSoilProfile CreateSingleLayerProfile(string name, double bottom, SoilProfileType type) + { + return new PipingSoilProfile(name, bottom, new[] + { + new PipingSoilLayer(bottom + 1.0) + }, type, profileIdRandom.Next()); + } + + private static PipingSoilProfile CreateRandomProfile(int randomSeed) + { + var random = new Random(randomSeed); + var layers = new Collection(); + for (var i = 0; i < random.Next(2, 6); i++) + { + layers.Add(CreateRandomLayer(random)); + } + return new PipingSoilProfile(GetRandomName(random), -1.0 - random.NextDouble(), layers, random.NextEnumValue(), profileIdRandom.Next()); + } + + private static PipingSoilLayer CreateRandomLayer(Random random) + { + return new PipingSoilLayer(random.NextDouble()) + { + MaterialName = GetRandomName(random), + Color = Color.FromKnownColor(random.NextEnumValue()), + IsAquifer = random.NextBoolean(), + BelowPhreaticLevelDeviation = random.NextDouble(), + BelowPhreaticLevelMean = random.NextDouble(), + BelowPhreaticLevelShift = random.NextDouble(), + DiameterD70CoefficientOfVariation = random.NextDouble(), + DiameterD70Mean = random.NextDouble(), + PermeabilityCoefficientOfVariation = random.NextDouble(), + PermeabilityMean = random.NextDouble() + }; + } + + private static string GetRandomName(Random random) + { + return new string('x', random.Next(0, 40)); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/Ringtoets.Piping.Primitives.Test.csproj =================================================================== diff -u -r23d1e296e2da4364fbfe346e68d582dfcf966bb0 -r9caa7daa14d0070e2a3f68c4b9e66109318bd9ab --- Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/Ringtoets.Piping.Primitives.Test.csproj (.../Ringtoets.Piping.Primitives.Test.csproj) (revision 23d1e296e2da4364fbfe346e68d582dfcf966bb0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Primitives.Test/Ringtoets.Piping.Primitives.Test.csproj (.../Ringtoets.Piping.Primitives.Test.csproj) (revision 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab) @@ -41,20 +41,48 @@ MinimumRecommendedRules.ruleset + + ..\..\..\..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll + True + + Properties\GlobalAssembly.cs + + + + Copying.licenseheader + + + + {3BBFD65B-B277-4E50-AE6D-BD24C3434609} + Core.Common.Base + + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + + + {d4200f43-3f72-4f42-af0a-8ced416a38ec} + Ringtoets.Common.Data + + + {14C6F716-64E2-4BC4-A1EF-05865FCEFA4C} + Ringtoets.Piping.Primitives + + + + + \ No newline at end of file