Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLiveUsingCompleteDataSetTest.cs
===================================================================
diff -u -r3977 -r4055
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLiveUsingCompleteDataSetTest.cs (.../DamLiveUsingCompleteDataSetTest.cs) (revision 3977)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLiveUsingCompleteDataSetTest.cs (.../DamLiveUsingCompleteDataSetTest.cs) (revision 4055)
@@ -1,20 +1,20 @@
-// Copyright (C) Stichting Deltares 2019. All rights reserved.
-//
+// Copyright (C) Stichting Deltares 2023. All rights reserved.
+//
// This file is part of the application DAM - Live.
-//
-// DAM - UI is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
+//
+// 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
+// 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.
@@ -23,21 +23,109 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using Deltares.Dam.Data;
using Deltares.Dam.Application.Live;
+using Deltares.Dam.Data;
using Deltares.DamLive.TestHelper;
using Deltares.Standard.IO;
+using NUnit.Framework;
namespace Deltares.DamLive.Tests
{
- using NUnit.Framework;
-
[TestFixture]
[Category("Integration")]
[Category("Slow")] //takes 3 minutes
[Ignore("Hangs because of a bug in D-GeoStability (MWDAM-1000, MST-1049)")]
public class DamLiveUsingCompleteDataSetTest
{
+ ///
+ /// This test calls the runner's Run method.
+ /// This test is an integration test.
+ ///
+ /// Required files are:
+ /// - the DAMX file which contains the dike models
+ /// - FEWS input file containing the water level time series for the locations
+ /// or monitoring points
+ /// - FEWS output file containing the time series results for each node
+ /// (location/monitoring point)
+ ///
+ /// See setup method
+ ///
+ [Test, Ignore("Under construction")]
+ public void Run_UsingTestFiles_HasExpectedResultsInOutputFile()
+ {
+ runner.Initialize();
+ runner.CreateAndSetWorkingDirectories();
+ runner.DeleteFormerProjectFiles();
+
+ Assert.IsNotNull(runner);
+ Assert.IsNotNull(runner.ProjectData);
+ Assert.IsNotNull(runner.RunnerDelegate);
+ Assert.IsNotNull(runner.CalculationParameters);
+ Assert.IsNotNull(runner.CalculationParameters.CalculationModules);
+ Assert.IsNotNull(runner.CalculationParameters.MStabParameters);
+
+ runner.Process();
+ runner.WriteResultsToFile(outputFile);
+
+ AssertNoErrors();
+
+ // Assertions
+
+ List series = runner.OutputTimeSeriesCollection.Series;
+
+ var seriesCount = 0;
+
+ string[] validParameterIDs = Enum.GetNames(typeof(TimeSerieParameters));
+ foreach (TimeSerie timeSeries in series)
+ {
+ Assert.IsTrue(validParameterIDs.Any(n => n == timeSeries.ParameterId));
+ Assert.IsTrue(locations.Any(l => l.Name == timeSeries.LocationId));
+
+ if (timeSeries.LocationId == "1C_31_5_bishop_binnen")
+ {
+ TimeSerieEntry firstEntry = timeSeries.Entries.First();
+ Assert.AreEqual(1.226, firstEntry.Value, "The computed safety factory is not correct");
+ TimeSerieEntry lastEntry = timeSeries.Entries.Last();
+ Assert.AreEqual(0.800, lastEntry.Value, "The computed safety factory is not correct");
+ }
+
+ if (timeSeries.LocationId == "1D_34_bishop_binnen")
+ {
+ TimeSerieEntry firstEntry = timeSeries.Entries.First();
+ Assert.AreEqual(1.319, firstEntry.Value, "The computed safety factory is not correct");
+ TimeSerieEntry lastEntry = timeSeries.Entries.Last();
+ Assert.AreEqual(0.864, lastEntry.Value, "The computed safety factory is not correct");
+ }
+
+ if (timeSeries.LocationId == "2A_37_bishop_binnen")
+ {
+ TimeSerieEntry firstEntry = timeSeries.Entries.First();
+ Assert.AreEqual(1.318, firstEntry.Value, "The computed safety factory is not correct");
+ TimeSerieEntry lastEntry = timeSeries.Entries.Last();
+ Assert.AreEqual(0.891, lastEntry.Value, "The computed safety factory is not correct");
+ }
+
+ seriesCount++;
+ }
+
+ Assert.AreEqual(locations.Count, seriesCount, "Number of output time series not equal to number of locations");
+ }
+
+ #region Helper methods
+
+ ///
+ /// Asserts that there are no errors in the runner
+ ///
+ private void AssertNoErrors()
+ {
+ if (runner.HasErrors)
+ {
+ Assert.Fail("The test failed. See the error log in the test output console for more info");
+ }
+ }
+
+ #endregion
+
#region Test Setup
const string TestWorkingFolder = "DamLiveUsingCompleteDataSetTest";
@@ -75,7 +163,7 @@
{
// create a random unique test directory name in the
// test working folder
- var actualTestPath = Guid.NewGuid().ToString().Replace("-", "");
+ string actualTestPath = Guid.NewGuid().ToString().Replace("-", "");
actualTestPath = Path.Combine(TestWorkingFolder, actualTestPath);
Directory.CreateDirectory(actualTestPath);
@@ -88,116 +176,23 @@
projectFile = Path.Combine(actualTestPath, "output.damx");
DamProject.SetTestProgramVersion("19.1");
- var damData = DamProject.LoadData(projectFile);
+ DamProjectData damData = DamProject.LoadData(projectFile);
locations = damData.Locations;
// Load the sensor time serie data (see input file for details)
- var inputTimeSeries = TimeSerieCollection.LoadFromFile(inputFile);
+ TimeSerieCollection inputTimeSeries = TimeSerieCollection.LoadFromFile(inputFile);
runner = new TestModelRunner
{
- DamXFile = new FileInfo(projectFile),
+ DamXFile = new FileInfo(projectFile),
ParametersFile = new FileInfo(parameterFile),
FewsInputFile = new FileInfo(inputFile),
FewsOutputFile = new FileInfo(outputFile),
-
RunnerDelegate = new SensorModelRunner(),
InputTimeSeriesCollection = inputTimeSeries
};
}
#endregion
-
- #region Helper methods
-
- ///
- /// Asserts that there are no errors in the runner
- ///
- private void AssertNoErrors()
- {
- if (runner.HasErrors)
- {
- Assert.Fail("The test failed. See the error log in the test output console for more info");
- }
- }
-
- #endregion
-
-
- ///
- /// This test calls the runner's Run method.
- /// This test is an integration test.
- ///
- /// Required files are:
- /// - the DAMX file which contains the dike models
- /// - FEWS input file containing the water level time series for the locations
- /// or monitoring points
- /// - FEWS output file containing the time series results for each node
- /// (location/monitoring point)
- ///
- /// See setup method
- ///
- [Test, Ignore("Under construction")]
- public void Run_UsingTestFiles_HasExpectedResultsInOutputFile()
- {
- runner.Initialize();
- runner.CreateAndSetWorkingDirectories();
- runner.DeleteFormerProjectFiles();
-
- Assert.IsNotNull(runner);
- Assert.IsNotNull(runner.ProjectData);
- Assert.IsNotNull(runner.RunnerDelegate);
- Assert.IsNotNull(runner.CalculationParameters);
- Assert.IsNotNull(runner.CalculationParameters.CalculationModules);
- Assert.IsNotNull(runner.CalculationParameters.MStabParameters);
-
- runner.Process();
- runner.WriteResultsToFile(outputFile);
-
- AssertNoErrors();
-
- // Assertions
-
- var series = runner.OutputTimeSeriesCollection.Series;
-
- int seriesCount = 0;
-
- var validParameterIDs = Enum.GetNames(typeof (TimeSerieParameters));
- foreach (var timeSeries in series)
- {
- Assert.IsTrue(validParameterIDs.Any(n => n == timeSeries.ParameterId));
- Assert.IsTrue(locations.Any(l => l.Name == timeSeries.LocationId));
-
- if (timeSeries.LocationId == "1C_31_5_bishop_binnen")
- {
- var firstEntry = timeSeries.Entries.First();
- Assert.AreEqual(1.226, firstEntry.Value , "The computed safety factory is not correct");
- var lastEntry = timeSeries.Entries.Last();
- Assert.AreEqual(0.800, lastEntry.Value, "The computed safety factory is not correct");
-
- }
-
- if (timeSeries.LocationId == "1D_34_bishop_binnen")
- {
- var firstEntry = timeSeries.Entries.First();
- Assert.AreEqual(1.319, firstEntry.Value, "The computed safety factory is not correct");
- var lastEntry = timeSeries.Entries.Last();
- Assert.AreEqual(0.864, lastEntry.Value, "The computed safety factory is not correct");
- }
-
- if (timeSeries.LocationId == "2A_37_bishop_binnen")
- {
- var firstEntry = timeSeries.Entries.First();
- Assert.AreEqual(1.318, firstEntry.Value, "The computed safety factory is not correct");
- var lastEntry = timeSeries.Entries.Last();
- Assert.AreEqual(0.891, lastEntry.Value, "The computed safety factory is not correct");
-
- }
-
- seriesCount++;
- }
-
- Assert.AreEqual(locations.Count, seriesCount, "Number of output time series not equal to number of locations");
- }
}
-}
+}
\ No newline at end of file