// 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.Calculators.KernelWrappers.MacroStabilityCommon; using Deltares.MacroStability.CSharpWrapper; using KellermanSoftware.CompareNetObjects; using NUnit.Framework; using UpliftVanCalculationGrid = Deltares.MacroStability.CSharpWrapper.UpliftVanCalculationGrid; namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.MacroStabilityCommon; [TestFixture] public class CSharpWrapperConvertersTests { [Test] public void GivenCSharpWrapperBishopCalculationCircleWhenConvertingToAndFromEngineBishopCalculationGridThenReturnsSameObject() { var expectedBishopCalculationCircle = new BishopCalculationCircle { Grid = new CalculationGrid { GridXLeft = 0.0, GridXRight = 10.0, GridXNumber = 100, GridZTop = 5.0, GridZBottom = 0.0, GridZNumber = 50 }, TangentLines = new List { 5.0, 4.0, 3.0, 2.0, 1.0 } }; BishopCalculationGrid engineBishopCalculationGrid = CSharpWrapperConverters.CreateEngineBishopCalculationGrid(expectedBishopCalculationCircle); BishopCalculationCircle actualBishopCalculationCircle = CSharpWrapperConverters.CreateWrapperBishopCalculationCircle(engineBishopCalculationGrid); var compare = new CompareLogic { Config = { MaxDifferences = 100 } }; ComparisonResult result = compare.Compare(expectedBishopCalculationCircle, actualBishopCalculationCircle); Assert.That(result.Differences, Is.Empty, "Differences found converting to and from engine BishopCalculationGrid"); } [Test] public void GivenCSharpWrapperUpliftVanCalculationGridWhenConvertingToAndFromEngineUpliftVanCalculationGridThenReturnsSameObject() { var expectedUpliftVanCalculationGrid = new UpliftVanCalculationGrid { LeftGrid = new CalculationGrid { GridXLeft = 0.0, GridXRight = 10.0, GridXNumber = 100, GridZTop = 5.0, GridZBottom = 0.0, GridZNumber = 50 }, RightGrid = new CalculationGrid { GridXLeft = 200.0, GridXRight = 30.0, GridXNumber = 100, GridZTop = 15.0, GridZBottom = 10.0, GridZNumber = 50 }, TangentLines = new List { 5.0, 4.0, 3.0, 2.0, 1.0 } }; Calculators.KernelWrappers.MacroStabilityCommon.UpliftVanCalculationGrid engineUpliftVanCalculationGrid = CSharpWrapperConverters.CreateEngineUpliftVanCalculationGrid(expectedUpliftVanCalculationGrid); UpliftVanCalculationGrid actualUpliftVanCalculationGrid = CSharpWrapperConverters.CreateWrapperUpliftVanCalculationGrid(engineUpliftVanCalculationGrid); var compare = new CompareLogic { Config = { MaxDifferences = 100 } }; ComparisonResult result = compare.Compare(expectedUpliftVanCalculationGrid, actualUpliftVanCalculationGrid); Assert.That(result.Differences, Is.Empty, "Differences found converting to and from engine UpliftVanCalculationGrid"); } }