// Copyright (C) Stichting Deltares 2025. 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.Collections.Generic;
using Deltares.DamEngine.Data.Geometry;
using NUnit.Framework;
namespace Deltares.DamEngine.Data.Tests.Geometry;
[TestFixture]
public class LineHelperTests
{
[Test]
public void Given2DPointsListWithDuplicatedPoints_WhenRemovingDuplicatedPoints_ThenCorrectListReturned()
{
var pointList = new List();
// The list contains only 2 times coinciding points => expected 3 points
pointList.Add(new Point2D(2, 3));
pointList.Add(new Point2D(2, 3));
pointList.Add(new Point2D(4, 3));
pointList.Add(new Point2D(2, 3));
pointList.Add(new Point2D(2, 3));
pointList.Add(new Point2D(2, 3));
pointList.Add(new Point2D(1, 2));
pointList.Add(new Point2D(1, 2));
LineHelper.RemoveDuplicatedPoints(pointList, 1e-12);
Assert.That(pointList, Has.Count.EqualTo(4));
Assert.Multiple(() =>
{
Assert.That(pointList[0].X, Is.EqualTo(2));
Assert.That(pointList[0].Z, Is.EqualTo(3));
Assert.That(pointList[1].X, Is.EqualTo(4));
Assert.That(pointList[1].Z, Is.EqualTo(3));
Assert.That(pointList[2].X, Is.EqualTo(2));
Assert.That(pointList[2].Z, Is.EqualTo(3));
Assert.That(pointList[3].X, Is.EqualTo(1));
Assert.That(pointList[3].Z, Is.EqualTo(2));
});
}
}