// Copyright (C) Stichting Deltares 2019. 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.IO; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Standard.Calculation; using Deltares.DamEngine.Interface; using Deltares.DamEngine.Io; using Deltares.DamEngine.Io.XmlOutput; using Deltares.DamEngine.TestHelpers; using NUnit.Framework; using ConversionHelper = Deltares.DamEngine.Interface.ConversionHelper; namespace Deltares.DamEngine.IntegrationTests.IntegrationTests { [TestFixture] public class MacroStabilityOutwardsTests { private const double tolerance = 0.0005; /// Test for different segmentFailureMechanismType /// The soilprobabilities are set tot the specified segmentFailureMechanismType [Test] [TestCase(ConversionHelper.InputSegmentFailureMechanismStability)] [TestCase(ConversionHelper.InputSegmentFailureMechanismAll)] public void TestRunMacroStabilityTutorialDesignBishop(int segmentFailureMechanismType) { // Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx" // Set Analysis type to "No adaption" // Select first location (DWP_1) // Set Calculation Options: Stability Inside - Bishop // DO NOT SET: Set Calculation Options: Stability Outside - Bishop, this is done in the test itself // Expected results are taken from test TestStabilityClassicOutsideWith2DstiFiles in FailureMechanismTests of DamUI. const string calcDir = "TestOutStabBishop"; 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, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName", @"TestFiles\DAM Tutorial Design0.soilmaterials.mdb"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SegmentFailureMechanismType", segmentFailureMechanismType.ToString()); File.WriteAllText(fileName + ".txt", inputString); EngineInterface engineInterface = new EngineInterface(inputString); Assert.IsNotNull(engineInterface.DamProjectData); engineInterface.DamProjectData.DamProjectCalculationSpecification.CurrentSpecification.StabilityModelType = MStabModelType.Bishop; engineInterface.DamProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismParametersMStab.MStabParameters.GridPosition = MStabGridPosition.Left; engineInterface.DamProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismSystemType = FailureMechanismSystemType.StabilityOutside; string outputString = engineInterface.Run(); Assert.IsNotNull(outputString); var output = DamXmlSerialization.LoadOutputFromXmlString(outputString); Assert.IsNull(output.Results.CalculationResults, "Results available when not expected"); Assert.AreEqual(1, output.Results.CalculationMessages.Length); Assert.IsTrue(output.Results.CalculationMessages[0].Message1.Contains("should be higher than dike toe at river side")); } } }