Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/StixFileReaderHelper.cs =================================================================== diff -u -r4247 -r4249 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/StixFileReaderHelper.cs (.../StixFileReaderHelper.cs) (revision 4247) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/StixFileReaderHelper.cs (.../StixFileReaderHelper.cs) (revision 4249) @@ -25,14 +25,14 @@ namespace Deltares.Dam.StixFileReader; /// -/// Helper class for . +/// Helper class for . /// public abstract class StixFileReaderHelper { private const string stixFileExtension = ".stix"; /// - /// Returns the file name including the stix file extension/>. + /// Returns the file name including the stix file extension/>. /// /// The file name. public static string FetchFileNameWithStixExtension(string fileName) Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/StixFileReadException.cs =================================================================== diff -u -r4247 -r4249 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/StixFileReadException.cs (.../StixFileReadException.cs) (revision 4247) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/StixFileReadException.cs (.../StixFileReadException.cs) (revision 4249) @@ -22,46 +22,57 @@ using System; using System.Runtime.Serialization; -namespace Deltares.Dam.Data.StiImporter; +namespace Deltares.Dam.StixFileReader; /// -/// Exception thrown when reading a stix file went wrong. +/// Exception thrown when reading a stix file went wrong. /// [Serializable] public class StixFileReadException : Exception { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public StixFileReadException() {} /// - /// Initializes a new instance of the class - /// with a specified error message. + /// Initializes a new instance of the class + /// with a specified error message. /// /// The message that describes the error. public StixFileReadException(string message) : base(message) {} /// - /// Initializes a new instance of the class with a specified error message - /// and a reference to the inner exception that is the cause of this exception. + /// Initializes a new instance of the class with a specified error message + /// and a reference to the inner exception that is the cause of this exception. /// /// The error message that explains the reason for the exception. - /// The exception that is the cause of the current exception, - /// or null if no inner exception is specified. + /// + /// The exception that is the cause of the current exception, + /// or null if no inner exception is specified. + /// public StixFileReadException(string message, Exception innerException) : base(message, innerException) {} /// - /// Initializes a new instance of with - /// serialized data. - /// The that holds the serialized - /// object data about the exception being thrown. - /// The that contains contextual - /// information about the source or destination. - /// The parameter is - /// null. - /// The class name is null or - /// is zero (0). + /// Initializes a new instance of with + /// serialized data. + /// + /// + /// The that holds the serialized + /// object data about the exception being thrown. + /// + /// + /// The that contains contextual + /// information about the source or destination. + /// + /// + /// The parameter is + /// null. + /// + /// + /// The class name is null or + /// is zero (0). + /// protected StixFileReadException(SerializationInfo info, StreamingContext context) : base(info, context) {} } \ No newline at end of file Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/StixFileReader.cs =================================================================== diff -u -r4247 -r4249 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/StixFileReader.cs (.../StixFileReader.cs) (revision 4247) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/StixFileReader.cs (.../StixFileReader.cs) (revision 4249) @@ -49,7 +49,7 @@ PersistableDataModel dataModel = dataModelReader.Read(); VerifyReadData(dataModel); - SoilProfile2D soilProfile2D = new SoilProfile2DDataModel().ConvertToSoilProfile2D(dataModel); + SoilProfile2D soilProfile2D = new SoilProfile2DDataModel().Create(dataModel); soilProfile2D.Name = Path.GetFileName(Path.GetFileNameWithoutExtension(filePath)); return soilProfile2D; } Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/StixFileReaderHelperTest.cs =================================================================== diff -u -r4247 -r4249 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/StixFileReaderHelperTest.cs (.../StixFileReaderHelperTest.cs) (revision 4247) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/StixFileReaderHelperTest.cs (.../StixFileReaderHelperTest.cs) (revision 4249) @@ -21,27 +21,26 @@ using NUnit.Framework; -namespace Deltares.Dam.StixFileReader.Tests +namespace Deltares.Dam.StixFileReader.Tests; + +[TestFixture] +public class StixFileReaderHelperTest { - [TestFixture] - public class StixFileReaderHelperTest + [Test] + [TestCase("profileName.stix")] + [TestCase("profileName")] + public void FetchSoilProfileFileNameWithStixExtensionTest(string profileName) { - [Test] - [TestCase("profileName.stix")] - [TestCase("profileName")] - public void FetchSoilProfileFileNameWithStixExtensionTest(string profileName) - { - Assert.That(StixFileReaderHelper.FetchFileNameWithStixExtension(profileName), Is.EqualTo("profileName.stix")); - } - - [Test] - [TestCase("profileName.stix", true)] - [TestCase("profileName.sti", false)] - [TestCase("../src/DamClientsLibrary/profileName.STIX", true)] - [TestCase("profileName", false)] - public void HasStixFileExtensionTest(string profileName, bool expectedResult) - { - Assert.That(StixFileReaderHelper.HasStixFileExtension(profileName), Is.EqualTo(expectedResult)); - } + Assert.That(StixFileReaderHelper.FetchFileNameWithStixExtension(profileName), Is.EqualTo("profileName.stix")); } + + [Test] + [TestCase("profileName.stix", true)] + [TestCase("profileName.sti", false)] + [TestCase("../src/DamClientsLibrary/profileName.STIX", true)] + [TestCase("profileName", false)] + public void HasStixFileExtensionTest(string profileName, bool expectedResult) + { + Assert.That(StixFileReaderHelper.HasStixFileExtension(profileName), Is.EqualTo(expectedResult)); + } } \ No newline at end of file Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/SoilProfile2DDataModel.cs =================================================================== diff -u -r4247 -r4249 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/SoilProfile2DDataModel.cs (.../SoilProfile2DDataModel.cs) (revision 4247) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader/SoilProfile2DDataModel.cs (.../SoilProfile2DDataModel.cs) (revision 4249) @@ -29,9 +29,17 @@ namespace Deltares.Dam.StixFileReader; +/// +/// Creates a from a . +/// public class SoilProfile2DDataModel { - public SoilProfile2D ConvertToSoilProfile2D(PersistableDataModel dataModel) + /// + /// Converts a to a . + /// + /// + /// + public SoilProfile2D Create(PersistableDataModel dataModel) { string geometryId = dataModel.Scenarios.Last().Stages.Last().GeometryId; PersistableGeometry geometry = dataModel.Geometry.First(g => g.Id == geometryId); Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/PersistableDataModelFactory.cs =================================================================== diff -u --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/PersistableDataModelFactory.cs (revision 0) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/PersistableDataModelFactory.cs (revision 4249) @@ -0,0 +1,124 @@ +// Copyright (C) Stichting Deltares 2023. 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.Collections.Generic; +using Components.Persistence.Stability.Version2.Data; + +namespace Deltares.Dam.StixFileReader.Tests; + +/// +/// Factory for creates a simple . +/// +public class PersistableDataModelFactory +{ + /// + /// Factory for creating a simple . + /// + /// + public static PersistableDataModel CreateSimpleDataModel() + { + var dataModel = new PersistableDataModel + { + Scenarios = new List + { + new() + { + Stages = new List + { + new() + { + GeometryId = "11" + }, + new() + { + GeometryId = "12" + } + } + }, + new() + { + Stages = new List + { + new() + { + GeometryId = "21" + }, + new() + { + GeometryId = "22" + } + } + } + }, + Geometry = new List + { + new() + { + Id = "22", + Layers = new List + { + new() + { + Id = "44", + Points = new List + { + new(-500, -100), + new(500, 100), + new(500, 100), + new(500, 100) + } + } + } + } + }, + SoilLayers = new List + { + new() + { + SoilLayers = new List + { + new() + { + SoilId = "33", + LayerId = "44" + } + } + } + }, + Soils = new PersistableSoilCollection + { + Soils = new List + { + new() + { + Id = "33" + } + } + }, + SoilVisualizations = new PersistableSoilVisualizationCollection + { + SoilVisualizations = new List() + } + }; + + return dataModel; + } +} \ No newline at end of file Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/Deltares.Dam.StixFileReader.Tests.csproj =================================================================== diff -u -r4247 -r4249 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/Deltares.Dam.StixFileReader.Tests.csproj (.../Deltares.Dam.StixFileReader.Tests.csproj) (revision 4247) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/Deltares.Dam.StixFileReader.Tests.csproj (.../Deltares.Dam.StixFileReader.Tests.csproj) (revision 4249) @@ -4,6 +4,12 @@ + + ..\..\..\lib\DamEngine\Components.Persistence.Stability.Version2.dll + + + ..\..\..\lib\DSL-Geo\Deltares.Geometry.dll + ..\..\..\lib\DSL-Geo\Deltares.Geotechnics.dll Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/StixFileReaderTest.cs =================================================================== diff -u -r4247 -r4249 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/StixFileReaderTest.cs (.../StixFileReaderTest.cs) (revision 4247) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/StixFileReaderTest.cs (.../StixFileReaderTest.cs) (revision 4249) @@ -41,14 +41,14 @@ { Assert.That(() => new StixFileReader().ReadSoilProfile(@".\TestFiles\Corrupt.stix"), Throws.Exception.TypeOf()); } - + [Test] public void WhenStixFileIsRead_ThenSoilProfile2DIsNotNull() { const string fileName = @".\TestFiles\DWP_1.stix"; SoilProfile2D soilProfile2D = new StixFileReader().ReadSoilProfile(fileName); - + Assert.That(soilProfile2D, Is.Not.Null); Assert.That(soilProfile2D.Name, Is.EqualTo("DWP_1")); } Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/SoilProfile2DDataModelTest.cs =================================================================== diff -u --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/SoilProfile2DDataModelTest.cs (revision 0) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.StixFileReader.Tests/SoilProfile2DDataModelTest.cs (revision 4249) @@ -0,0 +1,42 @@ +// Copyright (C) Stichting Deltares 2023. 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 Components.Persistence.Stability.Version2.Data; +using Deltares.Geotechnics.Soils; +using NUnit.Framework; + +namespace Deltares.Dam.StixFileReader.Tests; + +[TestFixture] +public class SoilProfile2DDataModelTest +{ + [Test] + public void WhenDataModelWithMultipleScenarioAndStagesIsCreated_ThenGeometryFromLastScenarioAndStageIsRetrieved() + { + PersistableDataModel dataModel = PersistableDataModelFactory.CreateSimpleDataModel(); + + SoilProfile2D soilProfile2D = new SoilProfile2DDataModel().Create(dataModel); + + Assert.That(soilProfile2D.Geometry.Left, Is.EqualTo(-500)); + Assert.That(soilProfile2D.Geometry.Right, Is.EqualTo(500)); + Assert.That(soilProfile2D.Geometry.Bottom, Is.EqualTo(-100)); + } +} \ No newline at end of file