// 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 Deltares.DamEngine.Data.Standard; using KellermanSoftware.CompareNetObjects; using NUnit.Framework; namespace Deltares.DamEngine.Data.Tests.Standard; /// /// Tests to check the ArrayExtensions /// [TestFixture] public class ArrayExtensionsTest { /// /// Test to check the ForEach void in ArrayExtensions /// [Test] public void ForEachTest() { var compare = new CompareLogic { Config = { MaxDifferences = 100 } }; // initialise double array var doubleArray = new double[5]; // assign values to array doubleArray.ForEach((array, indices) => array.SetValue(5, indices)); //assert for (var i = 0; i < 5; i++) { Assert.That(doubleArray[i], Is.EqualTo(5)); } // initialise geometryPoint Arrays var geometryPointArray = new ObjectCopierTest.TestPoint[5]; var geometryPointArray2 = new ObjectCopierTest.TestPoint[5]; // assign values to the first geometryPoint array for (var i = 0; i < 5; i++) { var geometryPoint = new ObjectCopierTest.TestPoint(); geometryPointArray[i] = geometryPoint; geometryPointArray[i].X = i; geometryPointArray[i].Z = i; } // copy the values of the first geometryPoint array to the second geometryPoint array geometryPointArray2.ForEach((array, indices) => array.SetValue(geometryPointArray.GetValue(indices), indices)); ComparisonResult result = compare.Compare(geometryPointArray, geometryPointArray2); Assert.That(result.Differences.Count, Is.EqualTo(0)); } }