Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsOutputCreateExtensionsTest.cs =================================================================== diff -u -r5276b5e82afd56701abd55dd098651fb9ac504e2 -rf6980957baa71e954fa585029b44c365c7dbf993 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsOutputCreateExtensionsTest.cs (.../MacroStabilityInwardsOutputCreateExtensionsTest.cs) (revision 5276b5e82afd56701abd55dd098651fb9ac504e2) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsOutputCreateExtensionsTest.cs (.../MacroStabilityInwardsOutputCreateExtensionsTest.cs) (revision f6980957baa71e954fa585029b44c365c7dbf993) @@ -23,13 +23,12 @@ using System.Collections.Generic; using Application.Ringtoets.Storage.Create.MacroStabilityInwards; using Application.Ringtoets.Storage.DbContext; -using Application.Ringtoets.Storage.Serializers; using Application.Ringtoets.Storage.TestUtil.MacroStabilityInwards; -using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.MacroStabilityInwards.Data; +using Ringtoets.MacroStabilityInwards.Data.TestUtil; namespace Application.Ringtoets.Storage.Test.Create.MacroStabilityInwards { @@ -55,7 +54,10 @@ MacroStabilityInwardsSlidingCircle leftCircle = CreateSlidingCircle(13); MacroStabilityInwardsSlidingCircle rightCircle = CreateSlidingCircle(34); - IEnumerable slices = CreateMacroStabilityInwardsSlices(); + IEnumerable slices = new[] + { + MacroStabilityInwardsSliceTestFactory.CreateSlice() + }; var slidingCurve = new MacroStabilityInwardsSlidingCurve(leftCircle, rightCircle, slices, @@ -75,7 +77,7 @@ FactorOfStability = random.NextDouble(), ForbiddenZonesXEntryMax = random.NextDouble(), ForbiddenZonesXEntryMin = random.NextDouble(), - ZValue = random.NextDouble(), + ZValue = random.NextDouble() }); // Call @@ -91,19 +93,15 @@ // Setup MacroStabilityInwardsSlidingCircle leftCircle = CreateSlidingCircleWithNaNValues(); MacroStabilityInwardsSlidingCircle rightCircle = CreateSlidingCircleWithNaNValues(); - IEnumerable slices = CreateMacroStabilityInwardsSlices(); var slidingCurve = new MacroStabilityInwardsSlidingCurve(leftCircle, rightCircle, - slices, + new MacroStabilityInwardsSlice[0], double.NaN, double.NaN); var slipPlane = new MacroStabilityInwardsSlipPlaneUpliftVan(new MacroStabilityInwardsGrid(), new MacroStabilityInwardsGrid(), - new[] - { - double.NaN - }); + new double[0]); var output = new MacroStabilityInwardsOutput(slidingCurve, slipPlane, new MacroStabilityInwardsOutput.ConstructionProperties()); @@ -157,51 +155,6 @@ double.NaN, double.NaN); } - - private static IEnumerable CreateMacroStabilityInwardsSlices() - { - var random = new Random(21); - return new[] - { - new MacroStabilityInwardsSlice(new Point2D(random.NextDouble(), random.NextDouble()), - new Point2D(random.NextDouble(), random.NextDouble()), - new Point2D(random.NextDouble(), random.NextDouble()), - new Point2D(random.NextDouble(), random.NextDouble()), - new MacroStabilityInwardsSlice.ConstructionProperties - { - Cohesion = random.NextDouble(), - FrictionAngle = random.NextDouble(), - CriticalPressure = random.NextDouble(), - OverConsolidationRatio = random.NextDouble(), - DegreeOfConsolidationPorePressureSoil = random.NextDouble(), - DegreeOfConsolidationPorePressureLoad = random.NextDouble(), - Pop = random.NextDouble(), - Dilatancy = random.NextDouble(), - ExternalLoad = random.NextDouble(), - HydrostaticPorePressure = random.NextDouble(), - LeftForce = random.NextDouble(), - LeftForceAngle = random.NextDouble(), - LeftForceY = random.NextDouble(), - RightForce = random.NextDouble(), - RightForceAngle = random.NextDouble(), - RightForceY = random.NextDouble(), - LoadStress = random.NextDouble(), - NormalStress = random.NextDouble(), - PorePressure = random.NextDouble(), - HorizontalPorePressure = random.NextDouble(), - VerticalPorePressure = random.NextDouble(), - PiezometricPorePressure = random.NextDouble(), - EffectiveStress = random.NextDouble(), - EffectiveStressDaily = random.NextDouble(), - ExcessPorePressure = random.NextDouble(), - ShearStress = random.NextDouble(), - SoilStress = random.NextDouble(), - TotalPorePressure = random.NextDouble(), - TotalStress = random.NextDouble() - }) - }; - } - #endregion } } \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensionsTest.cs =================================================================== diff -u -r5276b5e82afd56701abd55dd098651fb9ac504e2 -rf6980957baa71e954fa585029b44c365c7dbf993 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensionsTest.cs (.../MacroStabilityInwardsCalculationOutputEntityReadExtensionsTest.cs) (revision 5276b5e82afd56701abd55dd098651fb9ac504e2) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensionsTest.cs (.../MacroStabilityInwardsCalculationOutputEntityReadExtensionsTest.cs) (revision f6980957baa71e954fa585029b44c365c7dbf993) @@ -22,13 +22,13 @@ using System; using System.Collections.Generic; using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.Read.MacroStabilityInwards; using Application.Ringtoets.Storage.Serializers; using Application.Ringtoets.Storage.TestUtil.MacroStabilityInwards; -using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.MacroStabilityInwards.Data; -using Application.Ringtoets.Storage.Read.MacroStabilityInwards; +using Ringtoets.MacroStabilityInwards.Data.TestUtil; namespace Application.Ringtoets.Storage.Test.Read.MacroStabilityInwards { @@ -51,7 +51,10 @@ { // Setup var random = new Random(21); - IEnumerable slices = CreateMacroStabilityInwardsSlices(); + IEnumerable slices = new[] + { + MacroStabilityInwardsSliceTestFactory.CreateSlice() + }; IEnumerable tangentLines = new[] { random.NextDouble() @@ -132,7 +135,7 @@ }; // Call - TestDelegate call = ()=> entity.Read(); + TestDelegate call = () => entity.Read(); // Assert var exception = Assert.Throws(call); @@ -150,55 +153,11 @@ }; // Call - TestDelegate call = ()=> entity.Read(); + TestDelegate call = () => entity.Read(); // Assert var exception = Assert.Throws(call); Assert.AreEqual("xml", exception.ParamName); } - - private static IEnumerable CreateMacroStabilityInwardsSlices() - { - var random = new Random(21); - return new[] - { - new MacroStabilityInwardsSlice(new Point2D(random.NextDouble(), random.NextDouble()), - new Point2D(random.NextDouble(), random.NextDouble()), - new Point2D(random.NextDouble(), random.NextDouble()), - new Point2D(random.NextDouble(), random.NextDouble()), - new MacroStabilityInwardsSlice.ConstructionProperties - { - Cohesion = random.NextDouble(), - FrictionAngle = random.NextDouble(), - CriticalPressure = random.NextDouble(), - OverConsolidationRatio = random.NextDouble(), - DegreeOfConsolidationPorePressureSoil = random.NextDouble(), - DegreeOfConsolidationPorePressureLoad = random.NextDouble(), - Pop = random.NextDouble(), - Dilatancy = random.NextDouble(), - ExternalLoad = random.NextDouble(), - HydrostaticPorePressure = random.NextDouble(), - LeftForce = random.NextDouble(), - LeftForceAngle = random.NextDouble(), - LeftForceY = random.NextDouble(), - RightForce = random.NextDouble(), - RightForceAngle = random.NextDouble(), - RightForceY = random.NextDouble(), - LoadStress = random.NextDouble(), - NormalStress = random.NextDouble(), - PorePressure = random.NextDouble(), - HorizontalPorePressure = random.NextDouble(), - VerticalPorePressure = random.NextDouble(), - PiezometricPorePressure = random.NextDouble(), - EffectiveStress = random.NextDouble(), - EffectiveStressDaily = random.NextDouble(), - ExcessPorePressure = random.NextDouble(), - ShearStress = random.NextDouble(), - SoilStress = random.NextDouble(), - TotalPorePressure = random.NextDouble(), - TotalStress = random.NextDouble() - }) - }; - } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/MacroStabilityInwardsSliceTestFactoryTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/MacroStabilityInwardsSliceTestFactoryTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/MacroStabilityInwardsSliceTestFactoryTest.cs (revision f6980957baa71e954fa585029b44c365c7dbf993) @@ -0,0 +1,84 @@ +// 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 Core.Common.Base.Geometry; +using NUnit.Framework; + +namespace Ringtoets.MacroStabilityInwards.Data.TestUtil.Test +{ + [TestFixture] + public class MacroStabilityInwardsSliceTestFactoryTest + { + [Test] + public void CreateSlice_Always_ReturnsMacroStabilityInwardsSlice() + { + // Call + MacroStabilityInwardsSlice slice = MacroStabilityInwardsSliceTestFactory.CreateSlice(); + + // Assert + AssertPointIsConcreteValue(slice.TopLeftPoint); + AssertPointIsConcreteValue(slice.TopRightPoint); + AssertPointIsConcreteValue(slice.BottomLeftPoint); + AssertPointIsConcreteValue(slice.BottomRightPoint); + + AssertIsConcreteValue(slice.Cohesion); + AssertIsConcreteValue(slice.FrictionAngle); + AssertIsConcreteValue(slice.CriticalPressure); + AssertIsConcreteValue(slice.OverConsolidationRatio); + AssertIsConcreteValue(slice.Pop); + AssertIsConcreteValue(slice.DegreeOfConsolidationPorePressureSoil); + AssertIsConcreteValue(slice.DegreeOfConsolidationPorePressureLoad); + AssertIsConcreteValue(slice.Dilatancy); + AssertIsConcreteValue(slice.ExternalLoad); + AssertIsConcreteValue(slice.HydrostaticPorePressure); + AssertIsConcreteValue(slice.LeftForce); + AssertIsConcreteValue(slice.LeftForceAngle); + AssertIsConcreteValue(slice.RightForce); + AssertIsConcreteValue(slice.RightForceAngle); + AssertIsConcreteValue(slice.LoadStress); + AssertIsConcreteValue(slice.NormalStress); + AssertIsConcreteValue(slice.PorePressure); + AssertIsConcreteValue(slice.HorizontalPorePressure); + AssertIsConcreteValue(slice.VerticalPorePressure); + AssertIsConcreteValue(slice.PiezometricPorePressure); + AssertIsConcreteValue(slice.EffectiveStress); + AssertIsConcreteValue(slice.EffectiveStressDaily); + AssertIsConcreteValue(slice.ExcessPorePressure); + AssertIsConcreteValue(slice.ShearStress); + AssertIsConcreteValue(slice.SoilStress); + AssertIsConcreteValue(slice.TotalPorePressure); + AssertIsConcreteValue(slice.TotalStress); + AssertIsConcreteValue(slice.Weight); + } + + private static void AssertPointIsConcreteValue(Point2D actualPoint) + { + AssertIsConcreteValue(actualPoint.X); + AssertIsConcreteValue(actualPoint.Y); + } + + private static void AssertIsConcreteValue(double actualValue) + { + Assert.IsFalse(double.IsNaN(actualValue)); + Assert.IsFalse(double.IsInfinity(actualValue)); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test.csproj =================================================================== diff -u -r94fbe0ddb5936201eaffc5bab789a39ee7a245ef -rf6980957baa71e954fa585029b44c365c7dbf993 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.TestUtil.Test.csproj) (revision 94fbe0ddb5936201eaffc5bab789a39ee7a245ef) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.TestUtil.Test.csproj) (revision f6980957baa71e954fa585029b44c365c7dbf993) @@ -52,6 +52,7 @@ + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/MacroStabilityInwardsSliceTestFactory.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/MacroStabilityInwardsSliceTestFactory.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/MacroStabilityInwardsSliceTestFactory.cs (revision f6980957baa71e954fa585029b44c365c7dbf993) @@ -0,0 +1,80 @@ +// 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.Base.Geometry; + +namespace Ringtoets.MacroStabilityInwards.Data.TestUtil +{ + /// + /// Factory that creates instances of + /// that can be used for testing. + /// + public static class MacroStabilityInwardsSliceTestFactory + { + /// + /// Creates a with initialized values + /// for all properties. + /// + /// A . + public static MacroStabilityInwardsSlice CreateSlice() + { + var random = new Random(21); + return new MacroStabilityInwardsSlice(new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()), + new MacroStabilityInwardsSlice.ConstructionProperties + { + Cohesion = random.NextDouble(), + FrictionAngle = random.NextDouble(), + CriticalPressure = random.NextDouble(), + OverConsolidationRatio = random.NextDouble(), + DegreeOfConsolidationPorePressureSoil = random.NextDouble(), + DegreeOfConsolidationPorePressureLoad = random.NextDouble(), + Pop = random.NextDouble(), + Dilatancy = random.NextDouble(), + ExternalLoad = random.NextDouble(), + HydrostaticPorePressure = random.NextDouble(), + LeftForce = random.NextDouble(), + LeftForceAngle = random.NextDouble(), + LeftForceY = random.NextDouble(), + RightForce = random.NextDouble(), + RightForceAngle = random.NextDouble(), + RightForceY = random.NextDouble(), + LoadStress = random.NextDouble(), + NormalStress = random.NextDouble(), + PorePressure = random.NextDouble(), + HorizontalPorePressure = random.NextDouble(), + VerticalPorePressure = random.NextDouble(), + PiezometricPorePressure = random.NextDouble(), + EffectiveStress = random.NextDouble(), + EffectiveStressDaily = random.NextDouble(), + ExcessPorePressure = random.NextDouble(), + ShearStress = random.NextDouble(), + SoilStress = random.NextDouble(), + TotalPorePressure = random.NextDouble(), + TotalStress = random.NextDouble(), + Weight = random.NextDouble() + }); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/Ringtoets.MacroStabilityInwards.Data.TestUtil.csproj =================================================================== diff -u -r59adecfc7f82ab8277440ecae147453f5cbddbbf -rf6980957baa71e954fa585029b44c365c7dbf993 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/Ringtoets.MacroStabilityInwards.Data.TestUtil.csproj (.../Ringtoets.MacroStabilityInwards.Data.TestUtil.csproj) (revision 59adecfc7f82ab8277440ecae147453f5cbddbbf) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/Ringtoets.MacroStabilityInwards.Data.TestUtil.csproj (.../Ringtoets.MacroStabilityInwards.Data.TestUtil.csproj) (revision f6980957baa71e954fa585029b44c365c7dbf993) @@ -53,6 +53,7 @@ +