// 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; using Deltares.DamEngine.Io.XmlOutput; using Deltares.DamEngine.TestHelpers; using KellermanSoftware.CompareNetObjects; using NUnit.Framework; namespace Deltares.DamEngine.IntegrationTests.IntegrationTests; [TestFixture] public class OperationalStabilityProfile1DTests { [Test, Category(Categories.Slow)] // Following testcase based on the DamLive test Deltares.DamLive.Tests.StabilityInsideBishopGridTest // "Deltares.DamLive.Tests\TestData\IntegrationTests\StabilityInsideBishopGrid\DAMLive.damx" // with DamLive rev.4860 [TestCase("CalculateStabilityInsideBishopGrid1")] // Following testcase based on the DamLive test Deltares.DamLive.Tests.StabilityInsideUpliftVanBeeSwarmTest // "Deltares.DamLive.Tests\TestData\IntegrationTests\StabilityInsideUpliftVanBeeSwarm\DAMLive.damx" // with DamLive rev.4860 [TestCase("CalculateStabilityInsideUpliftVanBeeSwarm1")] public void GivenStabilityInsideProfile1DProject_WhenCalculatingWithSpecifiedModel_ThenExpectedResultIsGenerated(string baseName) { const string calcDir = "DAMLive.Calc"; const string testFilesLocation = @".\TestFiles\Operational\Profile1DTests\"; string projectPath = baseName; string inputFilename = baseName + "InputFile.xml"; string outputFilename = baseName + "OutputFile.xml"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } // Load expected output string expectedOutputFileName = testFilesLocation + outputFilename; Output expectedOutput = DamXmlSerialization.LoadOutputFromXmlFile(expectedOutputFileName); // Given // Load input string inputString = File.ReadAllText(testFilesLocation + inputFilename); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", projectPath); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used // When // Run calculation Output actualOutput = GeneralHelper.RunAfterInputValidation(inputString, true, outputFilename); // Then // Compare output Assert.Multiple(() => { Assert.That(actualOutput, Is.Not.Null); Assert.That(expectedOutput, Is.Not.Null); } ); CompareOutput(expectedOutput, actualOutput); } private void CompareOutput(Output expected, Output actual) { var compare = new CompareLogic { Config = { MaxDifferences = 100 } }; ComparisonResult result = compare.Compare(expected, actual); Assert.That(result.Differences.Count, Is.EqualTo(0), "Differences found read/write Output object"); } }