// 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.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Text.RegularExpressions; using System.Threading; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.Data.Standard.Calculation; using Deltares.DamEngine.Interface; using Deltares.DamEngine.Io.XmlInput; using Deltares.DamEngine.Io.XmlOutput; using Deltares.DamEngine.TestHelpers; using NUnit.Framework; using ConversionHelper = Deltares.DamEngine.Interface.ConversionHelper; using UpliftSituation = Deltares.DamEngine.Io.XmlOutput.UpliftSituation; namespace Deltares.DamEngine.IntegrationTests.IntegrationTests; [TestFixture] public class MacroStabilityInwardsTests { private const double tolerance = 0.0005; private const string mapTestFiles = @"TestFiles\"; private const double tol2Digits = 0.005; /// Test for different segmentFailureMechanismType /// The soil probabilities are set tot the specified segmentFailureMechanismType [Test, Category(Categories.Slow)] [Category(Categories.WorkInProgress)] [TestCase(ConversionHelper.InputSegmentFailureMechanismStability)] [TestCase(ConversionHelper.InputSegmentFailureMechanismAll)] public void TestRunMacroStabilityTutorialDesignBishop(int segmentFailureMechanismType) { // Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx" // with Dam Classic rev.1059 // Set Analysis type to "No adaption" // Select 1st location (DWP_1) // Set Calculation Options: Stability Inside - Bishop // Expected results are determined by running dam\dam clients\DamUI\trunk\data\DamEngineTestProjects\DAM Tutorial Design // with Dam Classic rev.833 const string calcDir = "TestStabInwardsBishop"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile.xml"; string inputString = File.ReadAllText(fileName); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "SegmentFailureMechanismType", segmentFailureMechanismType.ToString()); Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.Multiple(() => { Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.SafetyFactor, Is.EqualTo(1.309).Within(tolerance)); // NumberOfIterations=0 Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.NumberOfIterations, Is.EqualTo(0)); // ResultMessage "" Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.ResultMessage, Is.EqualTo("")); // Check that a line is specified Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.RedesignedSurfaceLine, Is.Not.Null); // Profile name = DWP_1.sti Assert.That(output.Results.CalculationResults[0].ProfileName, Is.EqualTo("DWP_1.stix")); }); // Uplift UpliftSituation upliftSituation = output.Results.CalculationResults[0].StabilityDesignResults.UpliftSituation; Assert.That(upliftSituation, Is.Not.Null); Assert.Multiple(() => { Assert.That(upliftSituation.IsUplift, Is.EqualTo(true)); Assert.That(upliftSituation.Pl3MinUplift, Is.EqualTo(1.135).Within(tolerance)); Assert.That(upliftSituation.Pl3HeadAdjusted, Is.EqualTo(4.400).Within(tolerance)); Assert.That(upliftSituation.Pl3LocationXMinUplift, Is.EqualTo(60.640).Within(tolerance)); Assert.That(upliftSituation.Pl4MinUplift, Is.EqualTo(0.0).Within(tolerance)); Assert.That(upliftSituation.Pl4HeadAdjusted, Is.EqualTo(0.0).Within(tolerance)); Assert.That(upliftSituation.Pl4LocationXMinUplift, Is.EqualTo(0.0).Within(tolerance)); // Calculation Result Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); } [Test, Category(Categories.Slow)] public void TestRunMacroStabilityTutorialDesignUpliftVan() { // Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx" // with Dam Classic rev.1059 // Select 1st location (DWP_1) // with Dam Classic rev.833 const string calcDir = "TestStabInwardsUpliftVan"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile.xml"; string inputString = File.ReadAllText(fileName); inputString = ChangeInputModel(inputString, InputStabilityModelType.UpliftVan); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.Multiple(() => { Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.SafetyFactor, Is.EqualTo(1.218).Within(tolerance)); // NumberOfIterations=0 Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.NumberOfIterations, Is.EqualTo(0)); // ResultMessage "" Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.ResultMessage, Is.EqualTo("")); // Check that a line is specified Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.RedesignedSurfaceLine, Is.Not.Null); // Profile name = DWP_1.sti Assert.That(output.Results.CalculationResults[0].ProfileName, Is.EqualTo("DWP_1.stix")); }); // Uplift UpliftSituation upliftSituation = output.Results.CalculationResults[0].StabilityDesignResults.UpliftSituation; Assert.That(upliftSituation, Is.Not.Null); Assert.Multiple(() => { Assert.That(upliftSituation.IsUplift, Is.EqualTo(true)); Assert.That(upliftSituation.Pl3MinUplift, Is.EqualTo(1.135).Within(tolerance)); Assert.That(upliftSituation.Pl3HeadAdjusted, Is.EqualTo(4.400).Within(tolerance)); Assert.That(upliftSituation.Pl3LocationXMinUplift, Is.EqualTo(60.640).Within(tolerance)); Assert.That(upliftSituation.Pl4MinUplift, Is.EqualTo(0.0).Within(tolerance)); Assert.That(upliftSituation.Pl4HeadAdjusted, Is.EqualTo(0.0).Within(tolerance)); Assert.That(upliftSituation.Pl4LocationXMinUplift, Is.EqualTo(0.0).Within(tolerance)); // Calculation Result Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); } [Test, Category(Categories.Slow)] public void TestRunMacroStabilityTutorialDesignBishopUpliftVan_UpliftVanLowest() { // Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx" // with Dam Classic rev.1059 // Select 1st location (DWP_1) // with Dam Classic rev.833 const string calcDir = "TestStabInwardsBishopUpliftVan_UpliftVanLowest"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile.xml"; string inputString = File.ReadAllText(fileName); inputString = ChangeInputModel(inputString, InputStabilityModelType.BishopUpliftVan); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used Output output = GeneralHelper.RunAfterInputValidation(inputString); // Bishop DesignResult result = output.Results.CalculationResults[0]; Assert.Multiple(() => { Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.309).Within(tolerance)); Assert.That(result.StabilityDesignResults.UpliftSituation, Is.Not.Null); }); Assert.Multiple(() => { Assert.That(result.StabilityDesignResults.UpliftSituation.IsUplift, Is.True); Assert.That(result.StabilityDesignResults.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.Bishop)); Assert.That(result.BaseFileName, Is.EqualTo("Loc(DWP_1)_Sce(1)_Pro(DWP_1_stix)")); }); // Uplift Van result = output.Results.CalculationResults[1]; Assert.Multiple(() => { Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.218).Within(tolerance)); Assert.That(result.StabilityDesignResults.UpliftSituation, Is.Not.Null); Assert.That(result.StabilityDesignResults.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.UpliftVan)); Assert.That(result.BaseFileName, Is.EqualTo("Loc(DWP_1)_Sce(1)_Pro(DWP_1_stix)")); }); // Lowest of Bishop and Uplift Van result = output.Results.CalculationResults[2]; Assert.Multiple(() => { Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.218).Within(tolerance)); Assert.That(result.StabilityDesignResults.UpliftSituation, Is.Not.Null); Assert.That(result.StabilityDesignResults.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan)); Assert.That(result.BaseFileName, Is.EqualTo("Loc(DWP_1)_Sce(1)_Pro(DWP_1_stix)")); }); Assert.Multiple(() => { // Calculation Result Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[1].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[2].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); } [Test, Category(Categories.Slow)] public void TestRunMacroStabilityTutorialDesignBishopUpliftVan_BishopLowest() { // Based on DAM UI tutorial for stability, for location DWP_22 const string calcDir = "TestStabInwardsBishopUpliftVan_BishopLowest"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile22.xml"; string inputString = File.ReadAllText(fileName); inputString = ChangeInputModel(inputString, InputStabilityModelType.BishopUpliftVan); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used Output output = GeneralHelper.RunAfterInputValidation(inputString); // Bishop DesignResultStabilityDesignResults result = output.Results.CalculationResults[0].StabilityDesignResults; Assert.Multiple(() => { Assert.That(result.SafetyFactor, Is.EqualTo(1.199).Within(tolerance)); Assert.That(result.UpliftSituation, Is.Not.Null); }); Assert.Multiple(() => { Assert.That(result.UpliftSituation.IsUplift, Is.True); Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.Bishop)); }); // Uplift Van result = output.Results.CalculationResults[1].StabilityDesignResults; Assert.Multiple(() => { Assert.That(result.SafetyFactor, Is.EqualTo(1.562).Within(tolerance)); Assert.That(result.UpliftSituation, Is.Not.Null); Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.UpliftVan)); }); // Lowest of Bishop and Uplift Van result = output.Results.CalculationResults[2].StabilityDesignResults; Assert.Multiple(() => { Assert.That(result.SafetyFactor, Is.EqualTo(1.199).Within(tolerance)); Assert.That(result.UpliftSituation, Is.Not.Null); Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan)); }); Assert.Multiple(() => { // Calculation Result Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[1].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[2].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); } [Test, Category(Categories.Slow)] public void TestRunMacroStabilityTutorialDesignBishopUpliftVan_NoUplift() { // Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx" // with Dam Classic rev.1059 // Select 10th location (DWP_18) // with Dam Classic rev.833 const string calcDir = "TestStabInwardsBishopUpliftVan_NoUplift"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile18.xml"; string inputString = File.ReadAllText(fileName); inputString = ChangeInputModel(inputString, InputStabilityModelType.BishopUpliftVan); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used Output output = GeneralHelper.RunAfterInputValidation(inputString); // Bishop DesignResultStabilityDesignResults result = output.Results.CalculationResults[0].StabilityDesignResults; Assert.Multiple(() => { Assert.That(result.SafetyFactorSpecified, Is.True); Assert.That(result.SafetyFactor, Is.EqualTo(1.450).Within(tolerance)); Assert.That(result.UpliftSituation, Is.Not.Null); }); Assert.Multiple(() => { Assert.That(result.UpliftSituation.IsUplift, Is.False); Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.Bishop)); }); // Uplift Van result = output.Results.CalculationResults[1].StabilityDesignResults; Assert.Multiple(() => { Assert.That(result.SafetyFactorSpecified, Is.False); Assert.That(result.UpliftSituation, Is.Not.Null); Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.UpliftVan)); }); // Lowest of Bishop and Uplift Van result = output.Results.CalculationResults[2].StabilityDesignResults; Assert.Multiple(() => { Assert.That(result.SafetyFactorSpecified, Is.True); Assert.That(result.SafetyFactor, Is.EqualTo(1.450).Within(tolerance)); Assert.That(result.UpliftSituation, Is.Not.Null); Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan)); }); Assert.Multiple(() => { // Calculation Result Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[1].CalculationResult), Is.EqualTo(CalculationResult.NoRun)); Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[2].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); } [Test] [Category(Categories.Slow)] public void TestRunMacroStabilityInvoer10ForbiddenZoneBishop() { // xml file is created with Invoer10\ZoneType.defx // Select locations DWP_10_1 and DWP_10_4 // Analysis type "No adaption" // Calculation options: Stability Inside - Bishop // This tests the first location with No Zones and the second with Forbidden Zone const string calcDir = "TestStabInwardsForbiddenZoneBishop"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\Invoer10.xml"; string inputString = File.ReadAllText(fileName); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.That(output.Results.CalculationResults.Length, Is.EqualTo(2)); DesignResult result = output.Results.CalculationResults[0]; Assert.Multiple(() => { // No Zone Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.365).Within(tolerance)); Assert.That(result.LocationName, Is.EqualTo("DWP_10_1")); Assert.That(result.ProfileName, Is.EqualTo("DWP_10.stix")); Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); result = output.Results.CalculationResults[1]; Assert.Multiple(() => { // Forbidden Zone, factor = 0.2 Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.899).Within(tolerance)); Assert.That(result.LocationName, Is.EqualTo("DWP_10_4")); Assert.That(result.ProfileName, Is.EqualTo("DWP_10.stix")); Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); } [Test, Ignore("This test does not give expected result. Fix in MWDAM-2473")] [Category(Categories.Slow)] [Category(Categories.WorkInProgress)] public void TestRunFailedExpectCalculationMessageInOptimizedSlopeAndShoulderAdaption() { // Inputfile was created with DAM Tutorial Design.damx // Select dwp 13 and Adapt geometry // Expected: RunFailed const string calcDir = "TestRunFailedExpectCalculationMessageInOptimizedSlopeAndShoulderAdaption"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\MacroStabilityRunFailedExpectCalculationMessage.xml"; string inputString = File.ReadAllText(fileName); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used Output output = GeneralHelper.RunAfterInputValidation(inputString, false); Assert.That(output.Results.CalculationMessages[0].Message1, Is.EqualTo("Location 'DWP_13', subsoil scenario 'DWP_13.stix', design scenario '1': " + "The calculation failed with error message " + "'The design was not successful. " + "The new shoulder height with topslope exceeds the allowed maximum height.'")); } [Test, Category(Categories.Slow), Ignore("Work in progress")] public void DesignBishopOptimizedSlopeAndShoulderAdaptionWithScenariosForHeadPL3CalculatesCorrect() { const string inputFilename = "InputFileMultiCoreTestForScenarioAdaption.xml"; string fullInputFilename = Path.Combine(mapTestFiles, inputFilename); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; string inputString = File.ReadAllText(fullInputFilename); var engineInterface = new EngineInterface(inputString); engineInterface.DamProjectData.MaxCalculationCores = 1; string calcDir = engineInterface.DamProjectData.CalculationMap + "_SingleCore"; engineInterface.DamProjectData.CalculationMap = calcDir; Assert.That(engineInterface.DamProjectData, Is.Not.Null); calcDir = Directory.GetCurrentDirectory() + "\\" + calcDir; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Output output = GeneralHelper.RunAfterInputValidation(engineInterface, true, "Results_Single_Core" + ".xml"); Assert.Multiple(() => { Assert.That(output.Results.CalculationResults, Has.Length.EqualTo(18)); Assert.That(output.Results.CalculationMessages, Has.Length.EqualTo(1336)); int resultsFound = CheckLargeResultsSets.CheckResultsDesignBishopAdaptionWithScenariosForHeadPl3CalculatesCorrect( output.Results.CalculationResults); Assert.That(resultsFound, Is.EqualTo(11)); }); } [Test, Category(Categories.Slow), Ignore("Work in progress")] public void TestRunSlopeAdaptionBeforeShoulderAdaptionSucceeds() { // Input file was created with .\data\Dam\Benchmarks\Validatie SlopeAdaption\SlopeAdaption.damx // Expected: a valid calculation. const string calcDir = "TestRunFailedExpectCalculationMessageInSlopeAdaptionBeforeShoulderAdaption"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\ValidatieSlopeAdaption.xml"; string inputString = File.ReadAllText(fileName); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.That(output.Results.CalculationResults.First().StabilityDesignResults.SafetyFactor, Is.EqualTo(1.366).Within(tolerance)); } [Test] [Category(Categories.Slow)] [Category(Categories.WorkInProgress)] // Xml is created with DAM Tutorial Design.damx // Select 1st location (DWP_1) // Set location scenario, Required safety factor stability inner slope to 1.4 // Design strategy: OptimizedSlopeAndShoulderAdaption // Set NewMinDistanceDikeToeStartDitch(New allowed distance toe-ditch) = 3.0 // Set UseNewMinDistanceDikeToeStartDitch(Use new allowed distance toe-ditch) = true (to force value to be written to XML) // // Parameters: CalcDir - StabilityModel - DesignStrategy - CalculationResult - FoS - EntryPointX - ExitPointX - DikeLength - ShoulderHeight - Iterations - ResultMessage [TestCase("TestStabInwardsBishopDesignSequential", "Bishop", "SlopeAdaptionBeforeShoulderAdaption", CalculationResult.Succeeded, 1.459, 45.387, 2.799, 5, "")] [TestCase("TestStabInwardsBishopDesignOptimized", "Bishop", "OptimizedSlopeAndShoulderAdaption", CalculationResult.Succeeded, 1.509, 43.760, 3.889, 4, "")] [TestCase("TestStabInwardsUpliftVanDesignSequential", "UpliftVan", "SlopeAdaptionBeforeShoulderAdaption", CalculationResult.Succeeded, 1.497, 50.285, 3.465, 7, "")] //ToDo MWDAM-2474 UpliftVan Optimized does not give expected result // [TestCase("TestStabInwardsUpliftVanDesignOptimized", "UpliftVan", "OptimizedSlopeAndShoulderAdaption", CalculationResult.RunFailed, 1.214, 0.0, 0.0, 4, "The new shoulder height with topslope exceeds the allowed maximum height.")] public void CanPerformStabilityInwardsDesignTutorialDesignOptimizedSlopeAndShoulderAdaption_OneLocation( string calcDir, string stabilityModel, string designStrategy, CalculationResult calculationResult, double expectedSafetyFactor, double expectedDikeLength, double expectedShoulderHeight, int expectedNumberOfIterations, string expectedResultMessage) { const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile1LocationWithAdaption.xml"; string inputString = File.ReadAllText(fileName); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "StabilityModelType", stabilityModel); inputString = XmlAdapter.ChangeValueInXml(inputString, "StabilityDesignMethod", designStrategy); if (stabilityModel == "UpliftVan") { inputString = XmlAdapter.ChangeValueInXml(inputString, "SearchMethod", "2"); } Output output = GeneralHelper.RunAfterInputValidation(inputString); DamProjectData actualDamProjectData = FillDamFromXmlOutput.CreateDamProjectData(null, output); Assert.That(ConversionHelper.ConvertToCalculationResult( output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(calculationResult)); DesignResultStabilityDesignResults stabilityDesignResults = output.Results.CalculationResults[0].StabilityDesignResults; Assert.Multiple(() => { Assert.That(stabilityDesignResults.SafetyFactor, Is.EqualTo(expectedSafetyFactor).Within(tolerance)); Assert.That(stabilityDesignResults.NumberOfIterations, Is.EqualTo(expectedNumberOfIterations)); Assert.That(stabilityDesignResults.ResultMessage, Is.EqualTo(expectedResultMessage)); }); SurfaceLine2 redesignedSurfaceLine = actualDamProjectData.DesignCalculations[0].StabilityDesignResults.RedesignedSurfaceLine; if (redesignedSurfaceLine != null) { Assert.That(redesignedSurfaceLine.GetDikeLength(), Is.EqualTo(expectedDikeLength).Within(tolerance)); GeometryPoint pointShoulderBaseInside = redesignedSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.ShoulderTopInside); if (pointShoulderBaseInside != null) { Assert.That(pointShoulderBaseInside.Z, Is.EqualTo(expectedShoulderHeight).Within(tolerance)); } } } [Test] [SetUICulture("nl-NL")] public void TestGiveFeedBackWhenNoProfilesAreAvailable() { // Based on "dam/IssueRelatedData/MWDAM-1341/HHNK Leggerstudie\DAM Leggerstudie.defx" // Import as Design -Primary dike: "DAM Leggerstudie.defx" // Select first location and start calculation // xml file is created with rev.2039 const string calcDir = "TestGiveFeedBackWhenNoProfilesAreAvailable"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\MacroStabilityNoProfilesInputFile.xml"; string inputString = File.ReadAllText(fileName); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used Output output = GeneralHelper.RunAfterInputValidation(inputString, false); Assert.That(output.Results.CalculationMessages.Length, Is.EqualTo(2)); Assert.That(output.Results.CalculationMessages[0].MessageType, Is.EqualTo(MessageMessageType.Warning)); 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() { var analysisType = "AdaptGeometry"; // Test just to see if calculation works in this case as it should do. Output output = GetOutputStringForProject(analysisType); //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); } [Test] public void TestNoDesignWithRiverLevelAboveDikeTopButBelowDthCanNotCalculate() { var 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); Assert.That(output.Results.CalculationMessages.Length, Is.EqualTo(2)); } [Test, Category(Categories.Slow)] public void TestRunMacroStabilityDeltaDijkBishopWith1DProducesStixFiles() { // Expected results are taken as is from the first run with the new kernel // This tests use of 1D profiles // Selected location (6-4-1-A-1-F) // Analysis type "No adaption" // Calculation options: Stability Inside - Bishop const string calcDir = "TestStabInwardsBishopWithStixFiles"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\DeltaDijkBishopInwards.xml"; string inputString = File.ReadAllText(fileName); inputString = ChangeInputModel(inputString, InputStabilityModelType.Bishop); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used Output output = GeneralHelper.RunAfterInputValidation(inputString); // one location is calculated with 3 1D profiles Assert.That(output.Results.CalculationResults.Length, Is.EqualTo(3)); Assert.That(output.Results.CalculationResults[0].LocationName, Is.EqualTo("6-4-1-A-1-F")); Assert.That(output.Results.CalculationResults[0].ProfileName, Is.EqualTo("6-4-1-A-1-F_1_s")); Assert.That(output.Results.CalculationResults[1].LocationName, Is.EqualTo("6-4-1-A-1-F")); Assert.That(output.Results.CalculationResults[1].ProfileName, Is.EqualTo("6-4-1-A-1-F_2_s")); Assert.That(output.Results.CalculationResults[2].LocationName, Is.EqualTo("6-4-1-A-1-F")); Assert.That(output.Results.CalculationResults[2].ProfileName, Is.EqualTo("6-4-1-A-1-F_3_s")); DesignResult result = output.Results.CalculationResults[0]; // SafetyFactor=1.682 Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.682).Within(tolerance)); // skip testing some of the results like uplift etc. // Calculation Result Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); // test safety factor for other profiles result = output.Results.CalculationResults[1]; // SafetyFactor=1.644 Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.624).Within(tolerance)); result = output.Results.CalculationResults[2]; // SafetyFactor=1.682 Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.682).Within(tolerance)); // Stix file var fileList = new List { "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_result.stix" }; foreach (string file in fileList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file))) { Assert.That(File.Exists(file), Is.True, file + " does not exist"); } } [Test, Category(Categories.Slow)] [TestCase(MStabSearchMethod.BeeSwarm, 4, 1.613, 1.535)] [TestCase(MStabSearchMethod.Grid, 2, 1.611, 1.536)] public void TestRunMacroStabilityDeltaDijkUpliftVanWith1DProducesStixFiles(MStabSearchMethod searchMethod, int expectedStixFileCount, double expectedSafetyFactor1, double expectedSafetyFactor2) { // Expected results are taken as is from the first run with the new kernel // Selected location (6-4-1-A-1-F) // Analysis type "No adaption" // Calculation options: Stability Inside - UpliftVan // This tests use of 1D profiles const string calcDir = "TestStabInwardsUpliftVanWithStixFiles"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); // Read as Bishop, then change to UpliftVan const string fileName = @"TestFiles\DeltaDijkBishopInwards.xml"; string inputString = File.ReadAllText(fileName); inputString = ChangeInputModel(inputString, InputStabilityModelType.UpliftVan); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used var engineInterface = new EngineInterface(inputString); engineInterface.DamProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismParametersMStab.MStabParameters.SearchMethod = searchMethod; Output output = GeneralHelper.RunAfterInputValidation(engineInterface); // one location is calculated with 3 1D profiles // However, profile 6-4-1-A-1-F_3_s has no UpliftVan occuring and thus has no result Assert.That(output.Results.CalculationResults.Length, Is.EqualTo(2)); Assert.Multiple(() => { Assert.That(output.Results.CalculationResults[0].LocationName, Is.EqualTo("6-4-1-A-1-F")); Assert.That(output.Results.CalculationResults[0].ProfileName, Is.EqualTo("6-4-1-A-1-F_1_s")); Assert.That(output.Results.CalculationResults[1].LocationName, Is.EqualTo("6-4-1-A-1-F")); Assert.That(output.Results.CalculationResults[1].ProfileName, Is.EqualTo("6-4-1-A-1-F_2_s")); }); DesignResult result = output.Results.CalculationResults[0]; Assert.Multiple(() => { // SafetyFactor=1.638 DSTAB 1.518 (1.079) Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(expectedSafetyFactor1).Within(tolerance)); // skip testing some of the results like uplift etc. // Calculation Result Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); // test safety factor for other profiles result = output.Results.CalculationResults[1]; Assert.Multiple(() => { Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(expectedSafetyFactor2).Within(tolerance)); Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); var fileList = new List { "Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix", "Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix" }; if (searchMethod == MStabSearchMethod.BeeSwarm) { fileList.Add("Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix"); fileList.Add("Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix"); } int stixFileCount = Directory.GetFiles(Path.GetFullPath(calcDir), "*.stix", SearchOption.AllDirectories).Length; Assert.That(stixFileCount, Is.EqualTo(expectedStixFileCount), "The number of created STIX files is not as expected"); foreach (string file in fileList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file))) { Assert.That(File.Exists(file), Is.True, file + " does not exist"); } } [Test, Category(Categories.Slow)] [TestCase(MStabSearchMethod.BeeSwarm, 10, 1.613, 1.535)] [TestCase(MStabSearchMethod.Grid, 8, 1.611, 1.536)] public void TestRunMacroStabilityDeltaDijkBishopUpliftVanWith1DWithUpliftProducesStixFiles(MStabSearchMethod searchMethod, int expectedStixFileCount, double expectedSafetyFactor1, double expectedSafetyFactor2) { // Expected results are taken as is from the first run with the new kernel // This tests use of 1D profiles // Selected location (6-4-1-A-1-F) // Analysis type "No adaption" // Calculation options: Stability Inside - Bishop const string calcDir = "TestStabInwardsBishopUpliftVanWithUpliftWithStixFiles"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\DeltaDijkBishopInwards.xml"; string inputString = File.ReadAllText(fileName); inputString = ChangeInputModel(inputString, InputStabilityModelType.BishopUpliftVan); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used var engineInterface = new EngineInterface(inputString); engineInterface.DamProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismParametersMStab.MStabParameters.SearchMethod = searchMethod; Output output = GeneralHelper.RunAfterInputValidation(engineInterface); // one location is calculated with 3 1D profiles, and results are for the 3 models Assert.That(output.Results.CalculationResults, Has.Length.EqualTo(9)); Assert.Multiple(() => { CheckCalculationResults( output.Results.CalculationResults[0], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s", DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.682, true, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[1], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s", DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, expectedSafetyFactor1, true, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[2], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s", DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, expectedSafetyFactor1, true, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[3], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s", DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.624, true, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[4], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s", DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, expectedSafetyFactor2, true, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[5], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s", DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, expectedSafetyFactor2, true, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[6], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s", DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.682, false, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[7], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s", DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, 0, false, CalculationResult.NoRun); CheckCalculationResults( output.Results.CalculationResults[8], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s", DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, 1.682, false, CalculationResult.Succeeded); }); // Stix file var fileList = new List { "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_result.stix", "Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix", "Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix" }; if (searchMethod == MStabSearchMethod.BeeSwarm) { fileList.Add("Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix"); fileList.Add("Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix"); } int stixFileCount = Directory.GetFiles(Path.GetFullPath(calcDir), "*.stix", SearchOption.AllDirectories).Length; Assert.That(stixFileCount, Is.EqualTo(expectedStixFileCount), "The number of created STIX files is not as expected"); foreach (string file in fileList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file))) { Assert.That(File.Exists(file), Is.True, file + " does not exist"); } } [Test, Category(Categories.Slow)] public void TestRunMacroStabilityDeltaDijkBishopUpliftVanWith1DWithoutUpliftProducesStixFiles() { // Expected results are taken as is from the first run with the new kernel // This tests use of 1D profiles // Selected location (6-4-1-A-1-F) // Analysis type "No adaption" // Calculation options: Stability Inside - Bishop const string calcDir = "TestStabInwardsBishopUpliftVanWithoutUpliftWithStixFiles"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\DeltaDijkBishopInwards.xml"; string inputString = File.ReadAllText(fileName); inputString = ChangeInputModel(inputString, InputStabilityModelType.BishopUpliftVan); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "UpliftCriterionStability", @"1.0"); Output output = GeneralHelper.RunAfterInputValidation(inputString); // one location is calculated with 3 1D profiles and results are for the 3 models (Bishop, Uplift-Van and Bishop/UpliftVan) Assert.That(output.Results.CalculationResults, Has.Length.EqualTo(9)); Assert.Multiple(() => { CheckCalculationResults( output.Results.CalculationResults[0], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s", DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.682, false, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[1], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s", DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, 0, false, CalculationResult.NoRun); CheckCalculationResults( output.Results.CalculationResults[2], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s", DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, 1.682, false, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[3], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s", DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.624, false, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[4], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s", DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, 0, false, CalculationResult.NoRun); CheckCalculationResults( output.Results.CalculationResults[5], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s", DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, 1.624, false, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[6], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s", DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.682, false, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[7], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s", DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, 0, false, CalculationResult.NoRun); CheckCalculationResults( output.Results.CalculationResults[8], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s", DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, 1.682, false, CalculationResult.Succeeded); }); // Stix file var existingFilesList = new List { "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_result.stix" }; foreach (string file in existingFilesList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file))) { Assert.That(File.Exists(file), Is.True, file + " does not exist"); } var noneExistingFilesList = new List { "Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix", "Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix", "Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix", "Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix" }; foreach (string file in noneExistingFilesList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file))) { Assert.That(File.Exists(file), Is.False, file + " does exist"); } } private static Output GetOutputStringForProject(string analysisType) { const string calcDir = "TestStabInwardsBishop"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\DesignInputFileWithRiverLevelAboveDikeTopButBelowDTH.xml"; string inputString = File.ReadAllText(fileName); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used 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); } private string ChangeInputModel(string input, InputStabilityModelType modelType) { var pattern = "StabilityModelType=\"[a-zA-Z]+\""; string replacement = pattern; switch (modelType) { case InputStabilityModelType.Bishop: replacement = "StabilityModelType=\"Bishop\""; break; case InputStabilityModelType.UpliftVan: replacement = "StabilityModelType=\"UpliftVan\""; break; case InputStabilityModelType.BishopUpliftVan: replacement = "StabilityModelType=\"BishopUpliftVan\""; break; } string result = Regex.Replace(input, pattern, replacement); return result; } private static void CheckCalculationResults(DesignResult output, string locationName, string profileName, DesignResultStabilityDesignResultsStabilityModelType model, double safetyFactor, bool isUplift, CalculationResult result) { Assert.Multiple(() => { Assert.That(output.LocationName, Is.EqualTo(locationName)); Assert.That(output.ProfileName, Is.EqualTo(profileName)); Assert.That(output.StabilityDesignResults.StabilityModelType, Is.EqualTo(model)); Assert.That(output.StabilityDesignResults.SafetyFactor, Is.EqualTo(safetyFactor).Within(tolerance)); Assert.That(output.StabilityDesignResults.UpliftSituation.IsUplift, Is.EqualTo(isUplift)); Assert.That(ConversionHelper.ConvertToCalculationResult(output.CalculationResult), Is.EqualTo(result)); }); } }