// 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.IO; using Deltares.DamEngine.Io.XmlOutput; using Deltares.DamEngine.TestHelpers; using NUnit.Framework; namespace Deltares.DamEngine.IntegrationTests.IntegrationTests; [TestFixture] public class OperationalPulauTekongTests { private const double tolerance = 0.00051; [Test] [Category(Categories.Slow)] public void Run2DStabilityInside_UsingTestFile_HasExpectedResultsInOutputFile() { const string calcDir = "TestOperationalPulauTekongInside"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } string outputFileName = Path.Combine(calcDir, "Output.xml"); Directory.CreateDirectory(calcDir); // Based on "DamLive\trunk\data\PulauTekong_inside\PulauTekong.damx" const string inputFileName = @"TestFiles\Operational\PulauTekong_inside\Input.xml"; string inputString = File.ReadAllText(inputFileName); 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, outputFileName); Assert.That(output.Results.OperationalOutputTimeSeries, Has.Length.EqualTo(5)); Assert.Multiple(() => { Assert.That(output.Results.OperationalOutputTimeSeries[0].Entries.TimeSerieEntry, Has.Length.EqualTo(1)); Assert.That(output.Results.OperationalOutputTimeSeries[0].Entries.TimeSerieEntry[0].SafetyFactor, Is.EqualTo(1.439).Within(tolerance)); Assert.That(output.Results.OperationalOutputTimeSeries[1].Entries.TimeSerieEntry[0].SafetyFactor, Is.EqualTo(1.218).Within(tolerance)); Assert.That(output.Results.OperationalOutputTimeSeries[2].Entries.TimeSerieEntry[0].SafetyFactor, Is.EqualTo(1.375).Within(tolerance)); Assert.That(output.Results.OperationalOutputTimeSeries[3].Entries.TimeSerieEntry[0].SafetyFactor, Is.EqualTo(1.395).Within(tolerance)); Assert.That(output.Results.OperationalOutputTimeSeries[4].Entries.TimeSerieEntry[0].SafetyFactor, Is.EqualTo(0.997).Within(tolerance)); }); } [Test] [Category(Categories.Slow)] public void Run2DStabilityOutside_UsingTestFile_HasExpectedResultsInOutputFile() { const string calcDir = "TestOperationalPulauTekongOutside"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); // Based on "DamLive\trunk\data\PulauTekong_inside\PulauTekong.damx" const string inputFileName = @"TestFiles\Operational\PulauTekong_outside\Input.xml"; string inputString = File.ReadAllText(inputFileName); 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.OperationalOutputTimeSeries, Has.Length.EqualTo(3)); Assert.Multiple(() => { Assert.That(output.Results.OperationalOutputTimeSeries[0].Entries.TimeSerieEntry, Has.Length.EqualTo(1)); Assert.That(output.Results.OperationalOutputTimeSeries[0].Entries.TimeSerieEntry[0].SafetyFactor, Is.EqualTo(1.222).Within(tolerance)); Assert.That(output.Results.OperationalOutputTimeSeries[1].Entries.TimeSerieEntry[0].SafetyFactor, Is.EqualTo(1.231).Within(tolerance)); Assert.That(output.Results.OperationalOutputTimeSeries[2].Entries.TimeSerieEntry[0].SafetyFactor, Is.EqualTo(1.282).Within(tolerance)); }); } }