// Copyright (C) Stichting Deltares 2025. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI 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 System; using System.Collections.Generic; using System.IO; using Deltares.Dam.Data; using Deltares.Dam.Data.CsvImporters; using Deltares.Dam.TestHelper.TestUtils; using Deltares.Geometry; using Deltares.Geotechnics.SurfaceLines; using NUnit.Framework; namespace Deltares.Dam.Tests { [TestFixture] public class CsvExportCharacteristicPointsTest { string importFolder; string fileNameCharacteristicPoints; [SetUp] public void FixtureSetup() { importFolder = Directory.GetCurrentDirectory() + "\\TmpImportFiles"; fileNameCharacteristicPoints = importFolder + "\\ExportCharacteristicPoints.csv"; if (!Directory.Exists(importFolder)) { Directory.CreateDirectory(importFolder); } } [Test] public void CanWriteTutorial1CharacteristicPoints() { // Write characteristic points using (SurfaceLine2 orgSurfaceLine = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1()) { var csvExportSurfaceLineIdentifiers = new CsvExportSurfaceLineIdentifiers { LocationId = "Location", SoilProfileId = "SoilProfile", Scenario = "Scenario", CalculationMechanism = "Mechanism", CalculationModel = "Model" }; var csvExportCharacteristicPoints = new CsvExportCharacteristicPoints(csvExportSurfaceLineIdentifiers, orgSurfaceLine); var creator = new CsvExporter(fileNameCharacteristicPoints, new List { csvExportCharacteristicPoints }) { WriteHeaderInFirstLine = true }; creator.WriteFile(); // Read characteristic points var csvImporterCharacteristicPoints = new CsvImporterCharacteristicPoints(fileNameCharacteristicPoints); IList surfaclinesCharacteristicPoints = csvImporterCharacteristicPoints.ImportedItems; CsvImporterCharacteristicPoints.CharacteristicPointsRecord currentSurfaceLine = surfaclinesCharacteristicPoints[0]; foreach (CsvImporterCharacteristicPoints.CharPoint characteristicPoint in currentSurfaceLine.Points) { GeometryPoint point = orgSurfaceLine.CharacteristicPoints.GetGeometryPoint(characteristicPoint.Type); if (point != null) { Assert.That(point.LocationEquals(new GeometryPoint(characteristicPoint.X, characteristicPoint.Y, characteristicPoint.Z)), Is.True, String.Format("Characteristic point '{0}' not equal", characteristicPoint.Type.ToString())); } } } } } }