Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/Handlers/HydraulicBoundaryDataUpdateHandler.cs
===================================================================
diff -u -r4e3adcc0429be2bcf52820168768e9e8bb52d740 -r3ac558c812599cebeeeda70c2be7e6fbd51e814b
--- Riskeer/Integration/src/Riskeer.Integration.Plugin/Handlers/HydraulicBoundaryDataUpdateHandler.cs (.../HydraulicBoundaryDataUpdateHandler.cs) (revision 4e3adcc0429be2bcf52820168768e9e8bb52d740)
+++ Riskeer/Integration/src/Riskeer.Integration.Plugin/Handlers/HydraulicBoundaryDataUpdateHandler.cs (.../HydraulicBoundaryDataUpdateHandler.cs) (revision 3ac558c812599cebeeeda70c2be7e6fbd51e814b)
@@ -161,7 +161,7 @@
}
}
- HydraulicLocationConfigurationSettingsUpdateHelper.UpdateHydraulicLocationConfigurationDatabase(
+ HydraulicLocationConfigurationDatabaseUpdateHelper.UpdateHydraulicLocationConfigurationDatabase(
hydraulicBoundaryData.HydraulicLocationConfigurationDatabase,
readHydraulicLocationConfigurationDatabase.ReadHydraulicLocationConfigurationDatabaseSettings?.Single(),
readHydraulicLocationConfigurationDatabase.ReadTracks.First(rt => rt.TrackId == readHydraulicBoundaryDatabase.TrackId).UsePreprocessorClosure,
Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/Handlers/HydraulicLocationConfigurationDatabaseUpdateHandler.cs
===================================================================
diff -u -r4e3adcc0429be2bcf52820168768e9e8bb52d740 -r3ac558c812599cebeeeda70c2be7e6fbd51e814b
--- Riskeer/Integration/src/Riskeer.Integration.Plugin/Handlers/HydraulicLocationConfigurationDatabaseUpdateHandler.cs (.../HydraulicLocationConfigurationDatabaseUpdateHandler.cs) (revision 4e3adcc0429be2bcf52820168768e9e8bb52d740)
+++ Riskeer/Integration/src/Riskeer.Integration.Plugin/Handlers/HydraulicLocationConfigurationDatabaseUpdateHandler.cs (.../HydraulicLocationConfigurationDatabaseUpdateHandler.cs) (revision 3ac558c812599cebeeeda70c2be7e6fbd51e814b)
@@ -86,7 +86,7 @@
throw new ArgumentNullException(nameof(hlcdFilePath));
}
- HydraulicLocationConfigurationSettingsUpdateHelper.UpdateHydraulicLocationConfigurationDatabase(
+ HydraulicLocationConfigurationDatabaseUpdateHelper.UpdateHydraulicLocationConfigurationDatabase(
hydraulicBoundaryData.HydraulicLocationConfigurationDatabase,
readHydraulicLocationConfigurationDatabaseSettings, usePreprocessorClosure, hlcdFilePath);
Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/Helpers/HydraulicLocationConfigurationDatabaseUpdateHelper.cs
===================================================================
diff -u
--- Riskeer/Integration/src/Riskeer.Integration.Plugin/Helpers/HydraulicLocationConfigurationDatabaseUpdateHelper.cs (revision 0)
+++ Riskeer/Integration/src/Riskeer.Integration.Plugin/Helpers/HydraulicLocationConfigurationDatabaseUpdateHelper.cs (revision 3ac558c812599cebeeeda70c2be7e6fbd51e814b)
@@ -0,0 +1,93 @@
+// Copyright (C) Stichting Deltares 2022. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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 log4net;
+using Riskeer.Common.Data.Hydraulics;
+using Riskeer.HydraRing.IO.HydraulicLocationConfigurationDatabase;
+using Riskeer.Integration.Plugin.Properties;
+
+namespace Riskeer.Integration.Plugin.Helpers
+{
+ ///
+ /// Helper class for updating instances.
+ ///
+ public static class HydraulicLocationConfigurationDatabaseUpdateHelper
+ {
+ private static readonly ILog log = LogManager.GetLogger(typeof(HydraulicLocationConfigurationDatabaseUpdateHelper));
+
+ ///
+ /// Updates the hydraulic location configuration database.
+ ///
+ /// The hydraulic location configuration database to update.
+ /// The read hydraulic location configuration database.
+ /// Indicator whether to use the preprocessor closure.
+ /// The file path of the hydraulic location configuration database.
+ /// Thrown when or
+ /// is null.
+ public static void UpdateHydraulicLocationConfigurationDatabase(HydraulicLocationConfigurationDatabase hydraulicLocationConfigurationDatabase,
+ ReadHydraulicLocationConfigurationDatabaseSettings readHydraulicLocationConfigurationDatabase,
+ bool usePreprocessorClosure,
+ string hlcdFilePath)
+ {
+ if (hydraulicLocationConfigurationDatabase == null)
+ {
+ throw new ArgumentNullException(nameof(hydraulicLocationConfigurationDatabase));
+ }
+
+ if (hlcdFilePath == null)
+ {
+ throw new ArgumentNullException(nameof(hlcdFilePath));
+ }
+
+ if (readHydraulicLocationConfigurationDatabase != null)
+ {
+ hydraulicLocationConfigurationDatabase.FilePath = hlcdFilePath;
+ hydraulicLocationConfigurationDatabase.ScenarioName = readHydraulicLocationConfigurationDatabase.ScenarioName;
+ hydraulicLocationConfigurationDatabase.Year = readHydraulicLocationConfigurationDatabase.Year;
+ hydraulicLocationConfigurationDatabase.Scope = readHydraulicLocationConfigurationDatabase.Scope;
+ hydraulicLocationConfigurationDatabase.SeaLevel = readHydraulicLocationConfigurationDatabase.SeaLevel;
+ hydraulicLocationConfigurationDatabase.RiverDischarge = readHydraulicLocationConfigurationDatabase.RiverDischarge;
+ hydraulicLocationConfigurationDatabase.LakeLevel = readHydraulicLocationConfigurationDatabase.LakeLevel;
+ hydraulicLocationConfigurationDatabase.WindDirection = readHydraulicLocationConfigurationDatabase.WindDirection;
+ hydraulicLocationConfigurationDatabase.WindSpeed = readHydraulicLocationConfigurationDatabase.WindSpeed;
+ hydraulicLocationConfigurationDatabase.Comment = readHydraulicLocationConfigurationDatabase.Comment;
+ hydraulicLocationConfigurationDatabase.UsePreprocessorClosure = usePreprocessorClosure;
+ }
+ else
+ {
+ log.Warn(Resources.HydraulicLocationConfigurationDatabaseUpdateHelper_ReadHydraulicLocationConfigurationDatabase_No_ScenarioInformation_entries_present);
+
+ hydraulicLocationConfigurationDatabase.FilePath = hlcdFilePath;
+ hydraulicLocationConfigurationDatabase.ScenarioName = HydraulicLocationConfigurationDatabaseConstants.MandatoryConfigurationPropertyDefaultValue;
+ hydraulicLocationConfigurationDatabase.Year = HydraulicLocationConfigurationDatabaseConstants.YearDefaultValue;
+ hydraulicLocationConfigurationDatabase.Scope = HydraulicLocationConfigurationDatabaseConstants.MandatoryConfigurationPropertyDefaultValue;
+ hydraulicLocationConfigurationDatabase.SeaLevel = HydraulicLocationConfigurationDatabaseConstants.OptionalConfigurationPropertyDefaultValue;
+ hydraulicLocationConfigurationDatabase.RiverDischarge = HydraulicLocationConfigurationDatabaseConstants.OptionalConfigurationPropertyDefaultValue;
+ hydraulicLocationConfigurationDatabase.LakeLevel = HydraulicLocationConfigurationDatabaseConstants.OptionalConfigurationPropertyDefaultValue;
+ hydraulicLocationConfigurationDatabase.WindDirection = HydraulicLocationConfigurationDatabaseConstants.OptionalConfigurationPropertyDefaultValue;
+ hydraulicLocationConfigurationDatabase.WindSpeed = HydraulicLocationConfigurationDatabaseConstants.OptionalConfigurationPropertyDefaultValue;
+ hydraulicLocationConfigurationDatabase.Comment = HydraulicLocationConfigurationDatabaseConstants.AdditionalInformationConfigurationPropertyValue;
+ hydraulicLocationConfigurationDatabase.UsePreprocessorClosure = usePreprocessorClosure;
+ }
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 3ac558c812599cebeeeda70c2be7e6fbd51e814b refers to a dead (removed) revision in file `Riskeer/Integration/src/Riskeer.Integration.Plugin/Helpers/HydraulicLocationConfigurationSettingsUpdateHelper.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/Properties/Resources.Designer.cs
===================================================================
diff -u -r5eb5c89275fe6f06cdf9d780458a4a9244d15187 -r3ac558c812599cebeeeda70c2be7e6fbd51e814b
--- Riskeer/Integration/src/Riskeer.Integration.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 5eb5c89275fe6f06cdf9d780458a4a9244d15187)
+++ Riskeer/Integration/src/Riskeer.Integration.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 3ac558c812599cebeeeda70c2be7e6fbd51e814b)
@@ -482,10 +482,10 @@
///
/// Looks up a localized string similar to De tabel 'ScenarioInformation' in het HLCD bestand is niet aanwezig. Er worden standaardwaarden conform WBI2017 gebruikt voor de HLCD bestandsinformatie..
///
- public static string HydraulicLocationConfigurationSettingsUpdateHelper_ReadHydraulicLocationConfigurationDatabaseSettings_No_ScenarioInformation_entries_present {
+ public static string HydraulicLocationConfigurationDatabaseUpdateHelper_ReadHydraulicLocationConfigurationDatabase_No_ScenarioInformation_entries_present {
get {
- return ResourceManager.GetString("HydraulicLocationConfigurationSettingsUpdateHelper_ReadHydraulicLocationConfigura" +
- "tionDatabaseSettings_No_ScenarioInformation_entries_present", resourceCulture);
+ return ResourceManager.GetString("HydraulicLocationConfigurationDatabaseUpdateHelper_ReadHydraulicLocationConfigura" +
+ "tionDatabase_No_ScenarioInformation_entries_present", resourceCulture);
}
}
Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/Properties/Resources.resx
===================================================================
diff -u -r5eb5c89275fe6f06cdf9d780458a4a9244d15187 -r3ac558c812599cebeeeda70c2be7e6fbd51e814b
--- Riskeer/Integration/src/Riskeer.Integration.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 5eb5c89275fe6f06cdf9d780458a4a9244d15187)
+++ Riskeer/Integration/src/Riskeer.Integration.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 3ac558c812599cebeeeda70c2be7e6fbd51e814b)
@@ -245,7 +245,7 @@
Wilt u doorgaan?
-
De tabel 'ScenarioInformation' in het HLCD bestand is niet aanwezig. Er worden standaardwaarden conform WBI2017 gebruikt voor de HLCD bestandsinformatie.
Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/Helpers/HydraulicLocationConfigurationDatabaseUpdateHelperTest.cs
===================================================================
diff -u
--- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/Helpers/HydraulicLocationConfigurationDatabaseUpdateHelperTest.cs (revision 0)
+++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/Helpers/HydraulicLocationConfigurationDatabaseUpdateHelperTest.cs (revision 3ac558c812599cebeeeda70c2be7e6fbd51e814b)
@@ -0,0 +1,118 @@
+// Copyright (C) Stichting Deltares 2022. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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 Core.Common.TestUtil;
+using NUnit.Framework;
+using Riskeer.Common.Data.Hydraulics;
+using Riskeer.HydraRing.IO.HydraulicLocationConfigurationDatabase;
+using Riskeer.HydraRing.IO.TestUtil;
+using Riskeer.Integration.Plugin.Helpers;
+
+namespace Riskeer.Integration.Plugin.Test.Helpers
+{
+ [TestFixture]
+ public class HydraulicLocationConfigurationDatabaseUpdateHelperTest
+ {
+ [Test]
+ public void UpdateHydraulicLocationConfigurationDatabase_HydraulicLocationConfigurationDatabaseNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => HydraulicLocationConfigurationDatabaseUpdateHelper.UpdateHydraulicLocationConfigurationDatabase(
+ null, ReadHydraulicLocationConfigurationDatabaseSettingsTestFactory.Create(), false, "");
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("hydraulicLocationConfigurationDatabase", exception.ParamName);
+ }
+
+ [Test]
+ public void UpdateHydraulicLocationConfigurationDatabase_HlcdFilePathNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => HydraulicLocationConfigurationDatabaseUpdateHelper.UpdateHydraulicLocationConfigurationDatabase(
+ new HydraulicLocationConfigurationDatabase(), ReadHydraulicLocationConfigurationDatabaseSettingsTestFactory.Create(), false, null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("hlcdFilePath", exception.ParamName);
+ }
+
+ [Test]
+ public void UpdateHydraulicLocationConfigurationDatabase_ReadHydraulicLocationConfigurationDatabaseNull_SetDefaultValuesAndLogsWarning()
+ {
+ // Setup
+ const string filePath = "some/file/path";
+ var hydraulicLocationConfigurationDatabase = new HydraulicLocationConfigurationDatabase();
+ bool usePreprocessorClosure = new Random(21).NextBoolean();
+
+ // Call
+ Action call = () => HydraulicLocationConfigurationDatabaseUpdateHelper.UpdateHydraulicLocationConfigurationDatabase(
+ hydraulicLocationConfigurationDatabase, null, usePreprocessorClosure, filePath);
+
+ // Assert
+ const string expectedMessage = "De tabel 'ScenarioInformation' in het HLCD bestand is niet aanwezig. Er worden standaardwaarden " +
+ "conform WBI2017 gebruikt voor de HLCD bestandsinformatie.";
+ TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Warn), 1);
+
+ Assert.AreEqual(filePath, hydraulicLocationConfigurationDatabase.FilePath);
+ Assert.AreEqual("WBI2017", hydraulicLocationConfigurationDatabase.ScenarioName);
+ Assert.AreEqual(2023, hydraulicLocationConfigurationDatabase.Year);
+ Assert.AreEqual("WBI2017", hydraulicLocationConfigurationDatabase.Scope);
+ Assert.AreEqual("Conform WBI2017", hydraulicLocationConfigurationDatabase.SeaLevel);
+ Assert.AreEqual("Conform WBI2017", hydraulicLocationConfigurationDatabase.RiverDischarge);
+ Assert.AreEqual("Conform WBI2017", hydraulicLocationConfigurationDatabase.LakeLevel);
+ Assert.AreEqual("Conform WBI2017", hydraulicLocationConfigurationDatabase.WindDirection);
+ Assert.AreEqual("Conform WBI2017", hydraulicLocationConfigurationDatabase.WindSpeed);
+ Assert.AreEqual("Gegenereerd door Riskeer (conform WBI2017)", hydraulicLocationConfigurationDatabase.Comment);
+ Assert.AreEqual(usePreprocessorClosure, hydraulicLocationConfigurationDatabase.UsePreprocessorClosure);
+ }
+
+ [Test]
+ public void UpdateHydraulicLocationConfigurationDatabase_ReadHydraulicLocationConfigurationDatabaseNotNull_SetExpectedValuesAndDoesNotLog()
+ {
+ // Setup
+ const string filePath = "some/file/path";
+ var hydraulicLocationConfigurationDatabase = new HydraulicLocationConfigurationDatabase();
+ ReadHydraulicLocationConfigurationDatabaseSettings readDatabase = ReadHydraulicLocationConfigurationDatabaseSettingsTestFactory.Create();
+ bool usePreprocessorClosure = new Random(21).NextBoolean();
+
+ // Call
+ Action call = () => HydraulicLocationConfigurationDatabaseUpdateHelper.UpdateHydraulicLocationConfigurationDatabase(
+ hydraulicLocationConfigurationDatabase, readDatabase, usePreprocessorClosure, filePath);
+
+ // Assert
+ TestHelper.AssertLogMessagesCount(call, 0);
+
+ Assert.AreEqual(filePath, hydraulicLocationConfigurationDatabase.FilePath);
+ Assert.AreEqual(readDatabase.ScenarioName, hydraulicLocationConfigurationDatabase.ScenarioName);
+ Assert.AreEqual(readDatabase.Year, hydraulicLocationConfigurationDatabase.Year);
+ Assert.AreEqual(readDatabase.Scope, hydraulicLocationConfigurationDatabase.Scope);
+ Assert.AreEqual(readDatabase.SeaLevel, hydraulicLocationConfigurationDatabase.SeaLevel);
+ Assert.AreEqual(readDatabase.RiverDischarge, hydraulicLocationConfigurationDatabase.RiverDischarge);
+ Assert.AreEqual(readDatabase.LakeLevel, hydraulicLocationConfigurationDatabase.LakeLevel);
+ Assert.AreEqual(readDatabase.WindDirection, hydraulicLocationConfigurationDatabase.WindDirection);
+ Assert.AreEqual(readDatabase.WindSpeed, hydraulicLocationConfigurationDatabase.WindSpeed);
+ Assert.AreEqual(readDatabase.Comment, hydraulicLocationConfigurationDatabase.Comment);
+ Assert.AreEqual(usePreprocessorClosure, hydraulicLocationConfigurationDatabase.UsePreprocessorClosure);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 3ac558c812599cebeeeda70c2be7e6fbd51e814b refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/Helpers/HydraulicLocationConfigurationSettingsUpdateHelperTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?