// Copyright (C) Stichting Deltares 2018. All rights reserved.
//
// This file is part of the Delta Shell Light Library.
//
// The Delta Shell Light Library 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 KellermanSoftware.CompareNetObjects;
using Deltares.DamEngine.Data.Standard;
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 (int i = 0; i < 5; i++)
{
Assert.AreEqual(5, doubleArray[i]);
}
// initialise geometryPoint Arrays
var geometryPointArray = new ObjectCopierTest.TestPoint[5];
var geometryPointArray2 = new ObjectCopierTest.TestPoint[5];
// assign values to the first geometryPoint array
for (int 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));
var result = compare.Compare(geometryPointArray, geometryPointArray2);
Assert.AreEqual(0, result.Differences.Count);
}
}
}