// 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.Globalization;
using System.IO;
using System.Threading;
using Deltares.DamEngine.Interface;
using Deltares.DamEngine.TestHelpers;
using NUnit.Framework;
namespace Deltares.DamEngine.IntegrationTests.IntegrationTests;
[TestFixture]
public class DebuggingTest
{
private const string mapTestFiles = @"TestFiles\";
/// Debugs the with XML input file.
/// Usage:
/// 1) Generate the input XML file in the DAM UI
/// 2) Copy the file to src\Deltares.DamEngine.IntegrationTests\TestFiles\InputForDebugging.xml
/// 3) Run the test in Debugging mode
///
[Test], Ignore("This test is only used for debugging XML files generated by Dam UI")]
public void DebugWithXmlInputFile()
{
const string inputFilename = "InputForDebugging.xml";
string fullInputFilename = Path.Combine(mapTestFiles, inputFilename);
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
string inputString = File.ReadAllText(fullInputFilename);
string outputName = "OutputForDebugging.xml";
var engineInterface = new EngineInterface(inputString);
GeneralHelper.RunAfterInputValidation(engineInterface, true, outputName);
int errorCount = GeneralHelper.DetermineNumberOfCalculationErrors(engineInterface.DamProjectData.CalculationMessages);
Assert.That(errorCount, Is.EqualTo(0), "There should be nor errors during the calculation.");
}
[Test, Ignore("This test is only used for debugging XML files generated by Dam UI")]
[TestCase(1, "InputFileOnnoBligh.xml")]
[TestCase(1, "InputFileOnnoWbiSellmeijer.xml")]
[TestCase(8, "InputFileOnnoBligh.xml")]
[TestCase(8, "InputFileOnnoWbiSellmeijer.xml")]
public void DebugProblemOnno(int maxCores, string fileName)
{
string fullInputFilename = Path.Combine(mapTestFiles, fileName);
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
string inputString = File.ReadAllText(fullInputFilename);
string outputName = fileName + maxCores + ".xml";
var engineInterface = new EngineInterface(inputString);
GeneralHelper.RunAfterInputValidation(engineInterface, true, outputName);
int errorCount = GeneralHelper.DetermineNumberOfCalculationErrors(engineInterface.DamProjectData.CalculationMessages);
Assert.That(errorCount, Is.EqualTo(0), "There should be nor errors during the calculation.");
}
}