// 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.Globalization; using System.IO; using System.Threading; using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.Interface; using Deltares.DamEngine.TestHelpers; using NUnit.Framework; namespace Deltares.DamEngine.IntegrationTests.IntegrationTests; [TestFixture] public class IssuesTests { private const string mapTestFiles = @"TestFiles\"; //const string visualizationFolder = @"C:\Dam\DamTools\GeometryVisualizer\"; //#John, for debugging purposes [Test] public void TestGeometryAndResultForIssueMWDAM_2349() { const string inputFilename = "InputFileDWP2.xml"; string fullInputFilename = Path.Combine(mapTestFiles, inputFilename); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; string inputString = File.ReadAllText(fullInputFilename); var outputName = "OutputForDebugging.xml"; var engineInterface = new EngineInterface(inputString); GeometryData geometry = engineInterface.DamProjectData.Segments[1].SoilProfileProbabilities[0].SoilProfile2D.Geometry; SurfaceLine2 surfaceLine = engineInterface.DamProjectData.Dike.Locations[0].SurfaceLine; Soil soil = engineInterface.DamProjectData.Dike.SoilList.Soils[0]; // To be able to check the geometry, create it here. SoilProfile2D soilProfile2D = SoilProfile2DSurfaceLineHelper.CombineSurfaceLineWithSoilProfile2D(surfaceLine.Geometry, engineInterface.DamProjectData.Segments[1].SoilProfileProbabilities[0].SoilProfile2D, soil, 0.0); //geometry = sp2.Geometry; // For debugging purposes based on the visualization of the geometry (tool Tom) //GeometryExporter.ExportToFile(geometry, visualizationFolder + "Geometry.txt"); //GeometryExporter.ExportToJsonFile(geometry, visualizationFolder + "Geometry.json"); Assert.Multiple(() => { Assert.That(soilProfile2D.Geometry.Surfaces, Has.Count.EqualTo(15)); Assert.That(soilProfile2D.Geometry.Curves, Has.Count.EqualTo(97)); Assert.That(soilProfile2D.Geometry.Points, Has.Count.EqualTo(83)); }); GeneralHelper.RunAfterInputValidation(engineInterface, true, outputName); int errorCount = GeneralHelper.DetermineNumberOfCalculationErrors(engineInterface.DamProjectData.CalculationMessages); Assert.Multiple(() => { Assert.That(errorCount, Is.EqualTo(0), "There should be no errors during the calculation."); Assert.That(engineInterface.DamProjectData.DesignCalculations, Has.Count.EqualTo(1), "There should be one design calculation."); Assert.That(engineInterface.DamProjectData.DesignCalculations[0].SafetyFactor, Is.EqualTo(1.435).Within(0.001), "The safety factor should be 1.435."); }); } }