Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryGenerator.cs =================================================================== diff -u -r5220 -r5222 --- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryGenerator.cs (.../GeometryGenerator.cs) (revision 5220) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryGenerator.cs (.../GeometryGenerator.cs) (revision 5222) @@ -1051,7 +1051,7 @@ } } - private static void DeterminePointClosestToLine(Point2D point1, Point2D point2, GeometryCurve line, + protected internal static void DeterminePointClosestToLine(Point2D point1, Point2D point2, GeometryCurve line, ref bool isPoint1ClosestToLine, ref bool isPoint2ClosestToLine) { double distance1 = Routines2D.CalculateDistanceToLine(point1.X, point1.Z, @@ -1066,8 +1066,8 @@ isPoint2ClosestToLine = false; } - private static void DeterminePointClosestToAnotherPoint(Point2D point1, Point2D point2, Point2D point3, - ref bool isPoint1ClosestToPoint3, ref bool isPoint2ClosestToPoint3) + protected internal static void DeterminePointClosestToAnotherPoint(Point2D point1, Point2D point2, Point2D point3, + ref bool isPoint1ClosestToPoint3, ref bool isPoint2ClosestToPoint3) { double distance1 = Routines2D.Compute2DDistance(point1.X, point1.Z, point3.X, point3.Z); double distance2 = Routines2D.Compute2DDistance(point2.X, point2.Z, point3.X, point3.Z); Index: DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geometry/GeometryGeneratorTests.cs =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geometry/GeometryGeneratorTests.cs (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geometry/GeometryGeneratorTests.cs (revision 5222) @@ -0,0 +1,74 @@ +// Copyright (C) Stichting Deltares 2024. All rights reserved. +// +// This file is part of the Dam Engine. +// +// The Dam Engine is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero 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.Security.Cryptography.X509Certificates; +using Deltares.DamEngine.Data.Geometry; +using NUnit.Framework; + +namespace Deltares.DamEngine.Data.Tests.Geometry; + +[TestFixture] +public class GeometryGeneratorTests +{ + [TestCase(0.52, 0.51, false, true)] + [TestCase(0.51, 0.52, true, false)] + [TestCase(0.51, 0.51, true, false)] + [Test] + public void WhenDeterminePointClosestToLine_ThenResultIsAsExpected(double x1, double x2, bool isPoint1Closest, bool isPoint2Closest) + { + // Given + var line = new GeometryCurve(new Point2D(0.0, 0.0), new Point2D(1.0, 1.0)); + var point1 = new Point2D(x1, 0.5); + var point2 = new Point2D(x2, 0.5); + var isPoint1ClosestToLine = true; + var isPoint2ClosestToLine = true; + // When + GeometryGenerator.DeterminePointClosestToLine(point1, point2, line, ref isPoint1ClosestToLine, ref isPoint2ClosestToLine); + Assert.Multiple(() => + { + // Then + Assert.That(isPoint1ClosestToLine, Is.EqualTo(isPoint1Closest)); + Assert.That(isPoint2ClosestToLine, Is.EqualTo(isPoint2Closest)); + }); + } + + [TestCase(0.52, 0.51, false, true)] + [TestCase(0.51, 0.52, true, false)] + [TestCase(0.51, 0.51, true, false)] + [Test] + public void WhenDeterminePointClosestToAnotherPoint_ThenResultIsAsExpected(double x1, double x2, bool isPoint1Closest, bool isPoint2Closest) + { + // Given + var point1 = new Point2D(x1, 0.5); + var point2 = new Point2D(x2, 0.5); + var point3 = new Point2D(0.5, 0.5); + var isPoint1ClosestToPoint3 = true; + var isPoint2ClosestToPoint3 = true; + // When + GeometryGenerator.DeterminePointClosestToAnotherPoint(point1, point2, point3, ref isPoint1ClosestToPoint3, ref isPoint2ClosestToPoint3); + Assert.Multiple(() => + { + // Then + Assert.That(isPoint1ClosestToPoint3, Is.EqualTo(isPoint1Closest)); + Assert.That(isPoint2ClosestToPoint3, Is.EqualTo(isPoint2Closest)); + }); + } +} \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Deltares.DamEngine.Data.csproj =================================================================== diff -u -r4898 -r5222 --- DamEngine/trunk/src/Deltares.DamEngine.Data/Deltares.DamEngine.Data.csproj (.../Deltares.DamEngine.Data.csproj) (revision 4898) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/Deltares.DamEngine.Data.csproj (.../Deltares.DamEngine.Data.csproj) (revision 5222) @@ -10,5 +10,8 @@ <_Parameter1>Deltares.DamEngine.Interface.Tests + + <_Parameter1>Deltares.DamEngine.Data.Tests +