Index: DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/MacroStabilityInwardsTests.cs =================================================================== diff -u -r5373 -r5388 --- DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/MacroStabilityInwardsTests.cs (.../MacroStabilityInwardsTests.cs) (revision 5373) +++ DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/MacroStabilityInwardsTests.cs (.../MacroStabilityInwardsTests.cs) (revision 5388) @@ -560,28 +560,30 @@ Assert.That(output.Results.CalculationMessages[0].Message1, Is.EqualTo("Geen ondergrond profielen beschikbaar voor locatie '12-2_027'")); } - [Test, Ignore("Not clear what the expected result is. In 19.3.2 the name of the test was TestDesignWithRiverLevelAboveDikeTopButBelowDthCanCalculate.")] - [Category(Categories.WorkInProgress)] - public void TestDesignWithRiverLevelAboveDikeTopButBelowDthCanNotCalculate() + [Test] + public void TestAdaptWithRiverLevelAboveDikeTopButBelowDikeTableHeightCanCalculate() { - var analysisType = "AdaptGeometry"; + const string analysisType = "AdaptGeometry"; // Test just to see if calculation works in this case as it should do. - Output output = GetOutputStringForProject(analysisType); + Output output = GetOutputStringForProject(analysisType, true); - //ToDo Bka: Note Bka: it already failed, Probably because DTH is not yet taken into account with testing/adjusting the data. - const string message = "The error calculation message is not has expected."; - Assert.That(output.Results.CalculationMessages[0].Message1, Does.Contain("Location 'DWP_1', subsoil scenario 'DWP_1.stix', design scenario '1': " + - "The calculation failed with error message 'Value cannot be null."), message); + Assert.That(output.Results.CalculationResults, Is.Not.Null, "No results available"); + Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.SafetyFactor, Is.EqualTo(1.257).Within(0.0005)); } [Test] - public void TestNoDesignWithRiverLevelAboveDikeTopButBelowDthCanNotCalculate() + public void TestNoAdaptionWithRiverLevelAboveDikeTopButBelowDikeTableHeightCanNotCalculate() { - var analysisType = "NoAdaption"; + const string analysisType = "NoAdaption"; // Test to see if calculation does NOT work in this case as it must fail with water level above dike top. - Output output = GetOutputStringForProject(analysisType); + Output output = GetOutputStringForProject(analysisType, false); Assert.That(output.Results.CalculationMessages.Length, Is.EqualTo(2)); + Assert.Multiple(() => + { + Assert.That(output.Results.CalculationMessages[0].Message1, Does.Contain("Location 'DWP_1', subsoil scenario 'DWP_1.stix', design scenario '1': The preparation for this calculation failed.")); + Assert.That(output.Results.CalculationMessages[1].Message1, Does.Contain("Level (5.50 m) should NOT be higher than surface line (5.24)")); + }); } [Test, Category(Categories.Slow)] @@ -906,9 +908,12 @@ } } - private static Output GetOutputStringForProject(string analysisType) + private static Output GetOutputStringForProject(string analysisType, bool isSuccessful) { - const string calcDir = "TestStabInwardsBishop"; + // Create xml with Tutorial project + // Select location DWP_1 + // Calculation options: Stability Inside - Bishop + string calcDir = "TestStabInwardsBishop_" + analysisType; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results @@ -922,10 +927,11 @@ inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "SegmentFailureMechanismType", ConversionHelper.InputSegmentFailureMechanismStability.ToString()); - inputString = XmlAdapter.ChangeValueInXml(inputString, "AnalysisType", analysisType); - - return GeneralHelper.RunAfterInputValidation(inputString, false); + inputString = XmlAdapter.ChangeValueInXml(inputString, "DikeTableHeight", "5.9"); + inputString = XmlAdapter.ChangeValueInXml(inputString, "RiverLevel", "5.5"); + + return GeneralHelper.RunAfterInputValidation(inputString, isSuccessful); } private string ChangeInputModel(string input, InputStabilityModelType modelType) Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Design/DesignScenario.cs =================================================================== diff -u -r4540 -r5388 --- DamEngine/trunk/src/Deltares.DamEngine.Data/Design/DesignScenario.cs (.../DesignScenario.cs) (revision 4540) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/Design/DesignScenario.cs (.../DesignScenario.cs) (revision 5388) @@ -393,12 +393,17 @@ /// /// Set Redesigned surfaceline /// - /// + /// /// /// - public void SetRedesignedSurfaceLine(SoilProfile1D soilProfile, SoilProfile2D soilProfile2D, SurfaceLine2 surfaceLine) + /// soilProfile1D and soilProfile2D can not both be null + public void SetRedesignedSurfaceLine(SoilProfile1D soilProfile1D, SoilProfile2D soilProfile2D, SurfaceLine2 surfaceLine) { - Object objectAsKey = GetObjectAsKey(soilProfile, soilProfile2D); + if ((soilProfile1D == null) && (soilProfile2D == null)) + { + throw new ArgumentException("Both soilProfile1D and soilProfile2D are null."); + } + object objectAsKey = GetObjectAsKey(soilProfile1D, soilProfile2D); SetRedesignedSurfaceLine(objectAsKey, surfaceLine); } Index: DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/TestFiles/DesignInputFileWithRiverLevelAboveDikeTopButBelowDTH.xml =================================================================== diff -u -r4000 -r5388 --- DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/TestFiles/DesignInputFileWithRiverLevelAboveDikeTopButBelowDTH.xml (.../DesignInputFileWithRiverLevelAboveDikeTopButBelowDTH.xml) (revision 4000) +++ DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/TestFiles/DesignInputFileWithRiverLevelAboveDikeTopButBelowDTH.xml (.../DesignInputFileWithRiverLevelAboveDikeTopButBelowDTH.xml) (revision 5388) @@ -1,984 +1,513 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Design/DesignScenarioTests.cs =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Design/DesignScenarioTests.cs (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Design/DesignScenarioTests.cs (revision 5388) @@ -0,0 +1,68 @@ +// 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; +using Deltares.DamEngine.Data.Design; +using Deltares.DamEngine.Data.Geotechnics; +using NUnit.Framework; + +namespace Deltares.DamEngine.Data.Tests.Design; + +[TestFixture] +public class DesignScenarioTests +{ + [Test] + public void SetRedesignedSurfaceLine_WhenNoSoilProfileIsSet_ThenExceptionIsThrown() + { + // Arrange + var designScenario = new DesignScenario(); + + // Act & Assert + var ex = Assert.Throws(() => designScenario.SetRedesignedSurfaceLine(null, null, new SurfaceLine2())); + Assert.That(ex?.Message, Is.EqualTo("Both soilProfile1D and soilProfile2D are null.")); + } + + [Test] + public void SetRedesignedSurfaceLine_WhenSoilProfile1DIsAssigned_ThenSurfaceLineIsSet() + { + // Arrange + var designScenario = new DesignScenario(); + + // Set surface line to soil profile 1D + var soilProfile1D = new SoilProfile1D(); + var surfaceLine = new SurfaceLine2(); + designScenario.SetRedesignedSurfaceLine(soilProfile1D, null, surfaceLine); + Assert.That(designScenario.GetMostRecentSurfaceLine(soilProfile1D, null), Is.EqualTo(surfaceLine)); + } + + [Test] + public void SetRedesignedSurfaceLine_WhenSoilProfile2DIsAssigned_ThenSurfaceLineIsSet() + { + // Arrange + var designScenario = new DesignScenario(); + + // Set surface line to soil profile 1D + var soilProfile2D = new SoilProfile2D(); + var surfaceLine = new SurfaceLine2(); + designScenario.SetRedesignedSurfaceLine(null, soilProfile2D, surfaceLine); + Assert.That(designScenario.GetMostRecentSurfaceLine(null, soilProfile2D), Is.EqualTo(surfaceLine)); + } +} \ No newline at end of file