// Copyright (C) Stichting Deltares 2023. All rights reserved. // // This file is part of the application DAM - Live. // // DAM - Live 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.Dam.Application.Live; using Deltares.Dam.Data; using Deltares.Standard.IO; using NUnit.Framework; namespace Deltares.DamLive.TestHelper; public class GeneralHelper { public const int CMinCores = 1; public const int CMaxCores = 20; public void SetupIntegrationProject(int maxCores, string testWorkingFolder, string testIntegrationDataFolder, string input1aFilename, string output1aFilename, string testFileName, string calculationParametersIntegrationFilename, string projectIntegrationFilename, out DamEngineRunner runner, out List locations) { string actualTestPath = Path.GetFullPath(testWorkingFolder + maxCores.ToString()); Directory.CreateDirectory(actualTestPath); DirectoryHelper.CopyRecursive(actualTestPath, testIntegrationDataFolder); string inputFile = Path.Combine(actualTestPath, input1aFilename); string outputFile = Path.Combine(actualTestPath, output1aFilename); string parameterFile = Path.Combine(actualTestPath, calculationParametersIntegrationFilename); string projectFile = Path.Combine(actualTestPath, projectIntegrationFilename); DamProject.SetTestProgramVersion("23.1"); DamProjectData damData = DamProject.LoadData(projectFile); locations = damData.Locations; // Load the sensor time serie data (see input file for details) TimeSerieCollection inputTimeSeries = TimeSerieCollection.LoadFromFile(inputFile); //ShortenTimeSeries(inputTimeSeries); inputTimeSeries.Save(Path.ChangeExtension(inputFile, "short.xml")); runner = new DamEngineRunner { DamXFile = new FileInfo(projectFile), ParametersFile = new FileInfo(parameterFile), FewsInputFile = new FileInfo(inputFile), FewsOutputFile = new FileInfo(outputFile), Filter = "", InputTimeSeriesCollection = inputTimeSeries, TestFileName = testFileName }; } public void AssertNoErrors(DamEngineRunner runner) { if (runner.HasErrors) { Assert.Fail("The test failed. See the error log in the test output console for more info"); } } }