// 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.IO; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.Interface; using Deltares.DamEngine.Io.XmlOutput; using Deltares.DamEngine.TestHelpers; using NUnit.Framework; namespace Deltares.DamEngine.IntegrationTests.IntegrationTests; [TestFixture] public class PipingAllTests { private const double tolerance = 0.00051; // The following file is created with DAM UI project // .\data\Tutorials\DAMDesign\Piping\PipingAll\PipingAll.damx // SVN rev.6179 // The results are listed in TutorialPipingResult.xlsx private const string pipingAll = @"TestFiles\InputPipingAll.xml"; private const string pipingModelBligh = "Bligh"; private const string pipingModelWtiSellmeijerRevised = "WtiSellmeijerRevised"; public static IEnumerable TestCases { get { yield return new TestCaseData( false, pipingModelBligh, new[] { 0.521, 0.521, 0.521, 0.521, 0.521 }, new[] { 25.0, 25.0, 25.0, 25.0, 25.0 }).SetName("No adaption Bligh"); yield return new TestCaseData( false, pipingModelWtiSellmeijerRevised, new[] { 0.432, 0.422, 0.428, 0.505, 0.515 }, new[] { 25.0, 25.0, 25.0, 25.0, 25.0 }).SetName("No adaption WtiSellmeijerRevised"); yield return new TestCaseData( true, pipingModelBligh, new[] { 1.323, 1.323, 1.323, 1.331, 1.331 }, new[] { 63.486, 63.486, 63.486, 63.902, 63.902 }).SetName("Adaption Bligh"); yield return new TestCaseData( true, pipingModelWtiSellmeijerRevised, new[] { 1.280, 1.276, 1.278, 1.304, 1.304 }, new[] { 83.986, 86.486, 85.486, 71.402, 69.902 }).SetName("Adaption WtiSellmeijerRevised"); } } [Test] [TestCaseSource(nameof(TestCases))] public void GivenPipingAll_WhenCalculateAll_ThenGivesExpectedResults(bool isAdaptGeometry, string pipingModelType, double[] expectedSafetyFactors, double[] expectedDikeLengths) { string inputString = File.ReadAllText(pipingAll); inputString = XmlAdapter.ChangeValueInXml(inputString, "AnalysisType", isAdaptGeometry ? "AdaptGeometry" : "NoAdaption"); inputString = XmlAdapter.ChangeValueInXml(inputString, "PipingModelType", pipingModelType); Output output = GeneralHelper.RunAfterInputValidation(inputString); DamProjectData actualDamProjectData = FillDamFromXmlOutput.CreateDamProjectData(null, output); Assert.That(actualDamProjectData.DesignCalculations, Has.Count.EqualTo(expectedSafetyFactors.Length)); Assert.That(actualDamProjectData.DesignCalculations, Has.Count.EqualTo(expectedDikeLengths.Length)); Assert.Multiple(() => { for (var i = 0; i < expectedSafetyFactors.Length; i++) { switch (pipingModelType) { case pipingModelBligh: Assert.That(actualDamProjectData.DesignCalculations[i].PipingDesignResults.BlighFactor, Is.EqualTo(expectedSafetyFactors[i]).Within(tolerance)); break; case pipingModelWtiSellmeijerRevised: Assert.That(actualDamProjectData.DesignCalculations[i].PipingDesignResults.Wti2017SafetyFactorOverall, Is.EqualTo(expectedSafetyFactors[i]).Within(tolerance)); break; } Assert.That(actualDamProjectData.DesignCalculations[i].PipingDesignResults.RedesignedSurfaceLine.GetDikeLength(), Is.EqualTo(expectedDikeLengths[i]).Within(tolerance)); } }); } }