// 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.Linq; using Deltares.WTIStability; using Deltares.WTIStability.Data.Geo; using NUnit.Framework; namespace Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Kernels.UpliftVan.Input { /// /// Class for asserting kernel input. /// public static class KernelInputAssert { /// /// Asserts whether is equal to . /// /// The expected . /// The actual . /// Thrown when /// is not equal to . public static void AssertSoilModels(SoilModel expected, SoilModel actual) { Assert.AreEqual(expected.Soils.Count, actual.Soils.Count); for (var i = 0; i < expected.Soils.Count; i++) { AssertSoils(expected.Soils[i], actual.Soils[i]); } } /// /// Asserts whether is equal to . /// /// The expected . /// The actual . /// Thrown when /// is not equal to . public static void AssertSoilProfiles(SoilProfile2D expected, SoilProfile2D actual) { AssertSoilLayers(expected.Surfaces.ToArray(), actual.Surfaces.ToArray()); AssertPreconsolidationStresses(expected.PreconsolidationStresses.ToArray(), actual.PreconsolidationStresses.ToArray()); AssertGeometryDatas(expected.Geometry, actual.Geometry); } /// /// Asserts whether is equal to . /// /// The expected . /// The actual . /// Thrown when /// is not equal to . public static void AssertStabilityLocations(StabilityLocation expected, StabilityLocation actual) { Assert.AreEqual(expected.DikeSoilScenario, actual.DikeSoilScenario); Assert.AreEqual(expected.WaternetCreationMode, actual.WaternetCreationMode); Assert.AreEqual(expected.PlLineCreationMethod, actual.PlLineCreationMethod); Assert.AreEqual(expected.WaterLevelRiver, actual.WaterLevelRiver); Assert.AreEqual(expected.WaterLevelRiverAverage, actual.WaterLevelRiverAverage); Assert.AreEqual(expected.WaterLevelPolder, actual.WaterLevelPolder); Assert.AreEqual(expected.WaterLevelRiverLow, actual.WaterLevelRiverLow); Assert.AreEqual(expected.DrainageConstructionPresent, actual.DrainageConstructionPresent); Assert.AreEqual(expected.XCoordMiddleDrainageConstruction, actual.XCoordMiddleDrainageConstruction); Assert.AreEqual(expected.ZCoordMiddleDrainageConstruction, actual.ZCoordMiddleDrainageConstruction); Assert.AreEqual(expected.MinimumLevelPhreaticLineAtDikeTopRiver, actual.MinimumLevelPhreaticLineAtDikeTopRiver); Assert.AreEqual(expected.MinimumLevelPhreaticLineAtDikeTopPolder, actual.MinimumLevelPhreaticLineAtDikeTopPolder); Assert.AreEqual(expected.UseDefaultOffsets, actual.UseDefaultOffsets); Assert.AreEqual(expected.PlLineOffsetBelowPointBRingtoetsWti2017, actual.PlLineOffsetBelowPointBRingtoetsWti2017); Assert.AreEqual(expected.PlLineOffsetBelowDikeTopAtPolder, actual.PlLineOffsetBelowDikeTopAtPolder); Assert.AreEqual(expected.PlLineOffsetBelowShoulderBaseInside, actual.PlLineOffsetBelowShoulderBaseInside); Assert.AreEqual(expected.PlLineOffsetBelowDikeToeAtPolder, actual.PlLineOffsetBelowDikeToeAtPolder); Assert.AreEqual(expected.HeadInPlLine2Outwards, actual.HeadInPlLine2Outwards); Assert.AreEqual(expected.HeadInPlLine2Inwards, actual.HeadInPlLine2Inwards); Assert.AreEqual(expected.AdjustPl3And4ForUplift, actual.AdjustPl3And4ForUplift); Assert.AreEqual(expected.PenetrationLength, actual.PenetrationLength); Assert.AreEqual(expected.LeakageLengthOutwardsPl3, actual.LeakageLengthOutwardsPl3); Assert.AreEqual(expected.LeakageLengthInwardsPl3, actual.LeakageLengthInwardsPl3); Assert.AreEqual(expected.LeakageLengthOutwardsPl4, actual.LeakageLengthOutwardsPl4); Assert.AreEqual(expected.LeakageLengthInwardsPl4, actual.LeakageLengthInwardsPl4); } /// /// Asserts whether is equal to . /// /// The expected . /// The actual . /// Thrown when /// is not equal to . public static void AssertSurfaceLines(SurfaceLine2 expected, SurfaceLine2 actual) { Assert.AreEqual(expected.Name, actual.Name); Assert.AreEqual(expected.LandwardDirection, actual.LandwardDirection); AssertGeometryPointStrings(expected.Geometry, actual.Geometry); AssertCharacteristicPointSets(expected.CharacteristicPoints, actual.CharacteristicPoints); } /// /// Asserts whether is equal to . /// /// The expected array. /// The actual array. /// Thrown when /// is not equal to . private static void AssertSoilLayers(SoilLayer2D[] expected, SoilLayer2D[] actual) { Assert.AreEqual(expected.Length, actual.Length); for (var i = 0; i < expected.Length; i++) { SoilLayer2D expectedSurface = expected[i]; SoilLayer2D actualSurface = actual[i]; Assert.AreEqual(expectedSurface.IsAquifer, actualSurface.IsAquifer); AssertGeometrySurfaces(expectedSurface.GeometrySurface, actualSurface.GeometrySurface); AssertSoils(expectedSurface.Soil, actualSurface.Soil); Assert.AreEqual(expectedSurface.WaterpressureInterpolationModel, actualSurface.WaterpressureInterpolationModel); } } /// /// Asserts whether is equal to . /// /// The expected array. /// The actual array. /// Thrown when /// is not equal to . private static void AssertPreconsolidationStresses(PreConsolidationStress[] expected, PreConsolidationStress[] actual) { Assert.AreEqual(expected.Length, actual.Length); for (var i = 0; i < expected.Length; i++) { PreConsolidationStress expectedPreconsolidationStress = expected[i]; PreConsolidationStress actualPreconsolidationStress = actual[i]; Assert.AreEqual(expectedPreconsolidationStress.StressValue, actualPreconsolidationStress.StressValue); Assert.AreEqual(expectedPreconsolidationStress.X, actualPreconsolidationStress.X); Assert.AreEqual(expectedPreconsolidationStress.Z, actualPreconsolidationStress.Z); } } /// /// Asserts whether is equal to . /// /// The expected . /// The actual . /// Thrown when /// is not equal to . private static void AssertGeometrySurfaces(GeometrySurface expected, GeometrySurface actual) { CollectionAssert.AreEqual(new[] { expected.OuterLoop }.Concat(expected.InnerLoops), new[] { actual.OuterLoop }.Concat(actual.InnerLoops), new GeometryLoopComparer()); } /// /// Asserts whether is equal to . /// /// The expected . /// The actual . /// Thrown when /// is not equal to . private static void AssertSoils(Soil expected, Soil actual) { Assert.AreEqual(expected.Name, actual.Name); Assert.AreEqual(expected.UsePop, actual.UsePop); Assert.AreEqual(expected.ShearStrengthModel, actual.ShearStrengthModel); Assert.AreEqual(expected.AbovePhreaticLevel, actual.AbovePhreaticLevel); Assert.AreEqual(expected.BelowPhreaticLevel, actual.BelowPhreaticLevel); Assert.AreEqual(expected.Cohesion, actual.Cohesion); Assert.AreEqual(expected.FrictionAngle, actual.FrictionAngle); Assert.AreEqual(expected.RatioCuPc, actual.RatioCuPc); Assert.AreEqual(expected.StrengthIncreaseExponent, actual.StrengthIncreaseExponent); Assert.AreEqual(expected.PoP, actual.PoP); Assert.AreEqual(expected.DilatancyType, actual.DilatancyType); } /// /// Asserts whether is equal to . /// /// The expected . /// The actual . /// Thrown when /// is not equal to . private static void AssertGeometryDatas(GeometryData expected, GeometryData actual) { AssertGeometrySurfaces(expected.Surfaces.ToArray(), actual.Surfaces.ToArray()); CollectionAssert.AreEqual(expected.Loops, actual.Loops, new GeometryLoopComparer()); CollectionAssert.AreEqual(expected.Curves, actual.Curves, new GeometryCurveComparer()); CollectionAssert.AreEqual(expected.Points, actual.Points, new StabilityPointComparer()); Assert.AreEqual(expected.Bottom, actual.Bottom); Assert.AreEqual(expected.Left, actual.Left); Assert.AreEqual(expected.Right, actual.Right); } /// /// Asserts whether is equal to . /// /// The expected array. /// The actual array. /// Thrown when /// is not equal to . private static void AssertGeometrySurfaces(GeometrySurface[] expected, GeometrySurface[] actual) { Assert.AreEqual(expected.Length, actual.Length); for (var i = 0; i < expected.Length; i++) { AssertGeometrySurfaces(expected[i], actual[i]); } } /// /// Asserts whether is equal to . /// /// The expected . /// The actual . /// Thrown when /// is not equal to . private static void AssertCharacteristicPointSets(CharacteristicPointSet expected, CharacteristicPointSet actual) { Assert.AreEqual(expected.Count, actual.Count); for (var i = 0; i < expected.Count; i++) { CharacteristicPoint expectedCharacteristicPoint = expected[i]; CharacteristicPoint actualCharacteristicPoint = actual[i]; AssertGeometryPoints(expectedCharacteristicPoint.GeometryPoint, actualCharacteristicPoint.GeometryPoint); Assert.AreEqual(expectedCharacteristicPoint.CharacteristicPointType, actualCharacteristicPoint.CharacteristicPointType); } } /// /// Asserts whether is equal to . /// /// The expected . /// The actual . /// Thrown when /// is not equal to . private static void AssertGeometryPointStrings(GeometryPointString expected, GeometryPointString actual) { Assert.AreEqual(expected.Points.Count, actual.Points.Count); for (var i = 0; i < expected.Points.Count; i++) { AssertGeometryPoints(expected.Points[i], actual.Points[i]); } } /// /// Asserts whether is equal to . /// /// The expected . /// The actual . /// Thrown when /// is not equal to . private static void AssertGeometryPoints(GeometryPoint expected, GeometryPoint actual) { Assert.AreEqual(expected.X, actual.X); Assert.AreEqual(expected.Z, actual.Z); } } }