Fisheye: Tag 00bca55b16694cd9d828d5a0052016b442b78b6b refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Importers/MacroStabilityInwardsSurfaceLineExtensions.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 00bca55b16694cd9d828d5a0052016b442b78b6b refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Importers/MacroStabilityInwardsSurfaceLineTransformer.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Ringtoets.MacroStabilityInwards.IO.csproj
===================================================================
diff -u -rb2d6fb0b948754d598692e76e2dc1a25b311d7e7 -r00bca55b16694cd9d828d5a0052016b442b78b6b
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Ringtoets.MacroStabilityInwards.IO.csproj (.../Ringtoets.MacroStabilityInwards.IO.csproj) (revision b2d6fb0b948754d598692e76e2dc1a25b311d7e7)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Ringtoets.MacroStabilityInwards.IO.csproj (.../Ringtoets.MacroStabilityInwards.IO.csproj) (revision 00bca55b16694cd9d828d5a0052016b442b78b6b)
@@ -50,8 +50,8 @@
-
-
+
+
True
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SurfaceLines/MacroStabilityInwardsSurfaceLineExtensions.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SurfaceLines/MacroStabilityInwardsSurfaceLineExtensions.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SurfaceLines/MacroStabilityInwardsSurfaceLineExtensions.cs (revision 00bca55b16694cd9d828d5a0052016b442b78b6b)
@@ -0,0 +1,397 @@
+// 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.SurfaceLines;
+using Ringtoets.MacroStabilityInwards.Primitives;
+using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources;
+using RingtoetsCommonIoResources = Ringtoets.Common.IO.Properties.Resources;
+using MacroStabilityInwardsIOResources = Ringtoets.MacroStabilityInwards.IO.Properties.Resources;
+
+namespace Ringtoets.MacroStabilityInwards.IO.SurfaceLines
+{
+ ///
+ /// Extension methods for the class.
+ ///
+ public static class MacroStabilityInwardsSurfaceLineExtensions
+ {
+ private static readonly ILog log = LogManager.GetLogger(typeof(MacroStabilityInwardsSurfaceLineExtensions));
+
+ ///
+ /// 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 a mandatory characteristic point is not
+ /// present or not on the given .
+ public static void SetCharacteristicPoints(this MacroStabilityInwardsSurfaceLine surfaceLine, CharacteristicPoints characteristicPoints)
+ {
+ if (surfaceLine == null)
+ {
+ throw new ArgumentNullException(nameof(surfaceLine));
+ }
+
+ if (characteristicPoints == null)
+ {
+ throw new ImportedDataTransformException($"Karakteristieke punten definitie voor profielschematisatie '{surfaceLine.Name}' is verplicht.");
+ }
+
+ surfaceLine.TrySetSurfaceLevelOutside(characteristicPoints.SurfaceLevelOutside);
+ surfaceLine.TrySetDikeToeAtRiver(characteristicPoints.DikeToeAtRiver);
+ surfaceLine.TrySetDikeTopAtPolder(characteristicPoints.DikeTopAtPolder);
+ surfaceLine.TrySetDikeToeAtPolder(characteristicPoints.DikeToeAtPolder);
+ surfaceLine.TrySetSurfaceLevelInside(characteristicPoints.SurfaceLevelInside);
+
+ surfaceLine.TrySetTrafficLoadOutside(characteristicPoints.TrafficLoadOutside);
+ surfaceLine.TrySetTrafficLoadInside(characteristicPoints.TrafficLoadInside);
+ surfaceLine.TrySetShoulderBaseInside(characteristicPoints.ShoulderBaseInside);
+ surfaceLine.TrySetShoulderTopInside(characteristicPoints.ShoulderTopInside);
+ surfaceLine.TrySetDitchDikeSide(characteristicPoints.DitchDikeSide);
+ surfaceLine.TrySetBottomDitchDikeSide(characteristicPoints.BottomDitchDikeSide);
+ surfaceLine.TrySetBottomDitchPolderSide(characteristicPoints.BottomDitchPolderSide);
+ surfaceLine.TrySetDitchPolderSide(characteristicPoints.DitchPolderSide);
+ }
+
+ ///
+ /// 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 MacroStabilityInwardsSurfaceLine surfaceLine, Point3D point)
+ {
+ if (point != null)
+ {
+ try
+ {
+ surfaceLine.SetDitchPolderSideAt(point);
+ }
+ catch (ArgumentException e)
+ {
+ LogOptionalCharacteristicPointError(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 MacroStabilityInwardsSurfaceLine surfaceLine, Point3D point)
+ {
+ if (point != null)
+ {
+ try
+ {
+ surfaceLine.SetBottomDitchPolderSideAt(point);
+ }
+ catch (ArgumentException e)
+ {
+ LogOptionalCharacteristicPointError(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 MacroStabilityInwardsSurfaceLine surfaceLine, Point3D point)
+ {
+ if (point != null)
+ {
+ try
+ {
+ surfaceLine.SetBottomDitchDikeSideAt(point);
+ }
+ catch (ArgumentException e)
+ {
+ LogOptionalCharacteristicPointError(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 MacroStabilityInwardsSurfaceLine surfaceLine, Point3D point)
+ {
+ if (point != null)
+ {
+ try
+ {
+ surfaceLine.SetDitchDikeSideAt(point);
+ }
+ catch (ArgumentException e)
+ {
+ LogOptionalCharacteristicPointError(surfaceLine, e);
+ }
+ }
+ }
+
+ ///
+ /// Tries to set the at the location of
+ /// .
+ ///
+ /// The to set the
+ /// for.
+ /// The point at which to set the .
+ /// Thrown when is null or
+ /// not on the .
+ private static void TrySetSurfaceLevelInside(this MacroStabilityInwardsSurfaceLine surfaceLine, Point3D point)
+ {
+ try
+ {
+ surfaceLine.SetSurfaceLevelInsideAt(point);
+ }
+ catch (ArgumentNullException)
+ {
+ throw CreateMandatoryCharacteristicPointException(CreateMissingMandatoryPointMessage(RingtoetsCommonDataResources.CharacteristicPoint_SurfaceLevelInside), surfaceLine.Name);
+ }
+ catch (ArgumentException e)
+ {
+ throw CreateMandatoryCharacteristicPointException(e.Message, surfaceLine.Name);
+ }
+ }
+
+ ///
+ /// Tries to set the at the location of
+ /// .
+ ///
+ /// The to set the
+ /// for.
+ /// The point at which to set the .
+ /// Thrown when is null or
+ /// not on the .
+ private static void TrySetSurfaceLevelOutside(this MacroStabilityInwardsSurfaceLine surfaceLine, Point3D point)
+ {
+ try
+ {
+ surfaceLine.SetSurfaceLevelOutsideAt(point);
+ }
+ catch (ArgumentNullException)
+ {
+ throw CreateMandatoryCharacteristicPointException(CreateMissingMandatoryPointMessage(RingtoetsCommonDataResources.CharacteristicPoint_SurfaceLevelOutside), surfaceLine.Name);
+ }
+ catch (ArgumentException e)
+ {
+ throw CreateMandatoryCharacteristicPointException(e.Message, surfaceLine.Name);
+ }
+ }
+
+ ///
+ /// Tries to set the at the location of
+ /// .
+ ///
+ /// The to set the
+ /// for.
+ /// The point at which to set the .
+ /// Thrown when is null or
+ /// not on the .
+ private static void TrySetDikeTopAtPolder(this MacroStabilityInwardsSurfaceLine surfaceLine, Point3D point)
+ {
+ try
+ {
+ surfaceLine.SetDikeTopAtPolderAt(point);
+ }
+ catch (ArgumentNullException)
+ {
+ throw CreateMandatoryCharacteristicPointException(CreateMissingMandatoryPointMessage(RingtoetsCommonDataResources.CharacteristicPoint_DikeTopAtPolder), surfaceLine.Name);
+ }
+ catch (ArgumentException e)
+ {
+ throw CreateMandatoryCharacteristicPointException(e.Message, surfaceLine.Name);
+ }
+ }
+
+ ///
+ /// Tries to set the at the location of
+ /// .
+ ///
+ /// The to set the
+ /// for.
+ /// The point at which to set the .
+ private static void TrySetShoulderBaseInside(this MacroStabilityInwardsSurfaceLine surfaceLine, Point3D point)
+ {
+ if (point != null)
+ {
+ try
+ {
+ surfaceLine.SetShoulderBaseInsideAt(point);
+ }
+ catch (ArgumentException e)
+ {
+ LogOptionalCharacteristicPointError(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 TrySetShoulderTopInside(this MacroStabilityInwardsSurfaceLine surfaceLine, Point3D point)
+ {
+ if (point != null)
+ {
+ try
+ {
+ surfaceLine.SetShoulderTopInsideAt(point);
+ }
+ catch (ArgumentException e)
+ {
+ LogOptionalCharacteristicPointError(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 TrySetTrafficLoadInside(this MacroStabilityInwardsSurfaceLine surfaceLine, Point3D point)
+ {
+ if (point != null)
+ {
+ try
+ {
+ surfaceLine.SetTrafficLoadInsideAt(point);
+ }
+ catch (ArgumentException e)
+ {
+ LogOptionalCharacteristicPointError(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 TrySetTrafficLoadOutside(this MacroStabilityInwardsSurfaceLine surfaceLine, Point3D point)
+ {
+ if (point != null)
+ {
+ try
+ {
+ surfaceLine.SetTrafficLoadOutsideAt(point);
+ }
+ catch (ArgumentException e)
+ {
+ LogOptionalCharacteristicPointError(surfaceLine, e);
+ }
+ }
+ }
+
+ ///
+ /// Tries to set the at the location of
+ /// .
+ ///
+ /// The to set the
+ /// for.
+ /// The point at which to set the .
+ /// Thrown when is null or
+ /// not on the .
+ private static void TrySetDikeToeAtRiver(this MacroStabilityInwardsSurfaceLine surfaceLine, Point3D point)
+ {
+ try
+ {
+ surfaceLine.SetDikeToeAtRiverAt(point);
+ }
+ catch (ArgumentNullException)
+ {
+ throw CreateMandatoryCharacteristicPointException(CreateMissingMandatoryPointMessage(RingtoetsCommonDataResources.CharacteristicPoint_DikeToeAtRiver), surfaceLine.Name);
+ }
+ catch (ArgumentException e)
+ {
+ throw CreateMandatoryCharacteristicPointException(e.Message, surfaceLine.Name);
+ }
+ }
+
+ ///
+ /// Tries to set the at the location of
+ /// .
+ ///
+ /// The to set the
+ /// for.
+ /// The point at which to set the .
+ /// Thrown when is null or
+ /// not on the .
+ private static void TrySetDikeToeAtPolder(this MacroStabilityInwardsSurfaceLine surfaceLine, Point3D point)
+ {
+ try
+ {
+ surfaceLine.SetDikeToeAtPolderAt(point);
+ }
+ catch (ArgumentNullException)
+ {
+ throw CreateMandatoryCharacteristicPointException(CreateMissingMandatoryPointMessage(RingtoetsCommonDataResources.CharacteristicPoint_DikeToeAtPolder), surfaceLine.Name);
+ }
+ catch (ArgumentException e)
+ {
+ throw CreateMandatoryCharacteristicPointException(e.Message, surfaceLine.Name);
+ }
+ }
+
+ private static void LogOptionalCharacteristicPointError(MacroStabilityInwardsSurfaceLine surfaceLine, ArgumentException e)
+ {
+ log.ErrorFormat(RingtoetsCommonIoResources.SurfaceLinesCsvImporter_CharacteristicPoint_of_SurfaceLine_0_skipped_cause_1_,
+ surfaceLine.Name,
+ e.Message);
+ }
+
+ private static string CreateMissingMandatoryPointMessage(string surfaceLineName)
+ {
+ return string.Format(MacroStabilityInwardsIOResources.MacroStabilityInwardsSurfaceLineTransformer_CharacteristicPoint_0_is_undefined, surfaceLineName);
+ }
+
+ private static ImportedDataTransformException CreateMandatoryCharacteristicPointException(string exceptionMessage, string surfaceLineName)
+ {
+ string message = string.Format(MacroStabilityInwardsIOResources.SurfaceLinesCsvImporter_SurfaceLine_0_skipped_cause_1_CharacteristicPoint_mandatory, surfaceLineName, exceptionMessage);
+ return new ImportedDataTransformException(message);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SurfaceLines/MacroStabilityInwardsSurfaceLineTransformer.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SurfaceLines/MacroStabilityInwardsSurfaceLineTransformer.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SurfaceLines/MacroStabilityInwardsSurfaceLineTransformer.cs (revision 00bca55b16694cd9d828d5a0052016b442b78b6b)
@@ -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.MacroStabilityInwards.Primitives;
+
+namespace Ringtoets.MacroStabilityInwards.IO.SurfaceLines
+{
+ ///
+ /// Transforms generic into macro stability inwards specific .
+ ///
+ public class MacroStabilityInwardsSurfaceLineTransformer : 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 MacroStabilityInwardsSurfaceLineTransformer(ReferenceLine referenceLine)
+ {
+ if (referenceLine == null)
+ {
+ throw new ArgumentNullException(nameof(referenceLine));
+ }
+ this.referenceLine = referenceLine;
+ }
+
+ public MacroStabilityInwardsSurfaceLine Transform(SurfaceLine surfaceLine, CharacteristicPoints characteristicPoints)
+ {
+ Point2D intersectionPoint = surfaceLine.GetSingleReferenceLineIntersection(referenceLine);
+
+ var macroStabilityInwardsSurfaceLine = new MacroStabilityInwardsSurfaceLine(surfaceLine.Name);
+ macroStabilityInwardsSurfaceLine.SetGeometry(surfaceLine.Points);
+
+ macroStabilityInwardsSurfaceLine.SetCharacteristicPoints(characteristicPoints);
+
+ macroStabilityInwardsSurfaceLine.ReferenceLineIntersectionWorldPoint = intersectionPoint;
+
+ return macroStabilityInwardsSurfaceLine;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Plugin/FileImporter/SurfaceLinesCsvImporterConfigurationFactory.cs
===================================================================
diff -u -rcd90ebf744fb74f0d4b0dd6ee06f9c39b5faf213 -r00bca55b16694cd9d828d5a0052016b442b78b6b
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Plugin/FileImporter/SurfaceLinesCsvImporterConfigurationFactory.cs (.../SurfaceLinesCsvImporterConfigurationFactory.cs) (revision cd90ebf744fb74f0d4b0dd6ee06f9c39b5faf213)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Plugin/FileImporter/SurfaceLinesCsvImporterConfigurationFactory.cs (.../SurfaceLinesCsvImporterConfigurationFactory.cs) (revision 00bca55b16694cd9d828d5a0052016b442b78b6b)
@@ -22,7 +22,7 @@
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.IO.SurfaceLines;
using Ringtoets.MacroStabilityInwards.Data;
-using Ringtoets.MacroStabilityInwards.IO.Importers;
+using Ringtoets.MacroStabilityInwards.IO.SurfaceLines;
using Ringtoets.MacroStabilityInwards.Primitives;
namespace Ringtoets.MacroStabilityInwards.Plugin.FileImporter
Fisheye: Tag 00bca55b16694cd9d828d5a0052016b442b78b6b refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Importers/MacroStabilityInwardsSurfaceLineExtensionsTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Ringtoets.MacroStabilityInwards.IO.Test.csproj
===================================================================
diff -u -r7b7bd75dc1c1327386c9be96b5d480565bb8ecd6 -r00bca55b16694cd9d828d5a0052016b442b78b6b
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Ringtoets.MacroStabilityInwards.IO.Test.csproj (.../Ringtoets.MacroStabilityInwards.IO.Test.csproj) (revision 7b7bd75dc1c1327386c9be96b5d480565bb8ecd6)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Ringtoets.MacroStabilityInwards.IO.Test.csproj (.../Ringtoets.MacroStabilityInwards.IO.Test.csproj) (revision 00bca55b16694cd9d828d5a0052016b442b78b6b)
@@ -78,8 +78,8 @@
-
-
+
+
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SurfaceLines/MacroStabilityInwardsSurfaceLineExtensionsTest.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SurfaceLines/MacroStabilityInwardsSurfaceLineExtensionsTest.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SurfaceLines/MacroStabilityInwardsSurfaceLineExtensionsTest.cs (revision 00bca55b16694cd9d828d5a0052016b442b78b6b)
@@ -0,0 +1,318 @@
+// 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.MacroStabilityInwards.IO.SurfaceLines;
+using Ringtoets.MacroStabilityInwards.Primitives;
+using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources;
+
+namespace Ringtoets.MacroStabilityInwards.IO.Test.SurfaceLines
+{
+ [TestFixture]
+ public class MacroStabilityInwardsSurfaceLineExtensionsTest
+ {
+ private static IEnumerable DifferentCharacteristicPointConfigurationsWithMissingMandatoryPoint
+ {
+ get
+ {
+ var name = "Missing SurfaceLevelOutside";
+ CharacteristicPoints set = CreateCompleteCharacteristicPointSet(name);
+ set.SurfaceLevelOutside = null;
+ yield return new TestCaseData(set, RingtoetsCommonDataResources.CharacteristicPoint_SurfaceLevelOutside).SetName(name);
+
+ name = "Missing DikeToeAtRiver";
+ set = CreateCompleteCharacteristicPointSet(name);
+ set.DikeToeAtRiver = null;
+ yield return new TestCaseData(set, RingtoetsCommonDataResources.CharacteristicPoint_DikeToeAtRiver).SetName(name);
+
+ name = "Missing DikeTopAtPolder";
+ set = CreateCompleteCharacteristicPointSet(name);
+ set.DikeTopAtPolder = null;
+ yield return new TestCaseData(set, RingtoetsCommonDataResources.CharacteristicPoint_DikeTopAtPolder).SetName(name);
+
+ name = "Missing DikeToeAtPolder";
+ set = CreateCompleteCharacteristicPointSet(name);
+ set.DikeToeAtPolder = null;
+ yield return new TestCaseData(set, RingtoetsCommonDataResources.CharacteristicPoint_DikeToeAtPolder).SetName(name);
+
+ name = "Missing SurfaceLevelInside";
+ set = CreateCompleteCharacteristicPointSet(name);
+ set.SurfaceLevelInside = null;
+ yield return new TestCaseData(set, RingtoetsCommonDataResources.CharacteristicPoint_SurfaceLevelInside).SetName(name);
+ }
+ }
+
+ private static IEnumerable DifferentCharacteristicPointConfigurationsWithMandatoryPointNotOnSurfaceLine
+ {
+ get
+ {
+ var name = "Moved SurfaceLevelOutside";
+ CharacteristicPoints set = CreateCompleteCharacteristicPointSet(name);
+ yield return new TestCaseData(
+ set,
+ new Action((points, p) => points.SurfaceLevelOutside = p),
+ RingtoetsCommonDataResources.CharacteristicPoint_SurfaceLevelOutside).SetName(name);
+
+ name = "Moved DikeToeAtRiver";
+ set = CreateCompleteCharacteristicPointSet(name);
+ yield return new TestCaseData(
+ set,
+ new Action((points, p) => points.DikeToeAtRiver = p),
+ RingtoetsCommonDataResources.CharacteristicPoint_DikeToeAtRiver).SetName(name);
+
+ name = "Moved DikeTopAtPolder";
+ set = CreateCompleteCharacteristicPointSet(name);
+ yield return new TestCaseData(
+ set,
+ new Action((points, p) => points.DikeTopAtPolder = p),
+ RingtoetsCommonDataResources.CharacteristicPoint_DikeTopAtPolder).SetName(name);
+
+ name = "Moved DikeToeAtPolder";
+ set = CreateCompleteCharacteristicPointSet(name);
+ yield return new TestCaseData(
+ set,
+ new Action((points, p) => points.DikeToeAtPolder = p),
+ RingtoetsCommonDataResources.CharacteristicPoint_DikeToeAtPolder).SetName(name);
+
+ name = "Moved SurfaceLevelInside";
+ set = CreateCompleteCharacteristicPointSet(name);
+ yield return new TestCaseData(
+ set,
+ new Action((points, p) => points.SurfaceLevelInside = p),
+ RingtoetsCommonDataResources.CharacteristicPoint_SurfaceLevelInside).SetName(name);
+ }
+ }
+
+ private static IEnumerable DifferentValidCharacteristicPointConfigurations
+ {
+ get
+ {
+ var name = "All present";
+ CharacteristicPoints set = CreateCompleteCharacteristicPointSet(name);
+ yield return new TestCaseData(set).SetName(name);
+
+ name = "Missing ShoulderBaseInside";
+ set = CreateCompleteCharacteristicPointSet(name);
+ set.ShoulderBaseInside = null;
+ yield return new TestCaseData(set).SetName(name);
+
+ name = "Missing ShoulderTopInside";
+ set = CreateCompleteCharacteristicPointSet(name);
+ set.ShoulderTopInside = null;
+ yield return new TestCaseData(set).SetName(name);
+
+ name = "Missing TrafficLoadOutside";
+ set = CreateCompleteCharacteristicPointSet(name);
+ set.TrafficLoadOutside = null;
+ yield return new TestCaseData(set).SetName(name);
+
+ name = "Missing TrafficLoadInside";
+ set = CreateCompleteCharacteristicPointSet(name);
+ set.TrafficLoadInside = null;
+ yield return new TestCaseData(set).SetName(name);
+
+ name = "Missing DitchDikeSide";
+ set = CreateCompleteCharacteristicPointSet(name);
+ set.DitchDikeSide = null;
+ yield return new TestCaseData(set).SetName(name);
+
+ name = "Missing BottomDitchDikeSide";
+ set = CreateCompleteCharacteristicPointSet(name);
+ set.BottomDitchDikeSide = null;
+ yield return new TestCaseData(set).SetName(name);
+
+ name = "Missing BottomDitchPolderSide";
+ set = CreateCompleteCharacteristicPointSet(name);
+ set.BottomDitchPolderSide = null;
+ yield return new TestCaseData(set).SetName(name);
+
+ name = "Missing DitchPolderSide";
+ set = CreateCompleteCharacteristicPointSet(name);
+ set.DitchPolderSide = null;
+ yield return new TestCaseData(set).SetName(name);
+ }
+ }
+
+ [Test]
+ public void SetCharacteristicPoints_SurfaceLineNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => ((MacroStabilityInwardsSurfaceLine) null).SetCharacteristicPoints(new CharacteristicPoints("Empty"));
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("surfaceLine", exception.ParamName);
+ }
+
+ [Test]
+ public void SetCharacteristicPoints_CharacteristicPointsNull_ThrowsImportedDataTransformException()
+ {
+ // Setup
+ const string name = "Some line name";
+ var surfaceLine = new MacroStabilityInwardsSurfaceLine(name);
+ 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
+ TestDelegate test = () => surfaceLine.SetCharacteristicPoints(null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual($"Karakteristieke punten definitie voor profielschematisatie '{name}' is verplicht.", exception.Message);
+ }
+
+ [Test]
+ [TestCaseSource(nameof(DifferentValidCharacteristicPointConfigurations))]
+ public void SetCharacteristicPoints_ValidSituations_PointsAreSet(CharacteristicPoints points)
+ {
+ // Setup
+ var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);
+ surfaceLine.SetGeometry(CharacteristicPointsToGeometry(points));
+
+ // Call
+ surfaceLine.SetCharacteristicPoints(points);
+
+ // Assert
+ Assert.AreEqual(points.DikeTopAtPolder, surfaceLine.DikeTopAtPolder);
+ Assert.AreEqual(points.ShoulderBaseInside, surfaceLine.ShoulderBaseInside);
+ Assert.AreEqual(points.ShoulderTopInside, surfaceLine.ShoulderTopInside);
+ Assert.AreEqual(points.TrafficLoadOutside, surfaceLine.TrafficLoadOutside);
+ Assert.AreEqual(points.TrafficLoadInside, surfaceLine.TrafficLoadInside);
+ Assert.AreEqual(points.SurfaceLevelOutside, surfaceLine.SurfaceLevelOutside);
+ Assert.AreEqual(points.SurfaceLevelInside, surfaceLine.SurfaceLevelInside);
+ 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);
+ }
+
+ [Test]
+ [TestCaseSource(nameof(DifferentCharacteristicPointConfigurationsWithMissingMandatoryPoint))]
+ public void SetCharacteristicPoints_UndefinedMandatoryPoint_ThrowsImportedDataTransformException(CharacteristicPoints points, string pointDescription)
+ {
+ // Setup
+ var surfaceLine = new MacroStabilityInwardsSurfaceLine(points.Name);
+ surfaceLine.SetGeometry(CharacteristicPointsToGeometry(points));
+
+ // Call
+ TestDelegate test = () => surfaceLine.SetCharacteristicPoints(points);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ string message = $"Profielschematisatie '{points.Name}' kan niet gebruikt worden. Karakteristiek punt \'{pointDescription}\' is niet gedefiniëerd. Dit karakteristieke punt is verplicht.";
+ Assert.AreEqual(message, exception.Message);
+ }
+
+ [Test]
+ [TestCaseSource(nameof(DifferentCharacteristicPointConfigurationsWithMandatoryPointNotOnSurfaceLine))]
+ public void SetCharacteristicPoints_MandatoryPointNotOnSurfaceLine_ThrowsImportedDataTransformException(
+ CharacteristicPoints points,
+ Action setPoint,
+ string pointDescription)
+ {
+ // Setup
+ var surfaceLine = new MacroStabilityInwardsSurfaceLine(points.Name);
+ surfaceLine.SetGeometry(CharacteristicPointsToGeometry(points));
+
+ var changedPoint = new Point3D(-1, -1, -1);
+ setPoint(points, changedPoint);
+
+ // Call
+ TestDelegate test = () => surfaceLine.SetCharacteristicPoints(points);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ string message = $"Profielschematisatie '{points.Name}' kan niet gebruikt worden. " +
+ $"De geometrie bevat geen punt op locatie {changedPoint} om als \'{pointDescription}\' in te stellen. " +
+ "Dit karakteristieke punt is verplicht.";
+ Assert.AreEqual(message, exception.Message);
+ }
+
+ private static IEnumerable CharacteristicPointsToGeometry(CharacteristicPoints points)
+ {
+ return new[]
+ {
+ points.DikeTopAtPolder,
+ points.ShoulderBaseInside,
+ points.ShoulderTopInside,
+ points.TrafficLoadOutside,
+ points.TrafficLoadInside,
+ points.SurfaceLevelOutside,
+ points.SurfaceLevelInside,
+ points.DikeToeAtRiver,
+ points.DikeToeAtPolder,
+ points.DitchDikeSide,
+ points.BottomDitchDikeSide,
+ points.BottomDitchPolderSide,
+ points.DitchPolderSide
+ }.Where(p => p != null);
+ }
+
+ private static CharacteristicPoints CreateCompleteCharacteristicPointSet(string name)
+ {
+ var surfaceLevelOutside = new Point3D(2, 2, 5);
+ var dikeToeAtRiver = new Point3D(2.1, 2, 5);
+ var trafficLoadOutside = new Point3D(2.25, 2, 5);
+ var trafficLoadInside = new Point3D(2.45, 2, 5);
+ var dikeTopAtPolder = new Point3D(2.7, 2, 5);
+ var shoulderBaseInside = new Point3D(3.2, 2, 5);
+ var shoulderTopInside = new Point3D(3.5, 2, 5);
+ var dikeToeAtPolder = new Point3D(4.4, 3, 8);
+ var ditchDikeSide = new Point3D(6.3, 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 surfaceLevelInside = new Point3D(10.1, 2, 5);
+
+ return new CharacteristicPoints(name)
+ {
+ DikeTopAtPolder = dikeTopAtPolder,
+ ShoulderBaseInside = shoulderBaseInside,
+ ShoulderTopInside = shoulderTopInside,
+ TrafficLoadOutside = trafficLoadOutside,
+ TrafficLoadInside = trafficLoadInside,
+ SurfaceLevelOutside = surfaceLevelOutside,
+ SurfaceLevelInside = surfaceLevelInside,
+ DikeToeAtRiver = dikeToeAtRiver,
+ DikeToeAtPolder = dikeToeAtPolder,
+ DitchDikeSide = ditchDikeSide,
+ BottomDitchDikeSide = bottomDitchDikeSide,
+ BottomDitchPolderSide = bottomDitchPolderSide,
+ DitchPolderSide = ditchPolderSide
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SurfaceLines/MacrostabilityInwardsSurfaceLineTransformerTest.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SurfaceLines/MacrostabilityInwardsSurfaceLineTransformerTest.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SurfaceLines/MacrostabilityInwardsSurfaceLineTransformerTest.cs (revision 00bca55b16694cd9d828d5a0052016b442b78b6b)
@@ -0,0 +1,393 @@
+// 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.MacroStabilityInwards.IO.SurfaceLines;
+using Ringtoets.MacroStabilityInwards.Primitives;
+
+namespace Ringtoets.MacroStabilityInwards.IO.Test.SurfaceLines
+{
+ [TestFixture]
+ public class MacroStabilityInwardsSurfaceLineTransformerTest
+ {
+ private static IEnumerable MoveOptionalCharacteristicPoint
+ {
+ get
+ {
+ yield return new TestCaseData(
+ new Action((cp, p) => cp.TrafficLoadOutside = p),
+ new Func(sl => sl.TrafficLoadOutside),
+ "Verkeersbelasting kant buitenwaarts")
+ .SetName("Move TrafficLoadOutside");
+ yield return new TestCaseData(
+ new Action((cp, p) => cp.TrafficLoadInside = p),
+ new Func(sl => sl.TrafficLoadInside),
+ "Verkeersbelasting kant binnenwaarts")
+ .SetName("Move TrafficLoadInside");
+ yield return new TestCaseData(
+ new Action((cp, p) => cp.ShoulderBaseInside = p),
+ new Func(sl => sl.ShoulderBaseInside),
+ "Insteek binnenberm")
+ .SetName("Move ShoulderBaseInside");
+ yield return new TestCaseData(
+ new Action((cp, p) => cp.ShoulderTopInside = p),
+ new Func(sl => sl.ShoulderTopInside),
+ "Kruin binnenberm")
+ .SetName("Move ShoulderTopInside");
+ 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.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");
+ }
+ }
+
+ private static IEnumerable MoveMandatoryCharacteristicPoint
+ {
+ get
+ {
+ yield return new TestCaseData(
+ new Action((cp, p) => cp.SurfaceLevelOutside = p),
+ new Func(sl => sl.SurfaceLevelOutside),
+ "Maaiveld buitenwaarts")
+ .SetName("Move SurfaceLevelOutside");
+ 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.DikeTopAtPolder = p),
+ new Func(sl => sl.DikeTopAtPolder),
+ "Kruin binnentalud")
+ .SetName("Move DikeTopAtPolder");
+ yield return new TestCaseData(
+ new Action((cp, p) => cp.DikeToeAtPolder = p),
+ new Func(sl => sl.DikeToeAtPolder),
+ "Teen dijk binnenwaarts")
+ .SetName("Move DikeToeAtPolder");
+ yield return new TestCaseData(
+ new Action((cp, p) => cp.SurfaceLevelInside = p),
+ new Func(sl => sl.SurfaceLevelInside),
+ "Maaiveld binnenwaarts")
+ .SetName("Move SurfaceLevelInside");
+ }
+ }
+
+ [Test]
+ public void Constructor_WithoutReferenceLine_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new MacroStabilityInwardsSurfaceLineTransformer(null);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Transform_SurfaceLineNotOnReferenceLine_ThrowsImportedDataTransformException()
+ {
+ // Setup
+ var referenceLine = new ReferenceLine();
+ var transformer = new MacroStabilityInwardsSurfaceLineTransformer(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 MacroStabilityInwardsSurfaceLineTransformer(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_ThrowsImportedDataTransformException()
+ {
+ // Setup
+ var referenceLine = new ReferenceLine();
+ var transformer = new MacroStabilityInwardsSurfaceLineTransformer(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);
+
+ surfaceLine.SetGeometry(new[]
+ {
+ point1,
+ point2,
+ point3
+ });
+
+ referenceLine.SetGeometry(new[]
+ {
+ new Point2D(5.6, 2.5),
+ new Point2D(6.8, 15)
+ });
+
+ MacroStabilityInwardsSurfaceLine result = null;
+
+ // Call
+ TestDelegate test = () => result = transformer.Transform(surfaceLine, null);
+
+ // Assert
+ string message = $"Karakteristieke punten definitie voor profielschematisatie '{locationName}' is verplicht.";
+ var exception = Assert.Throws(test);
+ Assert.AreEqual(message, exception.Message);
+ Assert.IsNull(result);
+ }
+
+ [Test]
+ [TestCaseSource(nameof(MoveOptionalCharacteristicPoint))]
+ public void Transform_OptionalCharacteristicPointNotOnSurfaceLine_LogErrorAndReturnSurfaceLineWithoutCharacteristicPointSet(Action pointChange, Func pointWhichIsNull, string changedCharacteristicPointName)
+ {
+ // Setup
+ var referenceLine = new ReferenceLine();
+ var transformer = new MacroStabilityInwardsSurfaceLineTransformer(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)
+ {
+ SurfaceLevelOutside = point2,
+ DikeToeAtRiver = point2,
+ TrafficLoadOutside = point2,
+ TrafficLoadInside = point2,
+ DikeTopAtPolder = point2,
+ ShoulderBaseInside = point3,
+ ShoulderTopInside = point3,
+ BottomDitchDikeSide = point3,
+ BottomDitchPolderSide = point3,
+ DitchPolderSide = point3,
+ DitchDikeSide = point3,
+ DikeToeAtPolder = point3,
+ SurfaceLevelInside = point3
+ };
+
+ pointChange(characteristicPoints, notOnSurfaceLinePoint);
+
+ referenceLine.SetGeometry(new[]
+ {
+ new Point2D(5.6, 2.5),
+ new Point2D(6.8, 15)
+ });
+
+ MacroStabilityInwardsSurfaceLine 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.SurfaceLevelOutside,
+ result.DikeToeAtRiver,
+ result.TrafficLoadOutside,
+ result.TrafficLoadInside,
+ result.DikeTopAtPolder,
+ result.ShoulderBaseInside,
+ result.ShoulderTopInside,
+ result.BottomDitchDikeSide,
+ result.BottomDitchPolderSide,
+ result.DitchPolderSide,
+ result.DitchDikeSide,
+ result.DikeToeAtPolder,
+ result.SurfaceLevelInside
+ }.Count(p => p == null));
+ }
+
+ [Test]
+ [TestCaseSource(nameof(MoveMandatoryCharacteristicPoint))]
+ public void Transform_MandatoryCharacteristicPointNotOnSurfaceLine_ThrowsImportedDataTransformException(
+ Action pointChange,
+ Func pointWhichIsNull,
+ string changedCharacteristicPointName)
+ {
+ // Setup
+ var referenceLine = new ReferenceLine();
+ var transformer = new MacroStabilityInwardsSurfaceLineTransformer(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)
+ {
+ SurfaceLevelOutside = point2,
+ DikeToeAtRiver = point2,
+ TrafficLoadOutside = point2,
+ TrafficLoadInside = point2,
+ DikeTopAtPolder = point2,
+ ShoulderBaseInside = point3,
+ ShoulderTopInside = point3,
+ BottomDitchDikeSide = point3,
+ BottomDitchPolderSide = point3,
+ DitchPolderSide = point3,
+ DitchDikeSide = point3,
+ DikeToeAtPolder = point3,
+ SurfaceLevelInside = point3
+ };
+
+ pointChange(characteristicPoints, notOnSurfaceLinePoint);
+
+ referenceLine.SetGeometry(new[]
+ {
+ new Point2D(5.6, 2.5),
+ new Point2D(6.8, 15)
+ });
+
+ // Call
+ TestDelegate test = () => transformer.Transform(surfaceLine, characteristicPoints);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ string message = $"Profielschematisatie '{locationName}' kan niet gebruikt worden. " +
+ $"De geometrie bevat geen punt op locatie {notOnSurfaceLinePoint} om als \'{changedCharacteristicPointName}\' in te stellen. " +
+ "Dit karakteristieke punt is verplicht.";
+ Assert.AreEqual(message, exception.Message);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/FileImporter/SurfaceLinesCsvImporterConfigurationFactoryTest.cs
===================================================================
diff -u -rcd90ebf744fb74f0d4b0dd6ee06f9c39b5faf213 -r00bca55b16694cd9d828d5a0052016b442b78b6b
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/FileImporter/SurfaceLinesCsvImporterConfigurationFactoryTest.cs (.../SurfaceLinesCsvImporterConfigurationFactoryTest.cs) (revision cd90ebf744fb74f0d4b0dd6ee06f9c39b5faf213)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/FileImporter/SurfaceLinesCsvImporterConfigurationFactoryTest.cs (.../SurfaceLinesCsvImporterConfigurationFactoryTest.cs) (revision 00bca55b16694cd9d828d5a0052016b442b78b6b)
@@ -24,7 +24,7 @@
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.IO.SurfaceLines;
using Ringtoets.MacroStabilityInwards.Data;
-using Ringtoets.MacroStabilityInwards.IO.Importers;
+using Ringtoets.MacroStabilityInwards.IO.SurfaceLines;
using Ringtoets.MacroStabilityInwards.Plugin.FileImporter;
using Ringtoets.MacroStabilityInwards.Primitives;