// Copyright (C) Stichting Deltares 2021. 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 System.Threading; using Deltares.DamEngine.Interface; using Deltares.DamEngine.Io; using NUnit.Framework; namespace Deltares.DamEngine.IntegrationTests.IntegrationTests { public class DesignCalculatorTests { [Test] [SetUICulture("en-US")] public void MessageWhenNoPipingSegmentsFound() { // Based on ".\data\DamEngineTestProjects\PipingVoorbeeld1\PipingVoorbeeld1.damx" // but without piping segments for piping // Set Analysis type to "No Adaption" // Set model to Piping Sellmeijer Revised (WBI) // Select first location (100) Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; const string fileName = @"TestFiles\PipingVoorbeeld1_WtiSellmeijerRevisedNoPipingInputFile.xml"; string inputString = File.ReadAllText(fileName); EngineInterface engineInterface = new EngineInterface(inputString); Assert.IsNotNull(engineInterface.DamProjectData); string outputString = engineInterface.Run(); var output = DamXmlSerialization.LoadOutputFromXmlString(outputString); Assert.AreEqual(1, output.Results.CalculationMessages.Length); Assert.AreEqual(null, output.Results.CalculationResults); Assert.AreEqual("No segments with failure mechanism Piping present", output.Results.CalculationMessages[0].Message1); } [Test] [SetUICulture("nl-NL")] public void MessageWhenNoStabilityInsideSegmentsFound() { // Based on ".\data\DamEngineTestProjects\Larenstein_AaenMaas\Rechter Diezedijk.damx" // Set Analysis type to "No Adaption" // Select Failure mechanism Stability Inside // Select second location (101) Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; const string fileName = @"TestFiles\Rechter Diezedijk_NoStabilityInsideInputFile.xml"; string inputString = File.ReadAllText(fileName); EngineInterface engineInterface = new EngineInterface(inputString); Assert.IsNotNull(engineInterface.DamProjectData); string outputString = engineInterface.Run(); var output = DamXmlSerialization.LoadOutputFromXmlString(outputString); Assert.AreEqual(1, output.Results.CalculationMessages.Length); Assert.AreEqual(null, output.Results.CalculationResults); Assert.AreEqual("Geen segmenten met faalmechanisme StabilityInside aanwezig", output.Results.CalculationMessages[0].Message1); } [Test] [SetUICulture("nl-NL")] public void TestInvalidInputXMLForOldDGeoStability() { // Based on InputFile.xml as produced by DAM UI in debug mode Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; const string fileName = @"TestFiles\InputFileForDGeoStability.xml"; string inputString = File.ReadAllText(fileName); EngineInterface engineInterface = new EngineInterface(inputString); Assert.IsNotNull(engineInterface.DamProjectData); string outputString = engineInterface.Run(); var output = DamXmlSerialization.LoadOutputFromXmlString(outputString); // As the data is not entirely correct for the new kernel, we expect 1 error. Assert.AreEqual(1, output.Results.CalculationMessages.Length); Assert.IsTrue(output.Results.CalculationMessages[0].Message1.Contains( "De berekening is mislukt met de volgende foutmelding"), output.Results.CalculationMessages[0].Message1); } [Test] [SetUICulture("nl-NL")] public void TestValidInputXML() { // Based on DeltaDijkInputFile.xml (1D, UpliftVan, Design, No Adaption) as produced by DAM UI in debug mode Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; const string fileName = @"TestFiles\DeltaDijkInputFile.xml"; string inputString = File.ReadAllText(fileName); EngineInterface engineInterface = new EngineInterface(inputString); Assert.IsNotNull(engineInterface.DamProjectData); string outputString = engineInterface.Run(); var output = DamXmlSerialization.LoadOutputFromXmlString(outputString); // We get 606 warnings in total when using the official release of the macro stability kernel. When we use the latest trunk version, we get 619 errors // So as long as the latest version is not (yet) released we have to check both values because otherwise it will either fail locally or on TC. Assert.IsTrue(606 == output.Results.CalculationMessages.Length || 619 == output.Results.CalculationMessages.Length, "Number of messages found = "+ output.Results.CalculationMessages.Length.ToString()) ; } } }