Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLivePulauTekongStabilityOutwardTest.cs
===================================================================
diff -u
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLivePulauTekongStabilityOutwardTest.cs (revision 0)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLivePulauTekongStabilityOutwardTest.cs (revision 1866)
@@ -0,0 +1,226 @@
+// Copyright (C) Stichting Deltares 2018. 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
+// 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
+// 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;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Deltares.Dam.Application.Live;
+using Deltares.Dam.Data;
+using Deltares.DamLive.TestHelper;
+using Deltares.Standard.IO;
+using NUnit.Framework;
+
+namespace Deltares.DamLive.Tests
+{
+ // This test is of the project Pulau Tekong for stability outward
+ // It contains the real data for the actual deployment of the project
+ [TestFixture]
+ [Category("Integration")]
+ public class PulauTekongStabilityOutwardTest
+ {
+ #region Test Setup
+
+ const string projectStabilityFilename = @"PulauTekong.damx";
+ const string inputFilenameWithValues = @"live.InputTimeSeries.xml";
+ const string outputFilename = @"live.OutputTimeSeries.xml";
+ const string calculationParametersStabilityFilename = @"live.ParametersFile.xml";
+
+ const string testWorkingFolder = @".\damLivePulauTekongStabilityOutwardWork";
+ private const string testStablityDataFolder = @"..\..\..\data\Projects\Pulau Tekong_Outward";
+ private List locations;
+
+ private string inputFileFullname;
+ private string outputFileFullname;
+ private string projectFile;
+ private string parameterFile;
+
+ private DamEngineRunner runner;
+
+ [TestFixtureSetUp]
+ public void SetupFixture()
+ {
+ IoHelper.RemoveTestWorkingDirectory(testWorkingFolder); // to be sure no test directory exist from previous tests
+ Directory.CreateDirectory(testWorkingFolder);
+ }
+
+ [TestFixtureTearDown]
+ public void TearDownFixture()
+ {
+ IoHelper.RemoveTestWorkingDirectory(testWorkingFolder);
+ }
+
+ [TearDown]
+ public void TearDownTest()
+ {
+ AssertNoErrors();
+ }
+
+ [SetUp]
+ public void SetupTest() { }
+
+ ///
+ /// Sets up the stability project.
+ ///
+ private void SetupStabilityProject(string inputFilename)
+ {
+ var actualTestPath = Path.GetFullPath(testWorkingFolder);
+
+ Directory.CreateDirectory(actualTestPath);
+
+ DirectoryHelper.CopyRecursive(actualTestPath, testStablityDataFolder);
+
+ inputFileFullname = Path.Combine(actualTestPath, inputFilename);
+ outputFileFullname = Path.Combine(actualTestPath, outputFilename);
+ parameterFile = Path.Combine(actualTestPath, calculationParametersStabilityFilename);
+ projectFile = Path.Combine(actualTestPath, projectStabilityFilename);
+
+ var damData = DamProject.LoadData(projectFile);
+ locations = damData.Locations;
+
+ // Load the sensor time serie data (see input file for details)
+ var inputTimeSeries = TimeSerieCollection.LoadFromFile(inputFileFullname);
+ ShortenTimeSeries(inputTimeSeries);
+ inputTimeSeries.Save(Path.ChangeExtension(inputFileFullname, "short.xml"));
+
+ if (String.IsNullOrEmpty(inputFileFullname))
+ {
+ throw new Exception("Inputfilename not specified");
+ }
+ runner = new DamEngineRunner
+ {
+ DamXFile = new FileInfo(projectFile),
+ ParametersFile = new FileInfo(parameterFile),
+ FewsInputFile = new FileInfo(inputFileFullname),
+ FewsOutputFile = new FileInfo(outputFileFullname),
+ Filter = "",
+ InputTimeSeriesCollection = inputTimeSeries
+ };
+ }
+
+ ///
+ /// Make timeserie shorter for testing: the first, the last and the middle entry are only used
+ ///
+ ///
+ private static void ShortenTimeSeries(TimeSerieCollection inputTimeSeries)
+ {
+ int shortEntriesCount = 1; // Should be 1, 2 or 3
+ int middleEntryIndex = inputTimeSeries.Series[0].Entries.Count / 2;
+ foreach (var serie in inputTimeSeries.Series)
+ {
+ int lastToDeleteIndex = (shortEntriesCount > 1) ? serie.Entries.Count - 2 : serie.Entries.Count - 1;
+ for (int i = lastToDeleteIndex; i > 0; i--)
+ {
+ if ((i != middleEntryIndex) || (shortEntriesCount < 3))// keep the time entry in the middle of the serie
+ {
+ serie.Entries.RemoveAt(i);
+ }
+ }
+ }
+ }
+
+ #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]
+ [Category("Integration")]
+ [TestCase(inputFilenameWithValues, 0.813953, 1.175137)]
+ public void CalculateStabilityOutsideUsingTestFilesHasExpectedResultsInOutputFile(string inputTestcaseFilename, double valueEntry1, double valueEntry2)
+ {
+ const double cTolerance = 0.0005;
+ SetupStabilityProject(inputTestcaseFilename);
+ runner.Initialize();
+
+ Assert.IsNotNull(runner);
+ Assert.IsNotNull(runner.DamProjectData);
+ Assert.IsNotNull(runner.CalculationParameters);
+ Assert.IsNotNull(runner.CalculationParameters.CalculationModules);
+ Assert.IsNotNull(runner.CalculationParameters.MStabParameters);
+
+ runner.Run();
+
+ AssertNoErrors();
+
+ // Assertions
+
+ var series = runner.OutputTimeSeriesCollection.Series;
+
+ int seriesCount = 0;
+ int calculatedLocationCount = 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));
+ // StabilityOutside check
+ if (timeSeries.ParameterId == TimeSerieParameters.StabilityOutsideFactor.ToString())
+ {
+
+ if (timeSeries.LocationId == "SD CS1 3-3")
+ {
+ calculatedLocationCount++;
+ var firstEntry = timeSeries.Entries.First();
+ Assert.AreEqual(valueEntry1, firstEntry.Value, cTolerance, "The computed safety factory is not correct");
+ }
+ if (timeSeries.LocationId == "SD CS2 8-8")
+ {
+ calculatedLocationCount++;
+ var firstEntry = timeSeries.Entries.First();
+ Assert.AreEqual(valueEntry2, firstEntry.Value, cTolerance, "The computed safety factory is not correct");
+ }
+ }
+
+ seriesCount++;
+ }
+
+ Assert.IsTrue(seriesCount > 0, "No output time series");
+ Assert.IsTrue(calculatedLocationCount == 2, "Not all locations have output for stability outside");
+ }
+ }
+}
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/Deltares.DamLive.Tests.csproj
===================================================================
diff -u -r1832 -r1866
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/Deltares.DamLive.Tests.csproj (.../Deltares.DamLive.Tests.csproj) (revision 1832)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/Deltares.DamLive.Tests.csproj (.../Deltares.DamLive.Tests.csproj) (revision 1866)
@@ -55,7 +55,8 @@
-
+
+
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLivePulauTekongTest.cs
===================================================================
diff -u -r1833 -r1866
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLivePulauTekongTest.cs (.../DamLivePulauTekongTest.cs) (revision 1833)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLivePulauTekongTest.cs (.../DamLivePulauTekongMissingValuesTest.cs) (revision 1866)
@@ -31,9 +31,11 @@
namespace Deltares.DamLive.Tests
{
+ // This test is based on a early configuration of the project Pulau Tekong for stability outward
+ // It tests if having missing values in the time serie is handled correctly
[TestFixture]
[Category("Integration")]
- public class PulauTekongTest
+ public class PulauTekongMissingValuesTest
{
#region Test Setup
@@ -48,8 +50,8 @@
private const string testStablityDataFolder = @"..\..\..\data\Projects\Pulau Tekong";
private List locations;
- private string inputFile;
- private string outputFile;
+ private string inputFileFullname;
+ private string outputFileFullname;
private string projectFile;
private string parameterFile;
@@ -88,26 +90,29 @@
DirectoryHelper.CopyRecursive(actualTestPath, testStablityDataFolder);
- //inputFile = Path.Combine(actualTestPath, "live.FEWS.InputFile.1Step.xml");
- inputFile = Path.Combine(actualTestPath, inputFilename);
- outputFile = Path.Combine(actualTestPath, outputFilename);
+ inputFileFullname = Path.Combine(actualTestPath, inputFilename);
+ outputFileFullname = Path.Combine(actualTestPath, outputFilename);
parameterFile = Path.Combine(actualTestPath, calculationParametersStabilityFilename);
projectFile = Path.Combine(actualTestPath, projectStabilityFilename);
var damData = DamProject.LoadData(projectFile);
locations = damData.Locations;
// Load the sensor time serie data (see input file for details)
- var inputTimeSeries = TimeSerieCollection.LoadFromFile(inputFile);
+ var inputTimeSeries = TimeSerieCollection.LoadFromFile(inputFileFullname);
ShortenTimeSeries(inputTimeSeries);
- inputTimeSeries.Save(Path.ChangeExtension(inputFile, "short.xml"));
+ inputTimeSeries.Save(Path.ChangeExtension(inputFileFullname, "short.xml"));
+ if (String.IsNullOrEmpty(inputFileFullname))
+ {
+ throw new Exception("Inputfilename not specified");
+ }
runner = new DamEngineRunner
{
DamXFile = new FileInfo(projectFile),
ParametersFile = new FileInfo(parameterFile),
- FewsInputFile = new FileInfo(inputFile),
- FewsOutputFile = new FileInfo(outputFile),
+ FewsInputFile = new FileInfo(inputFileFullname),
+ FewsOutputFile = new FileInfo(outputFileFullname),
Filter = "",
InputTimeSeriesCollection = inputTimeSeries
};
Fisheye: Tag 1866 refers to a dead (removed) revision in file `DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/DamLivePulauTekongTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?