Fisheye: Tag daa6b36fc2506683c50ba4117790452ae4f45d7f refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingSoilLayerTransformer.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag daa6b36fc2506683c50ba4117790452ae4f45d7f refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingSoilProfileTransformer.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag daa6b36fc2506683c50ba4117790452ae4f45d7f refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingStochasticSoilModelFilter.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag daa6b36fc2506683c50ba4117790452ae4f45d7f refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingStochasticSoilModelTransformer.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag daa6b36fc2506683c50ba4117790452ae4f45d7f refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingStochasticSoilProfileTransformer.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag daa6b36fc2506683c50ba4117790452ae4f45d7f refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingSurfaceLineExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag daa6b36fc2506683c50ba4117790452ae4f45d7f refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingSurfaceLineTransformer.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj =================================================================== diff -u -r17e4a03119d9331cfcbe5b2e3e3255d7d05b74bb -rdaa6b36fc2506683c50ba4117790452ae4f45d7f --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 17e4a03119d9331cfcbe5b2e3e3255d7d05b74bb) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -40,13 +40,13 @@ - - - - - - - + + + + + + + True True Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -0,0 +1,254 @@ +// 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.Linq; +using Core.Common.Base.Geometry; +using Ringtoets.Common.IO.Exceptions; +using Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Piping.IO.Properties; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.IO.SoilProfiles +{ + /// + /// Transforms generic into . + /// + public static class PipingSoilLayerTransformer + { + /// + /// Transforms the generic into a mechanism specific + /// soil profile of type . + /// + /// The soil layer to use in the transformation. + /// A new based on the given data. + /// Thrown when is null. + /// Thrown when transformation would not result + /// in a valid transformed instance. + public static PipingSoilLayer Transform(SoilLayer1D soilLayer) + { + if (soilLayer == null) + { + throw new ArgumentNullException(nameof(soilLayer)); + } + + ValidateStochasticParametersForPiping(soilLayer); + + var pipingSoilLayer = new PipingSoilLayer(soilLayer.Top) + { + IsAquifer = soilLayer.IsAquifer, + MaterialName = soilLayer.MaterialName, + Color = soilLayer.Color + }; + + SetOptionalStochasticParameters(pipingSoilLayer, soilLayer); + + return pipingSoilLayer; + } + + public static IEnumerable Transform(SoilLayer2D soilLayer, double atX, out double bottom) + { + if (soilLayer == null) + { + throw new ArgumentNullException(nameof(soilLayer)); + } + + ValidateStochasticParametersForPiping(soilLayer); + + bottom = double.MaxValue; + + if (soilLayer.OuterLoop == null) + { + return Enumerable.Empty(); + } + + double[] outerLoopIntersectionHeights = GetLoopIntersectionHeights(soilLayer.OuterLoop, atX).ToArray(); + + if (!outerLoopIntersectionHeights.Any()) + { + return Enumerable.Empty(); + } + + var soilLayers = new Collection(); + IEnumerable> innerLoopsIntersectionHeights = soilLayer.InnerLoops.Select(loop => GetLoopIntersectionHeights(loop, atX)); + IEnumerable> innerLoopIntersectionHeightPairs = GetOrderedStartAndEndPairsIn1D(innerLoopsIntersectionHeights).ToList(); + IEnumerable> outerLoopIntersectionHeightPairs = GetOrderedStartAndEndPairsIn1D(outerLoopIntersectionHeights).ToList(); + + double currentBottom = outerLoopIntersectionHeightPairs.First().Item1; + var heights = new List(); + heights.AddRange(innerLoopIntersectionHeightPairs.Where(p => p.Item1 >= currentBottom).Select(p => p.Item1)); + heights.AddRange(outerLoopIntersectionHeightPairs.Select(p => p.Item2)); + + foreach (double height in heights.Where(height => !innerLoopIntersectionHeightPairs.Any(tuple => HeightInInnerLoop(tuple, height)))) + { + var pipingSoilLayer = new PipingSoilLayer(height) + { + IsAquifer = soilLayer.IsAquifer, + MaterialName = soilLayer.MaterialName, + Color = soilLayer.Color + }; + + SetOptionalStochasticParameters(pipingSoilLayer, soilLayer); + + soilLayers.Add(pipingSoilLayer); + } + bottom = EnsureBottomOutsideInnerLoop(innerLoopIntersectionHeightPairs, currentBottom); + return soilLayers; + } + + /// + /// Validates whether the values of the distribution and shift for the stochastic parameters + /// are correct for creating a . + /// + /// Thrown when any of the distributions of the + /// stochastic parameters is not defined as lognormal or is shifted when it should not be. + private static void ValidateStochasticParametersForPiping(SoilLayerBase soilLayer1D) + { + ValidateIsLogNormal( + soilLayer1D.BelowPhreaticLevelDistribution, + Resources.SoilLayer_BelowPhreaticLevelDistribution_Description); + ValidateIsNonShiftedLogNormal( + soilLayer1D.DiameterD70Distribution, + soilLayer1D.DiameterD70Shift, + Resources.SoilLayer_DiameterD70Distribution_Description); + ValidateIsNonShiftedLogNormal( + soilLayer1D.PermeabilityDistribution, + soilLayer1D.PermeabilityShift, + Resources.SoilLayer_PermeabilityDistribution_Description); + } + + /// + /// Sets the values of the optional stochastic parameters for the given . + /// + /// The to set the property values for. + /// The to get the properties from. + /// This method does not perform validation. Use to + /// verify whether the distributions for the stochastic parameters are correctly defined. + private static void SetOptionalStochasticParameters(PipingSoilLayer pipingSoilLayer, SoilLayerBase soilLayer1D) + { + pipingSoilLayer.BelowPhreaticLevelMean = soilLayer1D.BelowPhreaticLevelMean; + pipingSoilLayer.BelowPhreaticLevelDeviation = soilLayer1D.BelowPhreaticLevelDeviation; + pipingSoilLayer.BelowPhreaticLevelShift = soilLayer1D.BelowPhreaticLevelShift; + pipingSoilLayer.DiameterD70Mean = soilLayer1D.DiameterD70Mean; + pipingSoilLayer.DiameterD70CoefficientOfVariation = soilLayer1D.DiameterD70CoefficientOfVariation; + pipingSoilLayer.PermeabilityMean = soilLayer1D.PermeabilityMean; + pipingSoilLayer.PermeabilityCoefficientOfVariation = soilLayer1D.PermeabilityCoefficientOfVariation; + } + + private static void ValidateIsNonShiftedLogNormal(long? distribution, double shift, string incorrectDistibutionParameter) + { + if (distribution.HasValue && (distribution != SoilLayerConstants.LogNormalDistributionValue || shift != 0.0)) + { + throw new ImportedDataTransformException(string.Format( + Resources.SoilLayer_Stochastic_parameter_0_has_no_lognormal_distribution, + incorrectDistibutionParameter)); + } + } + + private static void ValidateIsLogNormal(long? distribution, string incorrectDistibutionParameter) + { + if (distribution.HasValue && distribution != SoilLayerConstants.LogNormalDistributionValue) + { + throw new ImportedDataTransformException(string.Format( + Resources.SoilLayer_Stochastic_parameter_0_has_no_shifted_lognormal_distribution, + incorrectDistibutionParameter)); + } + } + + private static bool HeightInInnerLoop(Tuple tuple, double height) + { + return height <= tuple.Item2 && height > tuple.Item1; + } + + private static bool BottomInInnerLoop(Tuple tuple, double height) + { + return height < tuple.Item2 && height >= tuple.Item1; + } + + private static double EnsureBottomOutsideInnerLoop(IEnumerable> innerLoopIntersectionHeightPairs, double bottom) + { + double newBottom = bottom; + List> heightPairArray = innerLoopIntersectionHeightPairs.ToList(); + Tuple overlappingInnerLoop = heightPairArray.FirstOrDefault(t => BottomInInnerLoop(t, newBottom)); + + while (overlappingInnerLoop != null) + { + newBottom = overlappingInnerLoop.Item2; + overlappingInnerLoop = heightPairArray.FirstOrDefault(t => BottomInInnerLoop(t, newBottom)); + } + return newBottom; + } + + private static IEnumerable> GetOrderedStartAndEndPairsIn1D(IEnumerable> innerLoopsIntersectionPoints) + { + var result = new Collection>(); + foreach (IEnumerable innerLoopIntersectionPoints in innerLoopsIntersectionPoints) + { + foreach (Tuple tuple in GetOrderedStartAndEndPairsIn1D(innerLoopIntersectionPoints)) + { + result.Add(tuple); + } + } + return result; + } + + private static Collection> GetOrderedStartAndEndPairsIn1D(IEnumerable innerLoopIntersectionPoints) + { + var result = new Collection>(); + List orderedHeights = innerLoopIntersectionPoints.OrderBy(v => v).ToList(); + for (var i = 0; i < orderedHeights.Count; i = i + 2) + { + double first = orderedHeights[i]; + double second = orderedHeights[i + 1]; + result.Add(Tuple.Create(first, second)); + } + return result; + } + + /// + /// Gets a of heights where the intersects the + /// vertical line at . + /// + /// The sequence of which together create a loop. + /// The point on the x-axis where the vertical line is constructed do determine intersections with. + /// A of , representing the height at which the + /// intersects the vertical line at . + /// Thrown when a segment is vertical at and thus + /// no deterministic intersection points can be determined. + private static IEnumerable GetLoopIntersectionHeights(IEnumerable loop, double atX) + { + Segment2D[] segment2Ds = loop.ToArray(); + if (segment2Ds.Any(segment => IsVerticalAtX(segment, atX))) + { + string message = string.Format(Resources.Error_Can_not_determine_1D_profile_with_vertical_segments_at_X_0_, atX); + throw new ImportedDataTransformException(message); + } + return Math2D.SegmentsIntersectionWithVerticalLine(segment2Ds, atX).Select(p => p.Y); + } + + private static bool IsVerticalAtX(Segment2D segment, double atX) + { + return segment.FirstPoint.X.Equals(atX) && segment.IsVertical(); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilProfileTransformer.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilProfileTransformer.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilProfileTransformer.cs (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -0,0 +1,121 @@ +// 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.Linq; +using Ringtoets.Common.IO.Exceptions; +using Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Piping.IO.Properties; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.IO.SoilProfiles +{ + /// + /// Transforms generic into . + /// + public static class PipingSoilProfileTransformer + { + /// + /// Transforms the generic into a mechanism specific + /// soil profile of type . + /// + /// The soil profile to use in the transformation. + /// A new based on the given data. + /// Thrown when is null. + /// Thrown when transformation would not result + /// in a valid transformed instance. + public static PipingSoilProfile Transform(ISoilProfile soilProfile) + { + if (soilProfile == null) + { + throw new ArgumentNullException(nameof(soilProfile)); + } + + var soilProfile1D = soilProfile as SoilProfile1D; + if (soilProfile1D != null) + { + return CreatePipingSoilProfile(soilProfile1D); + } + + var soilProfile2D = soilProfile as SoilProfile2D; + if (soilProfile2D != null) + { + return CreatePipingSoilProfile(soilProfile2D); + } + + string message = string.Format(Resources.PipingSoilProfileTransformer_Cannot_tranform_Type_0_Only_types_Type_1_and_Type_2_are_supported, + soilProfile.GetType().Name, + nameof(SoilProfile1D), + nameof(SoilProfile2D)); + throw new ImportedDataTransformException(message); + } + + /// + /// Creates a new instances of the based on the . + /// + /// The soil profile to use in the transformation. + /// The created . + /// Thrown when: + /// + /// The can not be used to determine intersections with; + /// Transforming the failed. + /// + /// + private static PipingSoilProfile CreatePipingSoilProfile(SoilProfile2D soilProfile2D) + { + string profileName = soilProfile2D.Name; + double intersectionX = soilProfile2D.IntersectionX; + + if (double.IsNaN(intersectionX)) + { + string message = string.Format(Resources.Error_SoilProfileBuilder_cant_determine_intersect_SoilProfileName_0_at_double_NaN, + profileName); + throw new ImportedDataTransformException(message); + } + + var layers = new List(); + double bottom = double.MaxValue; + foreach (SoilLayer2D soilLayer2D in soilProfile2D.Layers) + { + double newBottom; + + layers.AddRange(PipingSoilLayerTransformer.Transform(soilLayer2D, + intersectionX, + out newBottom)); + + bottom = Math.Min(bottom, newBottom); + } + + return new PipingSoilProfile(profileName, bottom, layers, SoilProfileType.SoilProfile2D); + } + + private static PipingSoilProfile CreatePipingSoilProfile(SoilProfile1D soilProfile1D) + { + IEnumerable layers = soilProfile1D.Layers.Select(PipingSoilLayerTransformer.Transform); + + return new PipingSoilProfile(soilProfile1D.Name, + soilProfile1D.Bottom, + layers.ToArray(), + SoilProfileType.SoilProfile1D); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelFilter.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelFilter.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelFilter.cs (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -0,0 +1,43 @@ +// 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 Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Common.IO.SoilProfile.Schema; + +namespace Ringtoets.Piping.IO.SoilProfiles +{ + /// + /// Class to that can be used to filter stochastic soil models for the piping failure mechanism. + /// + public class PipingStochasticSoilModelFilter : IStochasticSoilModelMechanismFilter + { + public bool IsValidForFailureMechanism(StochasticSoilModel stochasticSoilModel) + { + if (stochasticSoilModel == null) + { + throw new ArgumentNullException(nameof(stochasticSoilModel)); + } + + return stochasticSoilModel.FailureMechanismType == FailureMechanismType.Piping; + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelTransformer.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelTransformer.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelTransformer.cs (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -0,0 +1,103 @@ +// 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.Collections.Generic; +using System.Linq; +using Ringtoets.Common.IO.Exceptions; +using Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Common.IO.SoilProfile.Schema; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.IO.Properties; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.IO.SoilProfiles +{ + /// + /// Transforms generic into . + /// + public class PipingStochasticSoilModelTransformer : IStochasticSoilModelTransformer + { + private readonly Dictionary soilProfiles = new Dictionary(); + + public PipingStochasticSoilModel Transform(StochasticSoilModel stochasticSoilModel) + { + if (stochasticSoilModel.FailureMechanismType != FailureMechanismType.Piping) + { + string message = string.Format(Resources.PipingStochasticSoilModelTransformer_Cannot_tranform_FailureMechanismType_0_Only_FailureMechanismType_1_supported, + stochasticSoilModel.FailureMechanismType, + FailureMechanismType.Piping); + throw new ImportedDataTransformException(message); + } + + IEnumerable pipingStochasticSoilProfiles = TransformStochasticSoilProfiles( + stochasticSoilModel.StochasticSoilProfiles); + + var pipingModel = new PipingStochasticSoilModel(stochasticSoilModel.Name); + pipingModel.Geometry.AddRange(stochasticSoilModel.Geometry); + pipingModel.StochasticSoilProfiles.AddRange(pipingStochasticSoilProfiles.ToArray()); + + return pipingModel; + } + + /// + /// Transforms all generic into . + /// + /// The stochastic soil profiles to use in the transformation. + /// The transformed piping stochastic soil profiles. + /// Thrown when transformation would + /// not result in a valid transformed instance. + private IEnumerable TransformStochasticSoilProfiles(IEnumerable stochasticSoilProfiles) + { + foreach (StochasticSoilProfile stochasticSoilProfile in stochasticSoilProfiles) + { + PipingSoilProfile pipingSoilProfile = GetTransformedPipingSoilProfile(stochasticSoilProfile.SoilProfile); + + if (pipingSoilProfile != null) + { + yield return PipingStochasticSoilProfileTransformer.Transform(stochasticSoilProfile, pipingSoilProfile); + } + } + } + + /// + /// Transforms all generic into . + /// + /// The soil profile to use in the transformation. + /// The transformed piping soil profile, or null when + /// is not of a type that can be transformed to . + /// Thrown when transformation would + /// not result in a valid transformed instance. + private PipingSoilProfile GetTransformedPipingSoilProfile(ISoilProfile soilProfile) + { + PipingSoilProfile pipingStochasticSoilProfile; + if (soilProfiles.ContainsKey(soilProfile)) + { + pipingStochasticSoilProfile = soilProfiles[soilProfile]; + } + else + { + pipingStochasticSoilProfile = PipingSoilProfileTransformer.Transform(soilProfile); + soilProfiles.Add(soilProfile, pipingStochasticSoilProfile); + } + return pipingStochasticSoilProfile; + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilProfileTransformer.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilProfileTransformer.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilProfileTransformer.cs (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -0,0 +1,58 @@ +// 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 Ringtoets.Common.IO.Exceptions; +using Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.IO.SoilProfiles +{ + /// + /// Transforms generic into . + /// + public static class PipingStochasticSoilProfileTransformer + { + /// + /// Transforms the generic into . + /// + /// The stochastic soil profile to use in the transformation. + /// The transformed piping soil profile. + /// A new based on the given data. + /// Thrown when any of the input parameters is null. + /// Thrown when transformation would not result + /// in a valid transformed instance. + public static PipingStochasticSoilProfile Transform(StochasticSoilProfile stochasticSoilProfile, PipingSoilProfile soilProfile) + { + if (stochasticSoilProfile == null) + { + throw new ArgumentNullException(nameof(stochasticSoilProfile)); + } + if (soilProfile == null) + { + throw new ArgumentNullException(nameof(soilProfile)); + } + + return new PipingStochasticSoilProfile(stochasticSoilProfile.Probability, soilProfile); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SurfaceLines/PipingSurfaceLineExtensions.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SurfaceLines/PipingSurfaceLineExtensions.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SurfaceLines/PipingSurfaceLineExtensions.cs (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -0,0 +1,229 @@ +// 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; +using log4net; +using Ringtoets.Common.IO.Exceptions; +using Ringtoets.Common.IO.Properties; +using Ringtoets.Common.IO.SurfaceLines; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.IO.SurfaceLines +{ + /// + /// Extension methods for the class. + /// + public static class PipingSurfaceLineExtensions + { + private static readonly ILog log = LogManager.GetLogger(typeof(PipingSurfaceLineExtensions)); + + /// + /// Tries to set the relevant characteristic points from the + /// on the . + /// + /// The surface line to set the characteristic points for. + /// The characteristic points to set, if the collection is valid. + /// Thrown when is null. + /// Thrown when defines + /// a dike toe at polder side in front of the dike toe at river side. + public static void SetCharacteristicPoints(this PipingSurfaceLine surfaceLine, CharacteristicPoints characteristicPoints) + { + if (surfaceLine == null) + { + throw new ArgumentNullException(nameof(surfaceLine)); + } + if (characteristicPoints == null) + { + return; + } + + surfaceLine.ValidateDikeToesInOrder(characteristicPoints); + + surfaceLine.TrySetDikeToeAtRiver(characteristicPoints.DikeToeAtRiver); + surfaceLine.TrySetDitchDikeSide(characteristicPoints.DitchDikeSide); + surfaceLine.TrySetBottomDitchDikeSide(characteristicPoints.BottomDitchDikeSide); + surfaceLine.TrySetBottomDitchPolderSide(characteristicPoints.BottomDitchPolderSide); + surfaceLine.TrySetDitchPolderSide(characteristicPoints.DitchPolderSide); + surfaceLine.TrySetDikeToeAtPolder(characteristicPoints.DikeToeAtPolder); + } + + /// + /// Tries to set the at the location of + /// . + /// + /// The to set the + /// for. + /// The point at which to set the . + private static void TrySetDitchPolderSide(this PipingSurfaceLine surfaceLine, Point3D point) + { + if (point != null) + { + try + { + surfaceLine.SetDitchPolderSideAt(point); + } + catch (ArgumentException e) + { + LogError(surfaceLine, e); + } + } + } + + /// + /// Tries to set the at the location of + /// . + /// + /// The to set the + /// for. + /// The point at which to set the . + private static void TrySetBottomDitchPolderSide(this PipingSurfaceLine surfaceLine, Point3D point) + { + if (point != null) + { + try + { + surfaceLine.SetBottomDitchPolderSideAt(point); + } + catch (ArgumentException e) + { + LogError(surfaceLine, e); + } + } + } + + /// + /// Tries to set the at the location of + /// . + /// + /// The to set the + /// for. + /// The point at which to set the . + private static void TrySetBottomDitchDikeSide(this PipingSurfaceLine surfaceLine, Point3D point) + { + if (point != null) + { + try + { + surfaceLine.SetBottomDitchDikeSideAt(point); + } + catch (ArgumentException e) + { + LogError(surfaceLine, e); + } + } + } + + /// + /// Tries to set the at the location of + /// . + /// + /// The to set the + /// for. + /// The point at which to set the . + private static void TrySetDitchDikeSide(this PipingSurfaceLine surfaceLine, Point3D point) + { + if (point != null) + { + try + { + surfaceLine.SetDitchDikeSideAt(point); + } + catch (ArgumentException e) + { + LogError(surfaceLine, e); + } + } + } + + /// + /// Tries to set the at the location of + /// . + /// + /// The to set the + /// for. + /// The point at which to set the . + private static void TrySetDikeToeAtRiver(this PipingSurfaceLine surfaceLine, Point3D point) + { + if (point != null) + { + try + { + surfaceLine.SetDikeToeAtRiverAt(point); + } + catch (ArgumentException e) + { + LogError(surfaceLine, e); + } + } + } + + /// + /// Tries to set the at the location of + /// . + /// + /// The to set the + /// for. + /// The point at which to set the . + private static void TrySetDikeToeAtPolder(this PipingSurfaceLine surfaceLine, Point3D point) + { + if (point != null) + { + try + { + surfaceLine.SetDikeToeAtPolderAt(point); + } + catch (ArgumentException e) + { + LogError(surfaceLine, e); + } + } + } + + private static void LogError(PipingSurfaceLine surfaceLine, ArgumentException e) + { + log.ErrorFormat(Resources.SurfaceLinesCsvImporter_CharacteristicPoint_of_SurfaceLine_0_skipped_cause_1_, + surfaceLine.Name, + e.Message); + } + + /// + /// Validates whether or not the dike toes are in the right order. + /// + /// The surface line. + /// The characteristic points (possibly) containing the dike toes. + /// Thrown when the dike toes are not in the right order. + private static void ValidateDikeToesInOrder(this PipingSurfaceLine surfaceLine, CharacteristicPoints characteristicPoints) + { + if (characteristicPoints.DikeToeAtRiver != null && characteristicPoints.DikeToeAtPolder != null) + { + Point2D localDikeToeAtRiver = surfaceLine.GetLocalPointFromGeometry(characteristicPoints.DikeToeAtRiver); + Point2D localDikeToeAtPolder = surfaceLine.GetLocalPointFromGeometry(characteristicPoints.DikeToeAtPolder); + + if (localDikeToeAtPolder.X <= localDikeToeAtRiver.X) + { + string message = string.Format(Resources.SurfaceLinesCsvImporter_CheckCharacteristicPoints_EntryPointL_greater_or_equal_to_ExitPointL_for_0_, characteristicPoints.Name); + throw new ImportedDataTransformException(message); + } + } + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SurfaceLines/PipingSurfaceLineTransformer.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SurfaceLines/PipingSurfaceLineTransformer.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SurfaceLines/PipingSurfaceLineTransformer.cs (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -0,0 +1,66 @@ +// 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; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.IO.SurfaceLines; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.IO.SurfaceLines +{ + /// + /// Transforms generic into piping specific . + /// + public class PipingSurfaceLineTransformer : ISurfaceLineTransformer + { + private readonly ReferenceLine referenceLine; + + /// + /// Creates a new instance of . + /// + /// The reference line to determine locations for the surface + /// lines for. + /// Thrown when is null. + public PipingSurfaceLineTransformer(ReferenceLine referenceLine) + { + if (referenceLine == null) + { + throw new ArgumentNullException(nameof(referenceLine)); + } + this.referenceLine = referenceLine; + } + + public PipingSurfaceLine Transform(SurfaceLine surfaceLine, CharacteristicPoints characteristicPoints) + { + Point2D intersectionPoint = surfaceLine.GetSingleReferenceLineIntersection(referenceLine); + + var pipingSurfaceLine = new PipingSurfaceLine(surfaceLine.Name ?? string.Empty); + pipingSurfaceLine.SetGeometry(surfaceLine.Points); + + pipingSurfaceLine.SetCharacteristicPoints(characteristicPoints); + + pipingSurfaceLine.ReferenceLineIntersectionWorldPoint = intersectionPoint; + + return pipingSurfaceLine; + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelImporterConfigurationFactory.cs =================================================================== diff -u -r26f527fb809a2325c8f883ece9da01a8f8040eb3 -rdaa6b36fc2506683c50ba4117790452ae4f45d7f --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelImporterConfigurationFactory.cs (.../StochasticSoilModelImporterConfigurationFactory.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelImporterConfigurationFactory.cs (.../StochasticSoilModelImporterConfigurationFactory.cs) (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -22,7 +22,7 @@ using Ringtoets.Common.IO.SoilProfile; using Ringtoets.Piping.Data; using Ringtoets.Piping.Data.SoilProfile; -using Ringtoets.Piping.IO.Importers; +using Ringtoets.Piping.IO.SoilProfiles; namespace Ringtoets.Piping.Plugin.FileImporter { Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/SurfaceLinesCsvImporterConfigurationFactory.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -rdaa6b36fc2506683c50ba4117790452ae4f45d7f --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/SurfaceLinesCsvImporterConfigurationFactory.cs (.../SurfaceLinesCsvImporterConfigurationFactory.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/SurfaceLinesCsvImporterConfigurationFactory.cs (.../SurfaceLinesCsvImporterConfigurationFactory.cs) (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -22,7 +22,7 @@ using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.IO.SurfaceLines; using Ringtoets.Piping.Data; -using Ringtoets.Piping.IO.Importers; +using Ringtoets.Piping.IO.SurfaceLines; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.Plugin.FileImporter Fisheye: Tag daa6b36fc2506683c50ba4117790452ae4f45d7f refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingSoilLayerTransformerTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag daa6b36fc2506683c50ba4117790452ae4f45d7f refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingSoilProfileTransformerTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag daa6b36fc2506683c50ba4117790452ae4f45d7f refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingStochasticSoilModelFilterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag daa6b36fc2506683c50ba4117790452ae4f45d7f refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingStochasticSoilModelTransformerTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag daa6b36fc2506683c50ba4117790452ae4f45d7f refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingStochasticSoilProfileTransformerTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag daa6b36fc2506683c50ba4117790452ae4f45d7f refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingSurfaceLineExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag daa6b36fc2506683c50ba4117790452ae4f45d7f refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingSurfaceLineTransformerTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj =================================================================== diff -u -r17e4a03119d9331cfcbe5b2e3e3255d7d05b74bb -rdaa6b36fc2506683c50ba4117790452ae4f45d7f --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 17e4a03119d9331cfcbe5b2e3e3255d7d05b74bb) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -71,13 +71,13 @@ - - - - - - - + + + + + + + Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilLayerTransformerTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilLayerTransformerTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilLayerTransformerTest.cs (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -0,0 +1,878 @@ +// 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.Drawing; +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.IO.Exceptions; +using Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Common.IO.TestUtil; +using Ringtoets.Piping.Data.TestUtil; +using Ringtoets.Piping.IO.SoilProfiles; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.IO.Test.SoilProfiles +{ + [TestFixture] + public class PipingSoilLayerTransformerTest + { + [Test] + public void SoilLayer1DTransform_SoilLayer1DNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => PipingSoilLayerTransformer.Transform(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("soilLayer", exception.ParamName); + } + + [Test] + public void SoilLayer1DTransform_PropertiesSetWithCorrectDistributionsAndDifferentLayerParameters_ExpectedProperties() + { + // Setup + var random = new Random(22); + + bool isAquifer = random.NextBoolean(); + double top = random.NextDouble(); + const string materialName = "materialX"; + Color color = Color.AliceBlue; + + const int belowPhreaticLevelDistribution = 3; + const int belowPhreaticLevelShift = 0; + double belowPhreaticLevelMean = random.NextDouble(); + double belowPhreaticLevelDeviation = random.NextDouble(); + + const int diameterD70Distribution = 3; + const int diameterD70Shift = 0; + double diameterD70Mean = random.NextDouble(); + double diameterD70CoefficientOfVariation = random.NextDouble(); + + const int permeabilityDistribution = 3; + const int permeabilityShift = 0; + double permeabilityMean = random.NextDouble(); + double permeabilityCoefficientOfVariation = random.NextDouble(); + + var layer = new SoilLayer1D(top) + { + MaterialName = materialName, + IsAquifer = isAquifer, + Color = color, + BelowPhreaticLevelDistribution = belowPhreaticLevelDistribution, + BelowPhreaticLevelShift = belowPhreaticLevelShift, + BelowPhreaticLevelMean = belowPhreaticLevelMean, + BelowPhreaticLevelDeviation = belowPhreaticLevelDeviation, + DiameterD70Distribution = diameterD70Distribution, + DiameterD70Shift = diameterD70Shift, + DiameterD70Mean = diameterD70Mean, + DiameterD70CoefficientOfVariation = diameterD70CoefficientOfVariation, + PermeabilityDistribution = permeabilityDistribution, + PermeabilityShift = permeabilityShift, + PermeabilityMean = permeabilityMean, + PermeabilityCoefficientOfVariation = permeabilityCoefficientOfVariation + }; + + // Call + PipingSoilLayer pipingSoilLayer = PipingSoilLayerTransformer.Transform(layer); + + // Assert + Assert.AreEqual(top, pipingSoilLayer.Top); + Assert.AreEqual(isAquifer, pipingSoilLayer.IsAquifer); + Assert.AreEqual(belowPhreaticLevelMean, pipingSoilLayer.BelowPhreaticLevelMean); + Assert.AreEqual(belowPhreaticLevelDeviation, pipingSoilLayer.BelowPhreaticLevelDeviation); + Assert.AreEqual(belowPhreaticLevelShift, pipingSoilLayer.BelowPhreaticLevelShift); + Assert.AreEqual(diameterD70Mean, pipingSoilLayer.DiameterD70Mean); + Assert.AreEqual(diameterD70CoefficientOfVariation, pipingSoilLayer.DiameterD70CoefficientOfVariation); + Assert.AreEqual(permeabilityMean, pipingSoilLayer.PermeabilityMean); + Assert.AreEqual(permeabilityCoefficientOfVariation, pipingSoilLayer.PermeabilityCoefficientOfVariation); + Assert.AreEqual(materialName, pipingSoilLayer.MaterialName); + Assert.AreEqual(color, pipingSoilLayer.Color); + } + + [Test] + public void SoilLayer1DTransform_IncorrectShiftedLogNormalDistribution_ThrowsImportedDataTransformException() + { + // Setup + var layer = new SoilLayer1D(0.0) + { + BelowPhreaticLevelDistribution = -1 + }; + + // Call + TestDelegate test = () => PipingSoilLayerTransformer.Transform(layer); + + // Assert + Exception exception = Assert.Throws(test); + Assert.AreEqual("Parameter 'Verzadigd gewicht' is niet verschoven lognormaal verdeeld.", exception.Message); + } + + [Test] + [TestCaseSource(nameof(IncorrectLogNormalDistributionsSoilLayer1D))] + public void SoilLayer1DTransform_IncorrectLogNormalDistribution_ThrowsImportedDataTransformException(SoilLayer1D layer, string parameter) + { + // Call + TestDelegate test = () => PipingSoilLayerTransformer.Transform(layer); + + // Assert + Exception exception = Assert.Throws(test); + Assert.AreEqual($"Parameter '{parameter}' is niet lognormaal verdeeld.", exception.Message); + } + + [Test] + public void SoilLayer2DTransform_SoilLayer2DNull_ThrowsArgumentNullException() + { + // Setup + double bottom; + + // Call + TestDelegate test = () => PipingSoilLayerTransformer.Transform(null, 0.0, out bottom); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("soilLayer", exception.ParamName); + } + + [Test] + public void SoilLayer2DTransform_EmptySoilLayer2D_ReturnsEmptyCollectionWithMaxValueBottom() + { + // Setup + var layer = new SoilLayer2D(); + double bottom; + + // Call + IEnumerable pipingSoilLayers = PipingSoilLayerTransformer.Transform(layer, 0.0, out bottom); + + // Assert + CollectionAssert.IsEmpty(pipingSoilLayers); + Assert.AreEqual(double.MaxValue, bottom); + } + + [Test] + public void SoilLayer2DTransform_PropertiesSetWithDifferentLayerParameters_ExpectedProperties() + { + // Setup + var random = new Random(22); + double y1 = random.NextDouble(); + double y2 = y1 + random.NextDouble(); + const double x1 = 1.0; + const double x2 = 1.1; + const double x3 = 1.2; + const string materialName = "materialX"; + Color color = Color.DarkSeaGreen; + double bottom; + + bool isAquifer = random.NextBoolean(); + const int logNormalDistribution = 3; + const int logNormalShift = 0; + + double belowPhreaticLevelMean = random.NextDouble(); + double belowPhreaticLevelDeviation = random.NextDouble(); + + double diameterD70Mean = random.NextDouble(); + double diameterD70CoefficientOfVariation = random.NextDouble(); + + double permeabilityMean = random.NextDouble(); + double permeabilityCoefficientOfVariation = random.NextDouble(); + + var outerLoop = new List + { + new Segment2D(new Point2D(x1, y1), + new Point2D(x3, y1)), + new Segment2D(new Point2D(x3, y1), + new Point2D(x3, y2)), + new Segment2D(new Point2D(x3, y2), + new Point2D(x1, y2)), + new Segment2D(new Point2D(x1, y1), + new Point2D(x1, y2)) + }; + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D( + Enumerable.Empty>(), + outerLoop); + layer.MaterialName = materialName; + layer.IsAquifer = isAquifer; + layer.Color = color; + layer.BelowPhreaticLevelDistribution = logNormalDistribution; + layer.BelowPhreaticLevelShift = logNormalShift; + layer.BelowPhreaticLevelMean = belowPhreaticLevelMean; + layer.BelowPhreaticLevelDeviation = belowPhreaticLevelDeviation; + layer.DiameterD70Distribution = logNormalDistribution; + layer.DiameterD70Shift = logNormalShift; + layer.DiameterD70Mean = diameterD70Mean; + layer.DiameterD70CoefficientOfVariation = diameterD70CoefficientOfVariation; + layer.PermeabilityDistribution = logNormalDistribution; + layer.PermeabilityShift = logNormalShift; + layer.PermeabilityMean = permeabilityMean; + layer.PermeabilityCoefficientOfVariation = permeabilityCoefficientOfVariation; + + // Call + PipingSoilLayer[] pipingSoilLayers = PipingSoilLayerTransformer.Transform( + layer, x2, out bottom).ToArray(); + + // Assert + Assert.AreEqual(1, pipingSoilLayers.Length); + Assert.AreEqual(y1, bottom, 1e-6); + PipingSoilLayer resultLayer = pipingSoilLayers.First(); + Assert.AreEqual(y2, resultLayer.Top, 1e-6); + Assert.AreEqual(isAquifer, resultLayer.IsAquifer); + Assert.AreEqual(materialName, resultLayer.MaterialName); + Assert.AreEqual(color, resultLayer.Color); + + Assert.AreEqual(belowPhreaticLevelMean, resultLayer.BelowPhreaticLevelMean); + Assert.AreEqual(belowPhreaticLevelDeviation, resultLayer.BelowPhreaticLevelDeviation); + Assert.AreEqual(diameterD70Mean, resultLayer.DiameterD70Mean); + Assert.AreEqual(diameterD70CoefficientOfVariation, resultLayer.DiameterD70CoefficientOfVariation); + Assert.AreEqual(permeabilityMean, resultLayer.PermeabilityMean); + Assert.AreEqual(permeabilityCoefficientOfVariation, resultLayer.PermeabilityCoefficientOfVariation); + } + + [Test] + public void SoilLayer2DTransform_WithOuterLoopNotIntersectingX_ReturnsEmptyCollectionWithMaxValueBottom() + { + // Setup + var random = new Random(22); + double y1 = random.NextDouble(); + double y2 = random.NextDouble(); + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D( + new List(), + new List + { + new Segment2D(new Point2D(1.0, y1), + new Point2D(1.2, y2)), + new Segment2D(new Point2D(1.2, y2), + new Point2D(1.0, y1)) + }); + + double bottom; + + // Call + PipingSoilLayer[] pipingSoilLayers = PipingSoilLayerTransformer.Transform( + layer, 0.0, out bottom).ToArray(); + + // Assert + CollectionAssert.IsEmpty(pipingSoilLayers); + Assert.AreEqual(double.MaxValue, bottom); + } + + [Test] + public void SoilLayer2DTransform_WithOuterLoopIntersectingX_ReturnsBottomAndLayerWithTop() + { + // Setup + double expectedZ = new Random(22).NextDouble(); + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D( + new List(), + new List + { + new Segment2D(new Point2D(-0.1, expectedZ), + new Point2D(0.1, expectedZ)), + new Segment2D(new Point2D(-0.1, expectedZ), + new Point2D(0.1, expectedZ)) + }); + double bottom; + + // Call + PipingSoilLayer[] pipingSoilLayers = PipingSoilLayerTransformer.Transform( + layer, 0.0, out bottom).ToArray(); + + // Assert + Assert.AreEqual(1, pipingSoilLayers.Length); + Assert.AreEqual(expectedZ, bottom); + Assert.AreEqual(expectedZ, pipingSoilLayers[0].Top); + } + + [Test] + public void SoilLayer2DTransform_OuterLoopComplex_ReturnsTwoLayers() + { + // Setup + List outerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "..1..2..", + "........", + "..8.7...", + "..5.6...", + "..4..3..", + "........")); + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D( + new List(), outerLoop); + + double bottom; + + // Call + PipingSoilLayer[] pipingSoilLayers = PipingSoilLayerTransformer.Transform( + layer, 3.5, out bottom).ToArray(); + + // Assert + Assert.AreEqual(2, pipingSoilLayers.Length); + Assert.AreEqual(1.0, bottom); + CollectionAssert.AreEquivalent(new[] + { + 5.0, + 2.0 + }, pipingSoilLayers.Select(rl => rl.Top)); + } + + [Test] + public void SoilLayer2DTransform_OuterLoopInnerLoopSimple_ReturnsTwoLayers() + { + // Setup + List outerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "..1..2..", + "........", + "........", + "........", + "........", + "..4..3..")); + + List innerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "........", + "...12...", + "........", + "........", + "...43...", + "........")); + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D(new[] + { + innerLoop + }, outerLoop); + + double bottom; + + // Call + PipingSoilLayer[] pipingSoilLayers = PipingSoilLayerTransformer.Transform( + layer, 3.5, out bottom).ToArray(); + + // Assert + Assert.AreEqual(2, pipingSoilLayers.Length); + Assert.AreEqual(0, bottom); + CollectionAssert.AreEquivalent(new[] + { + 5.0, + 1.0 + }, pipingSoilLayers.Select(rl => rl.Top)); + } + + [Test] + public void SoilLayer2DTransform_OuterLoopInnerLoopComplex_ReturnsThreeLayers() + { + // Setup + List outerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "..1..2..", + "........", + "........", + "........", + "........", + "..4..3..")); + + List innerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "........", + "...1.2..", + "...87...", + "...56...", + "...4.3..", + "........")); + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D(new[] + { + innerLoop + }, outerLoop); + + double bottom; + + // Call + PipingSoilLayer[] pipingSoilLayers = PipingSoilLayerTransformer.Transform( + layer, 3.5, out bottom).ToArray(); + + // Assert + Assert.AreEqual(3, pipingSoilLayers.Length); + Assert.AreEqual(0, bottom); + CollectionAssert.AreEquivalent(new[] + { + 5.0, + 3.0, + 1.0 + }, pipingSoilLayers.Select(rl => rl.Top)); + } + + [Test] + public void SoilLayer2DTransform_OuterLoopMultipleInnerLoops_ReturnsThreeLayers() + { + // Setup + List outerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "..1..2..", + "........", + "........", + "........", + "........", + "..4..3..")); + + List innerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "........", + "...12...", + "...43...", + "........", + "........", + "........")); + + List innerLoop2 = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "........", + "........", + "........", + "........", + "...12...", + "........")); + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D(new[] + { + innerLoop, + innerLoop2 + }, outerLoop); + + double bottom; + + // Call + PipingSoilLayer[] pipingSoilLayers = PipingSoilLayerTransformer.Transform( + layer, 3.5, out bottom).ToArray(); + + // Assert + Assert.AreEqual(3, pipingSoilLayers.Length); + Assert.AreEqual(0, bottom); + CollectionAssert.AreEquivalent(new[] + { + 5.0, + 3.0, + 1.0 + }, pipingSoilLayers.Select(rl => rl.Top)); + } + + [Test] + public void SoilLayer2DTransform_OuterLoopOverlappingInnerLoop_ReturnsOneLayer() + { + // Setup + List outerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "..1..2..", + "........", + "........", + "........", + ".4....3.", + "........")); + + List innerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "........", + "........", + "........", + "...12...", + "........", + "...43...")); + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D(new[] + { + innerLoop + }, outerLoop); + + double bottom; + + // Call + PipingSoilLayer[] pipingSoilLayers = PipingSoilLayerTransformer.Transform( + layer, 3.5, out bottom).ToArray(); + + // Assert + Assert.AreEqual(1, pipingSoilLayers.Length); + Assert.AreEqual(2.0, bottom); + CollectionAssert.AreEquivalent(new[] + { + 5.0 + }, pipingSoilLayers.Select(rl => rl.Top)); + } + + [Test] + public void SoilLayer2DTransform_Outer_LoopOverlappingInnerLoopsFirstInnerLoopNotOverBottom_ReturnsOneLayer() + { + // Setup + List outerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "..1..2..", + "........", + "........", + "........", + ".4....3.", + "........")); + + List innerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "........", + "...12...", + "........", + "...43...", + "........", + "........")); + + List innerLoop2 = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "........", + "........", + "...12...", + "........", + "........", + "...43...")); + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D(new[] + { + innerLoop, + innerLoop2 + }, outerLoop); + + double bottom; + + // Call + PipingSoilLayer[] pipingSoilLayers = PipingSoilLayerTransformer.Transform( + layer, 3.5, out bottom).ToArray(); + + // Assert + Assert.AreEqual(1, pipingSoilLayers.Length); + Assert.AreEqual(4.0, bottom); + CollectionAssert.AreEquivalent(new[] + { + 5.0 + }, pipingSoilLayers.Select(rl => rl.Top)); + } + + [Test] + public void SoilLayer2DTransform_OuterLoopInnerLoopOnBorderBottom_ReturnsTwoLayers() + { + // Setup + List outerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "..1..2..", + "........", + "........", + "........", + ".4....3.", + "........")); + + List innerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "........", + "........", + "...12...", + "........", + "...43...", + "........")); + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D(new[] + { + innerLoop + }, outerLoop); + + double bottom; + + // Call + PipingSoilLayer[] pipingSoilLayers = PipingSoilLayerTransformer.Transform( + layer, 3.5, out bottom).ToArray(); + + // Assert + Assert.AreEqual(2, pipingSoilLayers.Length); + Assert.AreEqual(3.0, bottom); + CollectionAssert.AreEquivalent(new[] + { + 5.0, + 1.0 + }, pipingSoilLayers.Select(rl => rl.Top)); + } + + [Test] + public void SoilLayer2DTransform_OuterLoopInnerLoopOverlapTop_ReturnsOneLayer() + { + // Setup + List outerLoop = Segment2DLoopCollectionHelper.CreateFromString + (string.Join(Environment.NewLine, + "6", + "........", + "..1..2..", + "........", + "........", + ".4....3.", + "........")); + + List innerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "...43...", + "........", + "...12...", + "........", + "........", + "........")); + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D(new[] + { + innerLoop + }, outerLoop); + + double bottom; + + // Call + PipingSoilLayer[] pipingSoilLayers = PipingSoilLayerTransformer.Transform( + layer, 3.5, out bottom).ToArray(); + + // Assert + Assert.AreEqual(1, pipingSoilLayers.Length); + Assert.AreEqual(1.0, bottom); + CollectionAssert.AreEquivalent(new[] + { + 3.0 + }, pipingSoilLayers.Select(rl => rl.Top)); + } + + [Test] + public void SoilLayer2DTransform_OuterLoopInnerLoopOnBorderTop_ReturnsOneLayer() + { + // Setup + List outerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "..1..2..", + "........", + "........", + "........", + ".4....3.", + "........")); + + List innerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "...43...", + "........", + "...12...", + "........", + "........", + "........")); + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D(new[] + { + innerLoop + }, outerLoop); + + double bottom; + + // Call + PipingSoilLayer[] pipingSoilLayers = PipingSoilLayerTransformer.Transform( + layer, 3.5, out bottom).ToArray(); + + // Assert + Assert.AreEqual(1, pipingSoilLayers.Length); + Assert.AreEqual(1.0, bottom); + CollectionAssert.AreEquivalent(new[] + { + 3.0 + }, pipingSoilLayers.Select(rl => rl.Top)); + } + + [Test] + public void SoilLayer2DTransform_OuterLoopVerticalAtX_ThrowsImportedDataTransformException() + { + // Setup + const double atX = 2.0; + List outerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "..1..2..", + "........", + "........", + "........", + "........", + "..4..3..")); + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D( + Enumerable.Empty(), outerLoop); + + double bottom; + + // Call + TestDelegate test = () => PipingSoilLayerTransformer.Transform(layer, atX, out bottom); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual($"Er kan geen 1D-profiel bepaald worden wanneer segmenten in een 2D laag verticaal lopen op de gekozen positie: x = {atX}.", exception.Message); + } + + [Test] + public void SoilLayer2DTransform_InnerLoopVerticalAtX_ThrowsImportedDataTransformException() + { + // Setup + const double atX = 3.0; + List outerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "..1..2..", + "........", + "........", + "........", + "........", + "..4..3..")); + + List innerLoop = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "6", + "........", + "...1.2..", + "........", + "........", + "...4.3..", + "........")); + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D(new[] + { + innerLoop + }, outerLoop); + + double bottom; + + // Call + TestDelegate test = () => PipingSoilLayerTransformer.Transform(layer, atX, out bottom); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual($"Er kan geen 1D-profiel bepaald worden wanneer segmenten in een 2D laag verticaal lopen op de gekozen positie: x = {atX}.", exception.Message); + } + + [Test] + public void SoilLayer2DTransform_IncorrectShiftedLogNormalDistribution_ThrowsImportedDataTransformException() + { + // Setup + var layer = new SoilLayer2D + { + BelowPhreaticLevelDistribution = -1 + }; + + double bottom; + + // Call + TestDelegate test = () => PipingSoilLayerTransformer.Transform(layer, 0, out bottom); + + // Assert + Exception exception = Assert.Throws(test); + Assert.AreEqual("Parameter 'Verzadigd gewicht' is niet verschoven lognormaal verdeeld.", exception.Message); + } + + [Test] + [TestCaseSource(nameof(IncorrectLogNormalDistributionsSoilLayer2D))] + public void SoilLayer2DTransform_IncorrectLogNormalDistribution_ThrowsImportedDataTransformException(SoilLayer2D layer, string parameter) + { + // Setup + double bottom; + + // Call + TestDelegate test = () => PipingSoilLayerTransformer.Transform(layer, 0, out bottom); + + // Assert + Exception exception = Assert.Throws(test); + Assert.AreEqual($"Parameter '{parameter}' is niet lognormaal verdeeld.", exception.Message); + } + + private static IEnumerable IncorrectLogNormalDistributionsSoilLayer1D() + { + return IncorrectLogNormalDistributions(() => new SoilLayer1D(0.0), nameof(SoilLayer1D)); + } + + private static IEnumerable IncorrectLogNormalDistributionsSoilLayer2D() + { + return IncorrectLogNormalDistributions(() => new SoilLayer2D(), nameof(SoilLayer2D)); + } + + private static IEnumerable IncorrectLogNormalDistributions(Func soilLayer, string typeName) + { + const string testNameFormat = "{0}Transform_Incorrect{1}{{1}}_ThrowsImportedDataTransformException"; + const long validDistribution = SoilLayerConstants.LogNormalDistributionValue; + const double validShift = 0.0; + + SoilLayerBase invalidDiameterD70Distribution = soilLayer(); + invalidDiameterD70Distribution.BelowPhreaticLevelDistribution = validDistribution; + invalidDiameterD70Distribution.DiameterD70Distribution = -1; + invalidDiameterD70Distribution.DiameterD70Shift = validShift; + invalidDiameterD70Distribution.PermeabilityDistribution = validDistribution; + invalidDiameterD70Distribution.PermeabilityShift = validShift; + + yield return new TestCaseData(invalidDiameterD70Distribution, "Korrelgrootte" + ).SetName(string.Format(testNameFormat, typeName, "Distribution")); + + SoilLayerBase invalidDiameterD70Shift = soilLayer(); + invalidDiameterD70Shift.BelowPhreaticLevelDistribution = validDistribution; + invalidDiameterD70Shift.DiameterD70Distribution = validDistribution; + invalidDiameterD70Shift.DiameterD70Shift = -1; + invalidDiameterD70Shift.PermeabilityDistribution = validDistribution; + invalidDiameterD70Shift.PermeabilityShift = validShift; + + yield return new TestCaseData(invalidDiameterD70Shift, "Korrelgrootte" + ).SetName(string.Format(testNameFormat, typeName, "Shift")); + + SoilLayerBase invalidPermeabilityDistribution = soilLayer(); + invalidPermeabilityDistribution.BelowPhreaticLevelDistribution = validDistribution; + invalidPermeabilityDistribution.DiameterD70Distribution = validDistribution; + invalidPermeabilityDistribution.DiameterD70Shift = validShift; + invalidPermeabilityDistribution.PermeabilityDistribution = -1; + invalidPermeabilityDistribution.PermeabilityShift = validShift; + + yield return new TestCaseData(invalidPermeabilityDistribution, "Doorlatendheid" + ).SetName(string.Format(testNameFormat, typeName, "Distribution")); + + SoilLayerBase invalidPermeabilityShift = soilLayer(); + invalidPermeabilityShift.BelowPhreaticLevelDistribution = validDistribution; + invalidPermeabilityShift.DiameterD70Distribution = validDistribution; + invalidPermeabilityShift.DiameterD70Shift = validShift; + invalidPermeabilityShift.PermeabilityDistribution = validDistribution; + invalidPermeabilityShift.PermeabilityShift = -1; + + yield return new TestCaseData(invalidPermeabilityShift, "Doorlatendheid" + ).SetName(string.Format(testNameFormat, typeName, "Shift")); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilProfileTransformerTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilProfileTransformerTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilProfileTransformerTest.cs (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -0,0 +1,456 @@ +// 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.Linq; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Common.IO.Exceptions; +using Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Common.IO.TestUtil; +using Ringtoets.Piping.Data.TestUtil; +using Ringtoets.Piping.IO.SoilProfiles; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.IO.Test.SoilProfiles +{ + [TestFixture] + public class PipingSoilProfileTransformerTest + { + [Test] + public void Transform_SoilProfileNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => PipingSoilProfileTransformer.Transform(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("soilProfile", exception.ParamName); + } + + [Test] + public void Transform_InvalidSoilProfile_ThrowsImportedDataTransformException() + { + // Setup + var invalidType = new TestSoilProfile(); + + // Call + TestDelegate test = () => PipingSoilProfileTransformer.Transform(invalidType); + + // Assert + var exception = Assert.Throws(test); + const string message = "De ondergrondschematisatie van het type 'TestSoilProfile' is niet ondersteund. " + + "Alleen ondergrondschematisaties van het type 'SoilProfile1D' of 'SoilProfile2D' zijn ondersteund."; + Assert.AreEqual(message, exception.Message); + } + + [Test] + public void Transform_SoilProfile2DWithoutIntersection_ThrowsImportedDataTransformException() + { + // Setup + const string name = "name"; + var profile = new SoilProfile2D(0, name, Enumerable.Empty()); + + // Call + TestDelegate test = () => PipingSoilProfileTransformer.Transform(profile); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual($"Geen geldige X waarde gevonden om intersectie te maken uit 2D profiel '{name}'.", + exception.Message); + } + + [Test] + public void Transform_ValidSoilProfile2D_ReturnsExpectedPipingSoilProfile() + { + // Setup + const string name = "name"; + const double bottom = 0.5; + const double intersectionX = 1.0; + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D(new List(), + new List + { + new Segment2D(new Point2D(1.0, bottom), + new Point2D(1.2, 1)), + new Segment2D(new Point2D(1.2, 1), + new Point2D(1.0, bottom)) + }); + var profile = new SoilProfile2D(0, name, new[] + { + layer + }) + { + IntersectionX = intersectionX + }; + + // Call + PipingSoilProfile transformed = PipingSoilProfileTransformer.Transform(profile); + + // Assert + Assert.AreEqual(name, transformed.Name); + Assert.AreEqual(SoilProfileType.SoilProfile2D, transformed.SoilProfileSourceType); + Assert.AreEqual(bottom, transformed.Bottom); + + double bottomOut; + IEnumerable actualPipingSoilLayers = PipingSoilLayerTransformer.Transform( + layer, intersectionX, out bottomOut); + + AssertPipingSoilLayers(actualPipingSoilLayers, transformed.Layers); + } + + [Test] + public void Transform_SoilProfile2DLayerWithVerticalLineOnXInXml_ThrowsImportedDataTransformException() + { + // Setup + const string profileName = "SomeProfile"; + const double atX = 0.0; + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D( + new List(), + new List + { + new Segment2D(new Point2D(atX, 0.0), + new Point2D(atX, 1.0)), + new Segment2D(new Point2D(atX, 1.0), + new Point2D(0.5, 0.5)), + new Segment2D(new Point2D(0.5, 0.5), + new Point2D(atX, 0.0)) + }); + + var profile = new SoilProfile2D(0, profileName, new[] + { + layer + }) + { + IntersectionX = atX + }; + + // Call + TestDelegate test = () => PipingSoilProfileTransformer.Transform(profile); + + // Assert + var exception = Assert.Throws(test); + string message = "Er kan geen 1D-profiel bepaald worden wanneer segmenten in een 2D " + + $"laag verticaal lopen op de gekozen positie: x = {atX}."; + Assert.AreEqual(message, exception.Message); + } + + [Test] + public void Transform_SoilProfile2DWithOutLayers_ThrowsImportedDataTransformException() + { + // Setup + const string profileName = "SomeProfile"; + var profile = new SoilProfile2D(0, profileName, new[] + { + new SoilLayer2D() + }); + + // Call + TestDelegate test = () => PipingSoilProfileTransformer.Transform(profile); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Transform_SoilProfile2DWithSingleLayerOnlyOuterLoop_ReturnsProfileWithBottomAndALayer() + { + // Setup + const string profileName = "SomeProfile"; + var firstPoint = new Point2D(-0.5, 1.0); + var secondPoint = new Point2D(0.5, 1.0); + var thirdPoint = new Point2D(0.5, -1.0); + var fourthPoint = new Point2D(-0.5, -1.0); + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D( + new List(), + new List + { + new Segment2D(firstPoint, secondPoint), + new Segment2D(secondPoint, thirdPoint), + new Segment2D(thirdPoint, fourthPoint), + new Segment2D(fourthPoint, firstPoint) + }); + layer.IsAquifer = true; + + var profile = new SoilProfile2D(0, profileName, new[] + { + layer + }) + { + IntersectionX = 0.0 + }; + + // Call + PipingSoilProfile transformed = PipingSoilProfileTransformer.Transform(profile); + + // Assert + Assert.AreEqual(profileName, transformed.Name); + Assert.AreEqual(1, transformed.Layers.Count()); + Assert.AreEqual(1.0, transformed.Layers.ToArray()[0].Top); + Assert.AreEqual(-1.0, transformed.Bottom); + Assert.AreEqual(SoilProfileType.SoilProfile2D, transformed.SoilProfileSourceType); + } + + [Test] + public void Transform_SoilProfile2DWithMultipleLayersOnlyOuterLoop_ReturnsProfileWithBottomAndALayers() + { + // Setup + const string profileName = "SomeProfile"; + const long pipingSoilProfileId = 1234L; + + var profile = new SoilProfile2D(pipingSoilProfileId, profileName, + new List + { + SoilLayer2DTestFactory.CreateSoilLayer2D( + new List(), + Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "10", + "...", + "...", + "...", + "...", + "...", + "...", + "...", + "1.2", + "4.3", + "..."))), + SoilLayer2DTestFactory.CreateSoilLayer2D( + new List(), + Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "10", + "...", + "...", + "...", + "...", + "...", + "4.3", + "...", + "1.2", + "...", + "..."))), + SoilLayer2DTestFactory.CreateSoilLayer2D( + new List(), + Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "10", + "...", + "1.2", + "...", + "...", + "...", + "4.3", + "...", + "...", + "...", + "..."))) + }) + { + IntersectionX = 1.0 + }; + + // Call + PipingSoilProfile transformed = PipingSoilProfileTransformer.Transform(profile); + + // Assert + Assert.AreEqual(profileName, transformed.Name); + Assert.AreEqual(SoilProfileType.SoilProfile2D, transformed.SoilProfileSourceType); + Assert.AreEqual(3, transformed.Layers.Count()); + CollectionAssert.AreEquivalent(new[] + { + 2.0, + 4.0, + 8.0 + }, transformed.Layers.Select(rl => rl.Top)); + Assert.AreEqual(1.0, transformed.Bottom); + } + + [Test] + public void Transform_SoilProfile2DWithLayerFilledWithOtherLayer_ReturnsProfileWithBottomAndALayers() + { + // Setup + const string profileName = "SomeProfile"; + const long pipingSoilProfileId = 1234L; + List loopHole = Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "5", + ".....", + ".4.1.", + ".3.2.", + ".....", + ".....")); + + SoilLayer2D soilLayer2D = SoilLayer2DTestFactory.CreateSoilLayer2D( + new[] + { + loopHole + }, + Segment2DLoopCollectionHelper.CreateFromString( + string.Join(Environment.NewLine, + "5", + "2...3", + ".....", + ".....", + ".....", + "1...4"))); + soilLayer2D.IsAquifer = true; + + var profile = new SoilProfile2D(pipingSoilProfileId, profileName, + new List + { + soilLayer2D, + SoilLayer2DTestFactory.CreateSoilLayer2D( + new List(), + loopHole) + } + ) + { + IntersectionX = 2.0 + }; + + // Call + PipingSoilProfile transformed = PipingSoilProfileTransformer.Transform(profile); + + // Assert + Assert.AreEqual(profileName, transformed.Name); + Assert.AreEqual(SoilProfileType.SoilProfile2D, transformed.SoilProfileSourceType); + Assert.AreEqual(3, transformed.Layers.Count()); + CollectionAssert.AreEquivalent(new[] + { + 4.0, + 3.0, + 2.0 + }, transformed.Layers.Select(rl => rl.Top)); + Assert.AreEqual(0.0, transformed.Bottom); + } + + [Test] + public void Transform_SoilProfile1DWithSingleLayer_ReturnsProfileWithBottomAndALayer() + { + // Setup + const string profileName = "SomeProfile"; + var random = new Random(22); + double bottom = random.NextDouble(); + double top = random.NextDouble(); + const long pipingSoilProfileId = 1234L; + + var profile = new SoilProfile1D(pipingSoilProfileId, + profileName, + bottom, + new[] + { + new SoilLayer1D(top) + { + IsAquifer = true + } + } + ); + + // Call + PipingSoilProfile transformed = PipingSoilProfileTransformer.Transform(profile); + + // Assert + Assert.AreEqual(profileName, transformed.Name); + Assert.AreEqual(SoilProfileType.SoilProfile1D, transformed.SoilProfileSourceType); + + PipingSoilLayer[] layers = transformed.Layers.ToArray(); + Assert.AreEqual(1, layers.Length); + Assert.AreEqual(top, layers[0].Top); + Assert.AreEqual(bottom, transformed.Bottom); + } + + [Test] + public void Transform_SoilProfile1DWithMultipleLayers_ReturnsProfileWithBottomAndALayer() + { + // Setup + const string profileName = "SomeProfile"; + var random = new Random(22); + double bottom = random.NextDouble(); + double top = bottom + random.NextDouble(); + double top2 = bottom + random.NextDouble(); + const long pipingSoilProfileId = 1234L; + + var profile = new SoilProfile1D(pipingSoilProfileId, + profileName, + bottom, + new[] + { + new SoilLayer1D(top) + { + IsAquifer = true + }, + new SoilLayer1D(top2) + } + ); + + // Call + PipingSoilProfile transformed = PipingSoilProfileTransformer.Transform(profile); + + // Assert + Assert.AreEqual(profileName, transformed.Name); + Assert.AreEqual(2, transformed.Layers.Count()); + CollectionAssert.AreEquivalent(new[] + { + top, + top2 + }, transformed.Layers.Select(l => l.Top)); + Assert.AreEqual(bottom, transformed.Bottom); + } + + private static void AssertPipingSoilLayers(IEnumerable expectedSoilLayer2Ds, + IEnumerable actualSoilLayer2Ds) + { + PipingSoilLayer[] expectedSoilLayer2DsArray = expectedSoilLayer2Ds.ToArray(); + PipingSoilLayer[] actualSoilLayers2DArray = actualSoilLayer2Ds.ToArray(); + Assert.AreEqual(expectedSoilLayer2DsArray.Length, actualSoilLayers2DArray.Length); + + for (var i = 0; i < expectedSoilLayer2DsArray.Length; i++) + { + AssertPipingSoilLayer(expectedSoilLayer2DsArray[i], actualSoilLayers2DArray[i]); + } + } + + private static void AssertPipingSoilLayer(PipingSoilLayer expected, PipingSoilLayer actual) + { + Assert.AreEqual(expected.Top, actual.Top); + Assert.AreEqual(expected.IsAquifer, actual.IsAquifer); + Assert.AreEqual(expected.BelowPhreaticLevelMean, actual.BelowPhreaticLevelMean); + Assert.AreEqual(expected.BelowPhreaticLevelDeviation, actual.BelowPhreaticLevelDeviation); + Assert.AreEqual(expected.BelowPhreaticLevelShift, actual.BelowPhreaticLevelShift); + Assert.AreEqual(expected.DiameterD70Mean, actual.DiameterD70Mean); + Assert.AreEqual(expected.DiameterD70CoefficientOfVariation, actual.DiameterD70CoefficientOfVariation); + Assert.AreEqual(expected.PermeabilityMean, actual.PermeabilityMean); + Assert.AreEqual(expected.PermeabilityCoefficientOfVariation, actual.PermeabilityCoefficientOfVariation); + Assert.AreEqual(expected.MaterialName, actual.MaterialName); + Assert.AreEqual(expected.Color, actual.Color); + } + + private class TestSoilProfile : ISoilProfile + { + public string Name { get; } + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelFilterTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelFilterTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelFilterTest.cs (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -0,0 +1,88 @@ +// 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.Linq; +using NUnit.Framework; +using Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Common.IO.SoilProfile.Schema; +using Ringtoets.Piping.IO.SoilProfiles; + +namespace Ringtoets.Piping.IO.Test.SoilProfiles +{ + [TestFixture] + public class PipingStochasticSoilModelFilterTest + { + [Test] + public void Constructor_StochasticSoilModelNull_ThrowsArgumentNullException() + { + // Setup + var filter = new PipingStochasticSoilModelFilter(); + + // Call + TestDelegate test = () => filter.IsValidForFailureMechanism(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("stochasticSoilModel", exception.ParamName); + } + + [Test] + [TestCaseSource(nameof(StochasticSoilModelsOfInvalidType))] + public void Constructor_StochasticSoilModelOfInvalidType_ReturnsFalse(StochasticSoilModel model) + { + // Setup + var filter = new PipingStochasticSoilModelFilter(); + + // Call + bool isValid = filter.IsValidForFailureMechanism(model); + + // Assert + Assert.IsFalse(isValid); + } + + [Test] + public void Constructor_ValidStochasticSoilModelType_ReturnsFalse() + { + // Setup + var filter = new PipingStochasticSoilModelFilter(); + var model = new StochasticSoilModel(nameof(FailureMechanismType.Piping), FailureMechanismType.Piping); + + // Call + bool isValid = filter.IsValidForFailureMechanism(model); + + // Assert + Assert.IsTrue(isValid); + } + + private static IEnumerable StochasticSoilModelsOfInvalidType() + { + return Enum.GetValues(typeof(FailureMechanismType)) + .Cast() + .Where(type => type != FailureMechanismType.Piping) + .Select(type => new TestCaseData( + new StochasticSoilModel(type.ToString(), type)) + .SetName($"Constructor_InvalidType_ReturnsFalse({type.ToString()})") + ); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -0,0 +1,250 @@ +// 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.Linq; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Common.IO.Exceptions; +using Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Common.IO.SoilProfile.Schema; +using Ringtoets.Common.IO.TestUtil; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.IO.SoilProfiles; + +namespace Ringtoets.Piping.IO.Test.SoilProfiles +{ + [TestFixture] + public class PipingStochasticSoilModelTransformerTest + { + [Test] + public void Constructor_ValidProperties_ExpectedValues() + { + // Call + var transformer = new PipingStochasticSoilModelTransformer(); + + // Assert + Assert.IsInstanceOf>(transformer); + } + + [Test] + [TestCaseSource(nameof(InvalidFailureMechanismTypes))] + public void Transform_InvalidFailureMechanismType_ThrowsImportedDataTransformException(FailureMechanismType failureMechanismType) + { + // Setup + var transformer = new PipingStochasticSoilModelTransformer(); + var soilModel = new StochasticSoilModel("some name", failureMechanismType); + + // Call + TestDelegate test = () => transformer.Transform(soilModel); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual($"Het stochastische ondergrondmodel met '{failureMechanismType}' als faalmechanisme type is niet ondersteund. " + + "Alleen stochastische ondergrondmodellen met 'Piping' als faalmechanisme type zijn ondersteund.", exception.Message); + } + + [Test] + public void Transform_StochasticSoilModelWithInvalidSoilProfile_ThrowsImportedDataTransformException() + { + // Setup + var transformer = new PipingStochasticSoilModelTransformer(); + var soilModel = new StochasticSoilModel("some name", FailureMechanismType.Piping) + { + StochasticSoilProfiles = + { + new StochasticSoilProfile(1.0, new TestSoilProfile()) + } + }; + + // Call + TestDelegate test = () => transformer.Transform(soilModel); + + // Assert + var exception = Assert.Throws(test); + const string message = "De ondergrondschematisatie van het type 'TestSoilProfile' is niet ondersteund. " + + "Alleen ondergrondschematisaties van het type 'SoilProfile1D' of 'SoilProfile2D' zijn ondersteund."; + Assert.AreEqual(message, exception.Message); + } + + [Test] + public void Transform_SoilProfile2DWithoutIntersection_ThrowsImportedDataTransformException() + { + // Setup + const string name = "name"; + var transformer = new PipingStochasticSoilModelTransformer(); + var soilModel = new StochasticSoilModel(name, FailureMechanismType.Piping) + { + StochasticSoilProfiles = + { + new StochasticSoilProfile(1.0, new SoilProfile2D(0, name, Enumerable.Empty())) + } + }; + + // Call + TestDelegate test = () => transformer.Transform(soilModel); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual($"Geen geldige X waarde gevonden om intersectie te maken uit 2D profiel '{name}'.", + exception.Message); + } + + [Test] + public void Transform_ValidStochasticSoilModelWithSoilProfile2D_ReturnsExpectedPipingStochasticSoilModel() + { + // Setup + const string name = "name"; + const double bottom = 0.5; + const double intersectionX = 1.0; + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D(new List(), + new List + { + new Segment2D(new Point2D(1.0, bottom), + new Point2D(1.2, 1)), + new Segment2D(new Point2D(1.2, 1), + new Point2D(1.0, bottom)) + }); + var profile = new SoilProfile2D(0, "SoilProfile2D", new[] + { + layer + }) + { + IntersectionX = intersectionX + }; + + var transformer = new PipingStochasticSoilModelTransformer(); + var soilModel = new StochasticSoilModel(name, FailureMechanismType.Piping) + { + StochasticSoilProfiles = + { + new StochasticSoilProfile(1.0, profile) + }, + Geometry = + { + new Point2D(1.0, 0.0), + new Point2D(0.0, 0.0) + } + }; + + // Call + PipingStochasticSoilModel transformed = transformer.Transform(soilModel); + + // Assert + Assert.AreEqual(name, transformed.Name); + Assert.AreEqual(1, transformed.StochasticSoilProfiles.Count); + CollectionAssert.AreEqual(soilModel.Geometry, transformed.Geometry); + + var expectedPipingSoilProfile = new List + { + new PipingStochasticSoilProfile(1.0, PipingSoilProfileTransformer.Transform(profile)) + }; + AssertPipingStochasticSoilProfiles(expectedPipingSoilProfile, transformed.StochasticSoilProfiles); + } + + [Test] + public void Transform_ValidTwoStochasticSoilModelWithSameProfile_ReturnsExpectedPipingStochasticSoilModel() + { + // Setup + const string name = "name"; + const double bottom = 0.5; + const double intersectionX = 1.0; + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D(new List(), + new List + { + new Segment2D(new Point2D(1.0, bottom), + new Point2D(1.2, 1)), + new Segment2D(new Point2D(1.2, 1), + new Point2D(1.0, bottom)) + }); + var profile = new SoilProfile2D(0, "SoilProfile2D", new[] + { + layer + }) + { + IntersectionX = intersectionX + }; + + var transformer = new PipingStochasticSoilModelTransformer(); + var soilModel1 = new StochasticSoilModel(name, FailureMechanismType.Piping) + { + StochasticSoilProfiles = + { + new StochasticSoilProfile(1.0, profile) + } + }; + + var soilModel2 = new StochasticSoilModel(name, FailureMechanismType.Piping) + { + StochasticSoilProfiles = + { + new StochasticSoilProfile(1.0, profile) + } + }; + + // Call + PipingStochasticSoilModel transformed1 = transformer.Transform(soilModel1); + PipingStochasticSoilModel transformed2 = transformer.Transform(soilModel2); + + // Assert + List transformedStochasticSoilProfiles1 = transformed1.StochasticSoilProfiles; + List transformedStochasticSoilProfiles2 = transformed2.StochasticSoilProfiles; + Assert.AreEqual(1, transformedStochasticSoilProfiles1.Count); + Assert.AreEqual(1, transformedStochasticSoilProfiles2.Count); + + PipingStochasticSoilProfile pipingStochasticSoilProfile1 = transformedStochasticSoilProfiles1[0]; + PipingStochasticSoilProfile pipingStochasticSoilProfile2 = transformedStochasticSoilProfiles2[0]; + Assert.AreSame(pipingStochasticSoilProfile1.SoilProfile, pipingStochasticSoilProfile2.SoilProfile); + } + + private static void AssertPipingStochasticSoilProfiles(IList expected, + IList actual) + { + Assert.AreEqual(expected.Count, actual.Count); + for (var i = 0; i < expected.Count; i++) + { + AssertPipingStochasticSoilProfile(expected[i], actual[i]); + } + } + + private static void AssertPipingStochasticSoilProfile(PipingStochasticSoilProfile expected, + PipingStochasticSoilProfile actual) + { + Assert.AreEqual(expected.Probability, actual.Probability); + Assert.AreEqual(expected.SoilProfile, actual.SoilProfile); + } + + private class TestSoilProfile : ISoilProfile + { + public string Name { get; } + } + + private static IEnumerable InvalidFailureMechanismTypes() + { + return Enum.GetValues(typeof(FailureMechanismType)) + .Cast() + .Where(t => t != FailureMechanismType.Piping); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilProfileTransformerTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilProfileTransformerTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilProfileTransformerTest.cs (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -0,0 +1,90 @@ +// 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 NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.IO.SoilProfiles; +using Ringtoets.Piping.KernelWrapper.TestUtil; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.IO.Test.SoilProfiles +{ + [TestFixture] + public class PipingStochasticSoilProfileTransformerTest + { + [Test] + public void Transform_StochasticSoilProfileNull_ThrowsArgumentNullException() + { + // Setup + PipingSoilProfile soilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile(); + + // Call + TestDelegate test = () => PipingStochasticSoilProfileTransformer.Transform(null, soilProfile); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("stochasticSoilProfile", exception.ParamName); + } + + [Test] + public void Transform_PipingSoilProfileNull_ThrowsArgumentNullException() + { + // Setup + var mockRepository = new MockRepository(); + var soilProfile = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var stochasticSoilProfile = new StochasticSoilProfile(0, soilProfile); + + // Call + TestDelegate test = () => PipingStochasticSoilProfileTransformer.Transform(stochasticSoilProfile, null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("soilProfile", exception.ParamName); + mockRepository.VerifyAll(); + } + + [Test] + public void Transform_ValidStochasticSoilProfile_ReturnsExpectedPipingStochasticSoilProfile() + { + // Setup + var mockRepository = new MockRepository(); + var soilProfile = mockRepository.Stub(); + mockRepository.ReplayAll(); + + PipingSoilProfile pipingSoilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile(); + + var stochasticSoilProfile = new StochasticSoilProfile(new Random(9).NextDouble(), soilProfile); + + // Call + PipingStochasticSoilProfile pipingStochasticSoilProfile = PipingStochasticSoilProfileTransformer.Transform(stochasticSoilProfile, pipingSoilProfile); + + // Assert + Assert.AreEqual(stochasticSoilProfile.Probability, pipingStochasticSoilProfile.Probability); + Assert.AreSame(pipingSoilProfile, pipingStochasticSoilProfile.SoilProfile); + mockRepository.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SurfaceLines/PipingSurfaceLineExtensionsTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SurfaceLines/PipingSurfaceLineExtensionsTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SurfaceLines/PipingSurfaceLineExtensionsTest.cs (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -0,0 +1,217 @@ +// 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.Linq; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Common.IO.Exceptions; +using Ringtoets.Common.IO.SurfaceLines; +using Ringtoets.Piping.IO.SurfaceLines; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.IO.Test.SurfaceLines +{ + [TestFixture] + public class PipingSurfaceLineExtensionsTest + { + private static IEnumerable DifferentValidCharacteristicPointConfigurations + { + get + { + var dikeToeAtRiver = new Point3D(3, 2, 5); + var dikeToeAtPolder = new Point3D(3.4, 3, 8); + var ditchDikeSide = new Point3D(4.4, 6, 8); + var bottomDitchDikeSide = new Point3D(5.1, 6, 6.5); + var bottomDitchPolderSide = new Point3D(8.5, 7.2, 4.2); + var ditchPolderSide = new Point3D(9.6, 7.5, 3.9); + + var name = "All present"; + yield return new TestCaseData(new CharacteristicPoints(name) + { + DikeToeAtRiver = dikeToeAtRiver, + DikeToeAtPolder = dikeToeAtPolder, + DitchDikeSide = ditchDikeSide, + BottomDitchDikeSide = bottomDitchDikeSide, + BottomDitchPolderSide = bottomDitchPolderSide, + DitchPolderSide = ditchPolderSide + }).SetName(name); + + name = "Missing DikeToeAtRiver"; + yield return new TestCaseData(new CharacteristicPoints(name) + { + DikeToeAtPolder = dikeToeAtPolder, + DitchDikeSide = ditchDikeSide, + BottomDitchDikeSide = bottomDitchDikeSide, + BottomDitchPolderSide = bottomDitchPolderSide, + DitchPolderSide = ditchPolderSide + }).SetName(name); + + name = "Missing DikeToeAtPolder"; + yield return new TestCaseData(new CharacteristicPoints(name) + { + DikeToeAtRiver = dikeToeAtRiver, + DitchDikeSide = ditchDikeSide, + BottomDitchDikeSide = bottomDitchDikeSide, + BottomDitchPolderSide = bottomDitchPolderSide, + DitchPolderSide = ditchPolderSide + }).SetName(name); + + name = "Missing DitchDikeSide"; + yield return new TestCaseData(new CharacteristicPoints(name) + { + DikeToeAtRiver = dikeToeAtRiver, + DikeToeAtPolder = dikeToeAtPolder, + BottomDitchDikeSide = bottomDitchDikeSide, + BottomDitchPolderSide = bottomDitchPolderSide, + DitchPolderSide = ditchPolderSide + }).SetName(name); + + name = "Missing BottomDitchDikeSide"; + yield return new TestCaseData(new CharacteristicPoints(name) + { + DikeToeAtRiver = dikeToeAtRiver, + DikeToeAtPolder = dikeToeAtPolder, + DitchDikeSide = ditchDikeSide, + BottomDitchPolderSide = bottomDitchPolderSide, + DitchPolderSide = ditchPolderSide + }).SetName(name); + + name = "Missing BottomDitchPolderSide"; + yield return new TestCaseData(new CharacteristicPoints(name) + { + DikeToeAtRiver = dikeToeAtRiver, + DikeToeAtPolder = dikeToeAtPolder, + DitchDikeSide = ditchDikeSide, + BottomDitchDikeSide = bottomDitchDikeSide, + DitchPolderSide = ditchPolderSide + }).SetName(name); + + name = "Missing DitchPolderSide"; + yield return new TestCaseData(new CharacteristicPoints(name) + { + DikeToeAtRiver = dikeToeAtRiver, + DikeToeAtPolder = dikeToeAtPolder, + DitchDikeSide = ditchDikeSide, + BottomDitchDikeSide = bottomDitchDikeSide, + BottomDitchPolderSide = bottomDitchPolderSide + }).SetName(name); + } + } + + [Test] + public void SetCharacteristicPoints_SurfaceLineNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => ((PipingSurfaceLine) null).SetCharacteristicPoints(new CharacteristicPoints("Empty")); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("surfaceLine", exception.ParamName); + } + + [Test] + public void SetCharacteristicPoints_CharacteristicPointsNull_NoCharacteristicPointsSet() + { + // Setup + var surfaceLine = new PipingSurfaceLine(string.Empty); + surfaceLine.SetGeometry(new[] + { + new Point3D(3, 2, 5), + new Point3D(3.4, 3, 8), + new Point3D(4.4, 6, 8), + new Point3D(5.1, 6, 6.5), + new Point3D(8.5, 7.2, 4.2), + new Point3D(9.6, 7.5, 3.9) + }); + + // Call + surfaceLine.SetCharacteristicPoints(null); + + // Assert + Assert.IsNull(surfaceLine.DikeToeAtRiver); + Assert.IsNull(surfaceLine.DikeToeAtPolder); + Assert.IsNull(surfaceLine.DitchDikeSide); + Assert.IsNull(surfaceLine.BottomDitchDikeSide); + Assert.IsNull(surfaceLine.BottomDitchPolderSide); + Assert.IsNull(surfaceLine.DitchPolderSide); + } + + [Test] + public void SetCharacteristicPoints_DikeToesReversed_ThrowsImportedDataTransformException() + { + // Setup + const string name = "Reversed dike toes"; + var points = new CharacteristicPoints(name) + { + DikeToeAtPolder = new Point3D(3, 2, 5), + DikeToeAtRiver = new Point3D(3.4, 3, 8), + DitchDikeSide = new Point3D(4.4, 6, 8), + BottomDitchDikeSide = new Point3D(5.1, 6, 6.5), + BottomDitchPolderSide = new Point3D(8.5, 7.2, 4.2), + DitchPolderSide = new Point3D(9.6, 7.5, 3.9) + }; + var surfaceLine = new PipingSurfaceLine(string.Empty); + surfaceLine.SetGeometry(CharacteristicPointsToGeometry(points)); + + // Call + TestDelegate test = () => surfaceLine.SetCharacteristicPoints(points); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual($"Het uittredepunt moet landwaarts van het intredepunt liggen voor locatie '{name}'.", exception.Message); + } + + [Test] + [TestCaseSource(nameof(DifferentValidCharacteristicPointConfigurations))] + public void SetCharacteristicPoints_ValidSituations_PointsAreSet(CharacteristicPoints points) + { + // Setup + var surfaceLine = new PipingSurfaceLine(string.Empty); + surfaceLine.SetGeometry(CharacteristicPointsToGeometry(points)); + + // Call + surfaceLine.SetCharacteristicPoints(points); + + // Assert + Assert.AreEqual(points.DikeToeAtRiver, surfaceLine.DikeToeAtRiver); + Assert.AreEqual(points.DikeToeAtPolder, surfaceLine.DikeToeAtPolder); + Assert.AreEqual(points.DitchDikeSide, surfaceLine.DitchDikeSide); + Assert.AreEqual(points.BottomDitchDikeSide, surfaceLine.BottomDitchDikeSide); + Assert.AreEqual(points.BottomDitchPolderSide, surfaceLine.BottomDitchPolderSide); + Assert.AreEqual(points.DitchPolderSide, surfaceLine.DitchPolderSide); + } + + private static IEnumerable CharacteristicPointsToGeometry(CharacteristicPoints points) + { + return new[] + { + points.DikeToeAtRiver, + points.DikeToeAtPolder, + points.DitchDikeSide, + points.BottomDitchDikeSide, + points.BottomDitchPolderSide, + points.DitchPolderSide + }.Where(p => p != null); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SurfaceLines/PipingSurfaceLineTransformerTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SurfaceLines/PipingSurfaceLineTransformerTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SurfaceLines/PipingSurfaceLineTransformerTest.cs (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -0,0 +1,303 @@ +// 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.Linq; +using Core.Common.Base.Geometry; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.IO.Exceptions; +using Ringtoets.Common.IO.SurfaceLines; +using Ringtoets.Piping.IO.SurfaceLines; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.IO.Test.SurfaceLines +{ + [TestFixture] + public class PipingSurfaceLineTransformerTest + { + private static IEnumerable MoveCharacteristicPoint + { + get + { + yield return new TestCaseData( + new Action((cp, p) => cp.DikeToeAtRiver = p), + new Func(sl => sl.DikeToeAtRiver), + "Teen dijk buitenwaarts") + .SetName("Move DikeToeAtRiver"); + yield return new TestCaseData( + new Action((cp, p) => cp.BottomDitchDikeSide = p), + new Func(sl => sl.BottomDitchDikeSide), + "Slootbodem dijkzijde") + .SetName("Move BottomDitchDikeSide"); + yield return new TestCaseData( + new Action((cp, p) => cp.BottomDitchPolderSide = p), + new Func(sl => sl.BottomDitchPolderSide), + "Slootbodem polderzijde") + .SetName("Move BottomDitchPolderSide"); + yield return new TestCaseData( + new Action((cp, p) => cp.DitchPolderSide = p), + new Func(sl => sl.DitchPolderSide), + "Insteek sloot polderzijde") + .SetName("Move DitchPolderSide"); + yield return new TestCaseData( + new Action((cp, p) => cp.DitchDikeSide = p), + new Func(sl => sl.DitchDikeSide), + "Insteek sloot dijkzijde") + .SetName("Move DitchDikeSide"); + yield return new TestCaseData( + new Action((cp, p) => cp.DikeToeAtPolder = p), + new Func(sl => sl.DikeToeAtPolder), + "Teen dijk binnenwaarts") + .SetName("Move DikeToeAtPolder"); + } + } + + [Test] + public void Constructor_WithoutReferenceLine_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new PipingSurfaceLineTransformer(null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Transform_SurfaceLineNotOnReferenceLine_ThrowsImportedDataTransformException() + { + // Setup + var referenceLine = new ReferenceLine(); + var transformer = new PipingSurfaceLineTransformer(referenceLine); + + const string surfaceLineName = "somewhere"; + var surfaceLine = new SurfaceLine + { + Name = surfaceLineName + }; + surfaceLine.SetGeometry(new[] + { + new Point3D(3.0, 4.0, 2.1), + new Point3D(3.0, 5.0, 2.1) + }); + referenceLine.SetGeometry(new[] + { + new Point2D(2.0, 4.0) + }); + + // Call + TestDelegate test = () => transformer.Transform(surfaceLine, null); + + // Assert + string message = $"Profielschematisatie {surfaceLineName} doorkruist de huidige referentielijn niet of op meer dan één punt en kan niet worden geïmporteerd. Dit kan komen doordat de profielschematisatie een lokaal coördinaatsysteem heeft."; + var exception = Assert.Throws(test); + Assert.AreEqual(message, exception.Message); + } + + [Test] + public void Transform_SurfaceLineIntersectsReferenceLineMultipleTimes_ThrowsImportedDataTransformException() + { + // Setup + var referenceLine = new ReferenceLine(); + var transformer = new PipingSurfaceLineTransformer(referenceLine); + + const string surfaceLineName = "somewhere"; + var surfaceLine = new SurfaceLine + { + Name = surfaceLineName + }; + surfaceLine.SetGeometry(new[] + { + new Point3D(1.0, 5.0, 2.1), + new Point3D(1.0, 3.0, 2.1) + }); + referenceLine.SetGeometry(new[] + { + new Point2D(0.0, 5.0), + new Point2D(2.0, 4.0), + new Point2D(0.0, 3.0) + }); + + // Call + TestDelegate test = () => transformer.Transform(surfaceLine, null); + + // Assert + string message = $"Profielschematisatie {surfaceLineName} doorkruist de huidige referentielijn niet of op meer dan één punt en kan niet worden geïmporteerd."; + var exception = Assert.Throws(test); + Assert.AreEqual(message, exception.Message); + } + + [Test] + public void Transform_WithoutCharacteristicPoints_ReturnsSurfaceLineWithoutCharacteristicPointsSet() + { + // Setup + var referenceLine = new ReferenceLine(); + var transformer = new PipingSurfaceLineTransformer(referenceLine); + + const string surfaceLineName = "somewhere"; + var surfaceLine = new SurfaceLine + { + Name = surfaceLineName + }; + surfaceLine.SetGeometry(new[] + { + new Point3D(1.0, 5.0, 2.1), + new Point3D(1.0, 3.0, 2.1) + }); + referenceLine.SetGeometry(new[] + { + new Point2D(0.0, 4.0), + new Point2D(2.0, 4.0) + }); + + // Call + PipingSurfaceLine result = transformer.Transform(surfaceLine, null); + + // Assert + Assert.IsNull(result.DitchDikeSide); + Assert.IsNull(result.BottomDitchDikeSide); + Assert.IsNull(result.BottomDitchPolderSide); + Assert.IsNull(result.DitchPolderSide); + Assert.IsNull(result.DikeToeAtPolder); + Assert.IsNull(result.DikeToeAtRiver); + } + + [Test] + [TestCase(2.0)] + [TestCase(3.0)] + [TestCase(3.5)] + public void Transform_DikeToePolderOnOrBeforeDikeToeRiver_ThrowsImportedDataTransformException(double xDikeToePolder) + { + // Setup + var referenceLine = new ReferenceLine(); + var transformer = new PipingSurfaceLineTransformer(referenceLine); + const string locationName = "a location"; + + var random = new Random(21); + double randomY = random.NextDouble(); + double randomZ = random.NextDouble(); + + var surfaceLine = new SurfaceLine(); + surfaceLine.SetGeometry(new[] + { + new Point3D(2.0, randomY, randomZ), + new Point3D(3.0, randomY, randomZ), + new Point3D(3.5, randomY, randomZ), + new Point3D(4.0, randomY, randomZ) + }); + var characteristicPoints = new CharacteristicPoints(locationName) + { + DikeToeAtRiver = new Point3D(3.5, 4, randomZ), + DikeToeAtPolder = new Point3D(xDikeToePolder, 4, randomZ) + }; + + referenceLine.SetGeometry(new[] + { + new Point2D(3.2, randomY - 1), + new Point2D(3.2, randomY + 1) + }); + + // Call + TestDelegate test = () => transformer.Transform(surfaceLine, characteristicPoints); + + // Assert + string message = $"Het uittredepunt moet landwaarts van het intredepunt liggen voor locatie '{locationName}'."; + var exception = Assert.Throws(test); + Assert.AreEqual(message, exception.Message); + } + + [Test] + [TestCaseSource(nameof(MoveCharacteristicPoint))] + public void Transform_CharacteristicPointNotOnSurfaceLine_LogErrorAndReturnSurfaceLineWithoutCharacteristicPointSet(Action pointChange, Func pointWhichIsNull, string changedCharacteristicPointName) + { + // Setup + var referenceLine = new ReferenceLine(); + var transformer = new PipingSurfaceLineTransformer(referenceLine); + const string locationName = "a location"; + + var random = new Random(21); + double randomZ = random.NextDouble(); + + var surfaceLine = new SurfaceLine + { + Name = locationName + }; + + var point1 = new Point3D(3.5, 4.8, randomZ); + var point2 = new Point3D(7.2, 9.3, randomZ); + var point3 = new Point3D(12.0, 5.6, randomZ); + var notOnSurfaceLinePoint = new Point3D(7.3, 9.3, randomZ); + + surfaceLine.SetGeometry(new[] + { + point1, + point2, + point3 + }); + + var characteristicPoints = new CharacteristicPoints(locationName) + { + DikeToeAtRiver = point2, + BottomDitchDikeSide = point2, + BottomDitchPolderSide = point2, + DitchPolderSide = point2, + DitchDikeSide = point3, + DikeToeAtPolder = point3 + }; + + pointChange(characteristicPoints, notOnSurfaceLinePoint); + + referenceLine.SetGeometry(new[] + { + new Point2D(5.6, 2.5), + new Point2D(6.8, 15) + }); + + PipingSurfaceLine result = null; + + // Call + Action call = () => result = transformer.Transform(surfaceLine, characteristicPoints); + + // Assert + string message = $"Karakteristiek punt van profielschematisatie '{locationName}' is overgeslagen. De geometrie bevat geen punt op locatie {notOnSurfaceLinePoint} om als '{changedCharacteristicPointName}' in te stellen."; + TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(message, LogLevelConstant.Error)); + Assert.AreEqual(new[] + { + point1, + point2, + point3 + }, result.Points); + Assert.IsNull(pointWhichIsNull(result)); + Assert.AreEqual(1, new Collection + { + result.DikeToeAtRiver, + result.BottomDitchDikeSide, + result.BottomDitchPolderSide, + result.DitchPolderSide, + result.DitchDikeSide, + result.DikeToeAtPolder + }.Count(p => p == null)); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelImporterConfigurationFactoryTest.cs =================================================================== diff -u -r26f527fb809a2325c8f883ece9da01a8f8040eb3 -rdaa6b36fc2506683c50ba4117790452ae4f45d7f --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelImporterConfigurationFactoryTest.cs (.../StochasticSoilModelImporterConfigurationFactoryTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelImporterConfigurationFactoryTest.cs (.../StochasticSoilModelImporterConfigurationFactoryTest.cs) (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -24,7 +24,7 @@ using Ringtoets.Common.IO.SoilProfile; using Ringtoets.Piping.Data; using Ringtoets.Piping.Data.SoilProfile; -using Ringtoets.Piping.IO.Importers; +using Ringtoets.Piping.IO.SoilProfiles; using Ringtoets.Piping.Plugin.FileImporter; namespace Ringtoets.Piping.Plugin.Test.FileImporter Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/SurfaceLinesCsvImporterConfigurationFactoryTest.cs =================================================================== diff -u -rd6fe8399e8398224cf1bda9259052232d85b85a4 -rdaa6b36fc2506683c50ba4117790452ae4f45d7f --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/SurfaceLinesCsvImporterConfigurationFactoryTest.cs (.../SurfaceLinesCsvImporterConfigurationFactoryTest.cs) (revision d6fe8399e8398224cf1bda9259052232d85b85a4) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/SurfaceLinesCsvImporterConfigurationFactoryTest.cs (.../SurfaceLinesCsvImporterConfigurationFactoryTest.cs) (revision daa6b36fc2506683c50ba4117790452ae4f45d7f) @@ -24,7 +24,7 @@ using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.IO.SurfaceLines; using Ringtoets.Piping.Data; -using Ringtoets.Piping.IO.Importers; +using Ringtoets.Piping.IO.SurfaceLines; using Ringtoets.Piping.Plugin.FileImporter; using Ringtoets.Piping.Primitives;