// Copyright (C) Stichting Deltares 2021. 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 Deltares.Dam.Data.CsvImporters; using Deltares.Dam.TestHelper.TestUtils; using Deltares.Geometry; using Deltares.Geotechnics.SurfaceLines; namespace Deltares.Dam.Tests { using System; using System.Collections.Generic; using System.IO; using NUnit.Framework; using Deltares.Dam.Data; [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 CsvImporterCharacteristicPoints csvImporterCharacteristicPoints = new CsvImporterCharacteristicPoints(fileNameCharacteristicPoints); IList surfaclinesCharacteristicPoints = csvImporterCharacteristicPoints.ImportedItems; var currentSurfaceLine = surfaclinesCharacteristicPoints[0]; foreach (var characteristicPoint in currentSurfaceLine.Points) { var point = orgSurfaceLine.CharacteristicPoints.GetGeometryPoint(characteristicPoint.Type); if (point != null) { Assert.IsTrue(point.LocationEquals(new GeometryPoint(characteristicPoint.X, characteristicPoint.Y, characteristicPoint.Z)), String.Format("Characteristic point '{0}' not equal", characteristicPoint.Type.ToString())); } } } } } }