Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs =================================================================== diff -u -rd1c3ff0afd7217b6217372c6466d6d1a5428a491 -r931200ff0439f03dc9d02fceecaa8c28dca92290 --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs (.../UpliftVanCalculatorTest.cs) (revision d1c3ff0afd7217b6217372c6466d6d1a5428a491) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs (.../UpliftVanCalculatorTest.cs) (revision 931200ff0439f03dc9d02fceecaa8c28dca92290) @@ -25,6 +25,7 @@ using Core.Common.Base.Geometry; using Core.Common.TestUtil; using Deltares.MacroStability.CSharpWrapper; +using Deltares.MacroStability.CSharpWrapper.Input; using Deltares.MacroStability.CSharpWrapper.Output; using NUnit.Framework; using Rhino.Mocks; @@ -44,8 +45,11 @@ using Riskeer.MacroStabilityInwards.Primitives; using Point2D = Core.Common.Base.Geometry.Point2D; using SoilLayer = Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Input.SoilLayer; -using SoilProfile = Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Input.SoilProfile; using CSharpWrapperPoint2D = Deltares.MacroStability.CSharpWrapper.Point2D; +using CSharpWrapperSoilProfile = Deltares.MacroStability.CSharpWrapper.Input.SoilProfile; +using PreconsolidationStress = Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Input.PreconsolidationStress; +using SoilProfile = Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Input.SoilProfile; +using CSharpWrapperWaternet = Deltares.MacroStability.CSharpWrapper.Waternet; namespace Riskeer.MacroStabilityInwards.KernelWrapper.Test.Calculators.UpliftVan { @@ -131,29 +135,20 @@ { var factory = (TestMacroStabilityInwardsKernelFactory) MacroStabilityInwardsKernelWrapperFactory.Instance; UpliftVanKernelStub upliftVanKernel = factory.LastCreatedUpliftVanKernel; - upliftVanKernel.SetWaternetDaily(factory.CreateWaternetDailyKernel(UpliftVanWaternetCreatorInputCreator.CreateDaily(input)).Waternet); - upliftVanKernel.SetWaternetExtreme(factory.CreateWaternetExtremeKernel(UpliftVanWaternetCreatorInputCreator.CreateExtreme(input)).Waternet); + + LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary layerLookup); + SurfaceLine surfaceLine = SurfaceLineCreator.Create(input.SurfaceLine); + CSharpWrapperSoilProfile soilProfile = SoilProfileCreator.Create(layersWithSoil); + + CSharpWrapperWaternet waternetDaily = factory.CreateWaternetDailyKernel(MacroStabilityInputCreator.CreateDailyWaternetForUpliftVan(input, layersWithSoil, surfaceLine, soilProfile)).Waternet; + CSharpWrapperWaternet waternetExtreme = factory.CreateWaternetExtremeKernel(MacroStabilityInputCreator.CreateExtremeWaternetForUpliftVan(input, layersWithSoil, surfaceLine, soilProfile)).Waternet; SetValidKernelOutput(upliftVanKernel); // Call new UpliftVanCalculator(input, factory).Calculate(); // Assert - Assert.AreEqual(input.MoveGrid, upliftVanKernel.MoveGrid); - Assert.AreEqual(input.MaximumSliceWidth, upliftVanKernel.MaximumSliceWidth); - - LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary layerLookup); - - UpliftVanKernelInputAssert.AssertSlipPlanesUpliftVan(UpliftVanCalculationGridCreator.Create(input.SlipPlane), upliftVanKernel.SlipPlaneUpliftVan); - UpliftVanKernelInputAssert.AssertSlipPlaneConstraints(SlipPlaneConstraintsCreator.Create(input.SlipPlaneConstraints), upliftVanKernel.SlipPlaneConstraints); - KernelInputAssert.AssertSoilModels(layersWithSoil.Select(lws => lws.Soil).ToArray(), upliftVanKernel.SoilModel); - KernelInputAssert.AssertSoilProfiles(SoilProfileCreator.Create(layersWithSoil), upliftVanKernel.SoilProfile); - KernelInputAssert.AssertSurfaceLines(SurfaceLineCreator.Create(input.SurfaceLine), upliftVanKernel.SurfaceLine); - Assert.AreEqual(input.SlipPlane.GridAutomaticDetermined, upliftVanKernel.GridAutomaticDetermined); - Assert.AreEqual(input.SlipPlane.TangentLinesAutomaticAtBoundaries, upliftVanKernel.TangentLinesAutomaticDetermined); - CollectionAssert.AreEqual(FixedSoilStressCreator.Create(layerLookup), upliftVanKernel.SoilStresses, new FixedSoilStressComparer()); - CollectionAssert.AreEqual(PreconsolidationStressCreator.Create(input.SoilProfile.PreconsolidationStresses), upliftVanKernel.PreConsolidationStresses, new PreConsolidationStressComparer()); - Assert.AreEqual(input.SlipPlaneConstraints.AutomaticForbiddenZones, upliftVanKernel.AutomaticForbiddenZones); + UpliftVanKernelInputAssert.AssertMacroStabilityInput(MacroStabilityInputCreator.CreateUpliftVan(input, layersWithSoil, layerLookup, surfaceLine, soilProfile, waternetDaily, waternetExtreme), upliftVanKernel.KernelInput); } } Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/Input/UpliftVanKernelInputAssert.cs =================================================================== diff -u -r8d966c5fb542e363013c140c1dd9c9081c06feca -r931200ff0439f03dc9d02fceecaa8c28dca92290 --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/Input/UpliftVanKernelInputAssert.cs (.../UpliftVanKernelInputAssert.cs) (revision 8d966c5fb542e363013c140c1dd9c9081c06feca) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/Input/UpliftVanKernelInputAssert.cs (.../UpliftVanKernelInputAssert.cs) (revision 931200ff0439f03dc9d02fceecaa8c28dca92290) @@ -19,6 +19,10 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Collections.Generic; +using System.Linq; +using Deltares.MacroStability.CSharpWrapper; +using Deltares.MacroStability.CSharpWrapper.Input; using Deltares.MacroStability.Data; using NUnit.Framework; @@ -32,15 +36,91 @@ /// /// Asserts whether is equal to . /// + /// The expected . + /// The actual . + /// Thrown when + /// is not equal to . + public static void AssertMacroStabilityInput(MacroStabilityInput expected, MacroStabilityInput actual) + { + AssertStabilityInput(expected.StabilityModel, actual.StabilityModel); + AssertPreprocessingInput(expected.PreprocessingInput, actual.PreprocessingInput); + } + + /// + /// Asserts whether is equal to . + /// + /// The expected . + /// The actual . + /// Thrown when + /// is not equal to . + private static void AssertStabilityInput(StabilityInput expected, StabilityInput actual) + { + Assert.AreEqual(expected.Orientation, actual.Orientation); + Assert.AreEqual(expected.SearchAlgorithm, actual.SearchAlgorithm); + Assert.AreEqual(expected.ModelOption, actual.ModelOption); + + AssertConstructionStages(expected.ConstructionStages, actual.ConstructionStages); + + CollectionAssert.AreEqual(expected.Soils, actual.Soils); + Assert.AreEqual(expected.MoveGrid, actual.MoveGrid); + Assert.AreEqual(expected.MaximumSliceWidth, actual.MaximumSliceWidth); + + AssertUpliftVanCalculationGrid(expected.UpliftVanCalculationGrid, actual.UpliftVanCalculationGrid); + AssertSlipPlaneConstraints(expected.SlipPlaneConstraints, actual.SlipPlaneConstraints); + } + + /// + /// Asserts whether is equal to . + /// + /// The expected collection of . + /// The actual collection of . + /// Thrown when + /// is not equal to . + private static void AssertConstructionStages(ICollection expected, ICollection actual) + { + Assert.AreEqual(expected.Count, actual.Count); + + for (var i = 0; i < expected.Count; i++) + { + ConstructionStage expectedConstructionStage = expected.ElementAt(i); + ConstructionStage actualConstructionStage = actual.ElementAt(i); + + Assert.AreEqual(expectedConstructionStage.SoilProfile, actualConstructionStage.SoilProfile); + Assert.AreEqual(expectedConstructionStage.Waternet, actualConstructionStage.Waternet); + CollectionAssert.AreEqual(expectedConstructionStage.FixedSoilStresses, actualConstructionStage.FixedSoilStresses); + CollectionAssert.AreEqual(expectedConstructionStage.PreconsolidationStresses, actualConstructionStage.PreconsolidationStresses); + + AssertMultiplicationFactorsCPhiForUplift(expectedConstructionStage.MultiplicationFactorsCPhiForUplift.Single(), + actualConstructionStage.MultiplicationFactorsCPhiForUplift.Single()); + } + } + + /// + /// Asserts whether is equal to . + /// + /// The expected . + /// The actual . + /// Thrown when + /// is not equal to . + private static void AssertMultiplicationFactorsCPhiForUplift(MultiplicationFactorsCPhiForUplift expected, + MultiplicationFactorsCPhiForUplift actual) + { + Assert.AreEqual(expected.MultiplicationFactor, actual.MultiplicationFactor); + Assert.AreEqual(expected.UpliftFactor, actual.UpliftFactor); + } + + /// + /// Asserts whether is equal to . + /// /// The expected . /// The actual . /// Thrown when /// is not equal to . - public static void AssertSlipPlanesUpliftVan(SlipPlaneUpliftVan expected, SlipPlaneUpliftVan actual) + private static void AssertUpliftVanCalculationGrid(UpliftVanCalculationGrid expected, UpliftVanCalculationGrid actual) { - AssertSlipCircleGrid(expected.SlipPlaneLeftGrid, actual.SlipPlaneLeftGrid); - AssertSlipCircleGrid(expected.SlipPlaneRightGrid, actual.SlipPlaneRightGrid); - AssertSlipCircleTangentLine(expected.SlipCircleTangentLine, actual.SlipCircleTangentLine); + AssertCalculationGrid(expected.LeftGrid, actual.LeftGrid); + AssertCalculationGrid(expected.RightGrid, actual.RightGrid); + CollectionAssert.AreEqual(expected.TangentLines, actual.TangentLines); } /// @@ -50,12 +130,12 @@ /// The actual . /// Thrown when /// is not equal to . - public static void AssertSlipPlaneConstraints(SlipPlaneConstraints expected, SlipPlaneConstraints actual) + private static void AssertSlipPlaneConstraints(SlipPlaneConstraints expected, SlipPlaneConstraints actual) { Assert.AreEqual(expected.SlipPlaneMinDepth, actual.SlipPlaneMinDepth); Assert.AreEqual(expected.SlipPlaneMinLength, actual.SlipPlaneMinLength); - Assert.AreEqual(expected.XLeftMin, actual.XLeftMin); - Assert.AreEqual(expected.XLeftMax, actual.XLeftMax); + Assert.AreEqual(expected.XEntryMin, actual.XEntryMin); + Assert.AreEqual(expected.XEntryMax, actual.XEntryMax); } /// @@ -65,7 +145,7 @@ /// The actual . /// Thrown when /// is not equal to . - private static void AssertSlipCircleGrid(SlipCircleGrid expected, SlipCircleGrid actual) + private static void AssertCalculationGrid(CalculationGrid expected, CalculationGrid actual) { Assert.AreEqual(expected.GridXLeft, actual.GridXLeft); Assert.AreEqual(expected.GridXRight, actual.GridXRight); @@ -78,15 +158,46 @@ /// /// Asserts whether is equal to . /// - /// The expected . - /// The actual . + /// The expected . + /// The actual . /// Thrown when /// is not equal to . - private static void AssertSlipCircleTangentLine(SlipCircleTangentLine expected, SlipCircleTangentLine actual) + private static void AssertPreprocessingInput(PreprocessingInput expected, PreprocessingInput actual) { - Assert.AreEqual(expected.TangentLineZTop, actual.TangentLineZTop); - Assert.AreEqual(expected.TangentLineZBottom, actual.TangentLineZBottom); - Assert.AreEqual(expected.TangentLineNumber, actual.TangentLineNumber); + SearchAreaConditions expectedSearchAreaConditions = expected.SearchAreaConditions; + SearchAreaConditions actualSearchAreaConditions = actual.SearchAreaConditions; + + Assert.AreEqual(expectedSearchAreaConditions.MaxSpacingBetweenBoundaries, actualSearchAreaConditions.MaxSpacingBetweenBoundaries); + Assert.AreEqual(expectedSearchAreaConditions.OnlyAbovePleistoceen, actualSearchAreaConditions.OnlyAbovePleistoceen); + Assert.AreEqual(expectedSearchAreaConditions.AutoSearchArea, actualSearchAreaConditions.AutoSearchArea); + Assert.AreEqual(expectedSearchAreaConditions.AutoTangentLines, actualSearchAreaConditions.AutoTangentLines); + Assert.AreEqual(expectedSearchAreaConditions.AutomaticForbiddenZones, actualSearchAreaConditions.AutomaticForbiddenZones); + Assert.AreEqual(expectedSearchAreaConditions.TangentLineNumber, actualSearchAreaConditions.TangentLineNumber); + Assert.AreEqual(expectedSearchAreaConditions.TangentLineZTop, actualSearchAreaConditions.TangentLineZTop); + Assert.AreEqual(expectedSearchAreaConditions.TangentLineZBottom, actualSearchAreaConditions.TangentLineZBottom); + + AssertPreConstructionStages(expected.PreConstructionStages, actual.PreConstructionStages); } + + /// + /// Asserts whether is equal to . + /// + /// The expected collection of . + /// The actual collection of . + /// Thrown when + /// is not equal to . + private static void AssertPreConstructionStages(ICollection expected, ICollection actual) + { + Assert.AreEqual(expected.Count, actual.Count); + + for (int i = 0; i < expected.Count; i++) + { + PreConstructionStage expectedPreConstructionStage = expected.ElementAt(i); + PreConstructionStage actualPreConstructionStage = actual.ElementAt(i); + + Assert.AreEqual(expectedPreConstructionStage.WaternetCreationMode, actualPreConstructionStage.WaternetCreationMode); + Assert.AreEqual(expectedPreConstructionStage.SurfaceLine, actualPreConstructionStage.SurfaceLine); + } + } } } \ No newline at end of file