Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/CalculationConfigurationImporter.cs
===================================================================
diff -u -r99b9874140d5a5f6d082bcb23cae6f738be92daf -r1144837cd4defc65250e08e83d9ab8583324e21b
--- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/CalculationConfigurationImporter.cs (.../CalculationConfigurationImporter.cs) (revision 99b9874140d5a5f6d082bcb23cae6f738be92daf)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/CalculationConfigurationImporter.cs (.../CalculationConfigurationImporter.cs) (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -135,6 +135,11 @@
}
}
+ protected void LogOutOfRangeException(string errorMessage, string calculationName, ArgumentOutOfRangeException e)
+ {
+ LogReadCalculationConversionError($"{errorMessage} {e.Message}", calculationName);
+ }
+
protected void LogReadCalculationConversionError(string message, string calculationName)
{
log.ErrorFormat(Resources.CalculationConfigurationImporter_ValidateCalculation_Error_message_0_calculation_1_skipped, message, calculationName);
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsInput.cs
===================================================================
diff -u -r974fb1eadbd8a630c7a992648ad42ac85ec205b1 -r1144837cd4defc65250e08e83d9ab8583324e21b
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsInput.cs (.../GrassCoverErosionInwardsInput.cs) (revision 974fb1eadbd8a630c7a992648ad42ac85ec205b1)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsInput.cs (.../GrassCoverErosionInwardsInput.cs) (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -97,7 +97,7 @@
RoundedDouble newOrientation = value.ToPrecision(orientation.NumberOfDecimalPlaces);
if (!double.IsNaN(newOrientation) && !orientationValidityRange.InRange(newOrientation))
{
- throw new ArgumentOutOfRangeException(nameof(value), string.Format(RingtoetsCommonDataResources.Orientation_Value_needs_to_be_in_Range_0_,
+ throw new ArgumentOutOfRangeException(null, string.Format(RingtoetsCommonDataResources.Orientation_Value_needs_to_be_in_Range_0_,
orientationValidityRange));
}
orientation = newOrientation;
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Importers/GrassCoverErosionInwardsCalculationConfigurationImporter.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Importers/GrassCoverErosionInwardsCalculationConfigurationImporter.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Importers/GrassCoverErosionInwardsCalculationConfigurationImporter.cs (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -0,0 +1,302 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets 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.Linq;
+using Core.Common.Base.Data;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.IO.FileImporters;
+using Ringtoets.GrassCoverErosionInwards.Data;
+using Ringtoets.GrassCoverErosionInwards.IO.Properties;
+using Ringtoets.GrassCoverErosionInwards.IO.Readers;
+using RingtoetsCommonIOResources = Ringtoets.Common.IO.Properties.Resources;
+
+namespace Ringtoets.GrassCoverErosionInwards.IO.Importers
+{
+ public class GrassCoverErosionInwardsCalculationConfigurationImporter
+ : CalculationConfigurationImporter
+ {
+ private readonly IEnumerable availableHydraulicBoundaryLocations;
+ private readonly IEnumerable availableDikeProfiles;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The path to the XML file to import from.
+ /// The calculation group to update.
+ /// The hydraulic boundary locations
+ /// used to check if the imported objects contain the right location.
+ /// The dike profiles used to check if
+ /// the imported objects contain the right profile.
+ /// Thrown when any parameter is
+ /// null.
+ public GrassCoverErosionInwardsCalculationConfigurationImporter(
+ string xmlFilePath,
+ CalculationGroup importTarget,
+ IEnumerable hydraulicBoundaryLocations,
+ IEnumerable dikeProfiles)
+ : base(xmlFilePath, importTarget)
+ {
+ if (hydraulicBoundaryLocations == null)
+ {
+ throw new ArgumentNullException(nameof(hydraulicBoundaryLocations));
+ }
+ if (dikeProfiles == null)
+ {
+ throw new ArgumentNullException(nameof(dikeProfiles));
+ }
+ availableHydraulicBoundaryLocations = hydraulicBoundaryLocations;
+ availableDikeProfiles = dikeProfiles;
+ }
+
+ protected override GrassCoverErosionInwardsCalculationConfigurationReader CreateCalculationConfigurationReader(string xmlFilePath)
+ {
+ return new GrassCoverErosionInwardsCalculationConfigurationReader(xmlFilePath);
+ }
+
+ protected override ICalculation ParseReadCalculation(ReadGrassCoverErosionInwardsCalculation readCalculation)
+ {
+ var calculation = new GrassCoverErosionInwardsCalculation
+ {
+ Name = readCalculation.Name
+ };
+ ReadDikeHeightCalculationType(readCalculation, calculation);
+
+ if (!ReadHydraulicBoundaryLocation(readCalculation, calculation))
+ {
+ return null;
+ }
+ if (!ReadDikeProfile(readCalculation, calculation))
+ {
+ return null;
+ }
+ if (!ReadOrientation(readCalculation, calculation))
+ {
+ return null;
+ }
+ if (!ReadWaveReduction(readCalculation, calculation))
+ {
+ return null;
+ }
+ if (!ReadDikeHeight(readCalculation, calculation))
+ {
+ return null;
+ }
+
+ return calculation;
+ }
+
+ ///
+ /// Reads the hydraulic boundary location.
+ ///
+ /// The calculation read from the imported file.
+ /// The calculation to configure.
+ /// false when the has a
+ /// set which is not available in , true otherwise.
+ private bool ReadHydraulicBoundaryLocation(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation)
+ {
+ if (readCalculation.HydraulicBoundaryLocation != null)
+ {
+ HydraulicBoundaryLocation location = availableHydraulicBoundaryLocations
+ .FirstOrDefault(l => l.Name == readCalculation.HydraulicBoundaryLocation);
+
+ if (location == null)
+ {
+ LogReadCalculationConversionError(
+ string.Format(
+ RingtoetsCommonIOResources.CalculationConfigurationImporter_ReadHydraulicBoundaryLocation_Hydraulic_boundary_location_0_does_not_exist,
+ readCalculation.HydraulicBoundaryLocation),
+ calculation.Name);
+
+ return false;
+ }
+
+ calculation.InputParameters.HydraulicBoundaryLocation = location;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Reads the foreshore profile.
+ ///
+ /// The calculation read from the imported file.
+ /// The calculation to configure.
+ /// false when the has a
+ /// set which is not available in , true otherwise.
+ private bool ReadDikeProfile(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation)
+ {
+ if (readCalculation.DikeProfile != null)
+ {
+ DikeProfile dikeProfile = availableDikeProfiles.FirstOrDefault(fp => fp.Name == readCalculation.DikeProfile);
+
+ if (dikeProfile == null)
+ {
+ LogReadCalculationConversionError(
+ string.Format(
+ Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ReadDikeProfile_DikeProfile_0_does_not_exist,
+ readCalculation.DikeProfile),
+ calculation.Name);
+
+ return false;
+ }
+
+ calculation.InputParameters.DikeProfile = dikeProfile;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Reads the orientation.
+ ///
+ /// The calculation read from the imported file.
+ /// The calculation to configure.
+ /// false when the orientation is invalid, true otherwise.
+ private bool ReadOrientation(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation)
+ {
+ if (readCalculation.Orientation.HasValue)
+ {
+ var orientation = new RoundedDouble(2, readCalculation.Orientation.Value);
+
+ try
+ {
+ calculation.InputParameters.Orientation = orientation;
+ }
+ catch (ArgumentOutOfRangeException e)
+ {
+ LogOutOfRangeException(
+ string.Format(Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ReadOrientation_Orientation_0_invalid, orientation),
+ calculation.Name,
+ e);
+
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ ///
+ /// Reads the wave reduction parameters.
+ ///
+ /// The calculation read from the imported file.
+ /// The calculation to configure.
+ /// false when there is an invalid wave reduction parameter defined, true otherwise.
+ private bool ReadWaveReduction(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation)
+ {
+ if (!ValidateWaveReduction(readCalculation, calculation))
+ {
+ return false;
+ }
+
+ if (readCalculation.UseForeshore.HasValue)
+ {
+ calculation.InputParameters.UseForeshore = (bool) readCalculation.UseForeshore;
+ }
+
+ if (readCalculation.UseBreakWater.HasValue)
+ {
+ calculation.InputParameters.UseBreakWater = (bool) readCalculation.UseBreakWater;
+ }
+
+ if (readCalculation.BreakWaterType != null)
+ {
+ calculation.InputParameters.BreakWater.Type = readCalculation.BreakWaterType.Value;
+ }
+
+ if (readCalculation.BreakWaterHeight.HasValue)
+ {
+ calculation.InputParameters.BreakWater.Height = (RoundedDouble) readCalculation.BreakWaterHeight;
+ }
+
+ return true;
+ }
+
+ private bool ReadDikeHeight(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation)
+ {
+ if (calculation.InputParameters.DikeProfile == null)
+ {
+ if (readCalculation.DikeHeight.HasValue)
+ {
+ LogReadCalculationConversionError(
+ Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_No_DikeProfile_provided_for_DikeHeight,
+ calculation.Name);
+
+ return false;
+ }
+ }
+ else if (readCalculation.DikeHeight.HasValue)
+ {
+ calculation.InputParameters.DikeHeight = (RoundedDouble) readCalculation.DikeHeight.Value;
+ }
+ return true;
+ }
+
+ private void ReadDikeHeightCalculationType(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation)
+ {
+ if (readCalculation.DikeHeightCalculationType.HasValue)
+ {
+ calculation.InputParameters.DikeHeightCalculationType = readCalculation.DikeHeightCalculationType.Value;
+ }
+ }
+
+ ///
+ /// Validation to check if the defined wave reduction parameters are valid.
+ ///
+ /// The calculation read from the imported file.
+ /// The calculation to configure.
+ /// false when there is an invalid wave reduction parameter defined, true otherwise.
+ private bool ValidateWaveReduction(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation)
+ {
+ if (calculation.InputParameters.DikeProfile == null)
+ {
+ if (readCalculation.UseBreakWater.HasValue
+ || readCalculation.UseForeshore.HasValue
+ || readCalculation.BreakWaterHeight != null
+ || readCalculation.BreakWaterType != null)
+ {
+ LogReadCalculationConversionError(
+ Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_No_DikeProfile_provided_for_BreakWater_parameters,
+ calculation.Name);
+
+ return false;
+ }
+ }
+ else if (!calculation.InputParameters.ForeshoreGeometry.Any())
+ {
+ if (readCalculation.UseForeshore.HasValue)
+ {
+ LogReadCalculationConversionError(
+ string.Format(
+ Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_DikeProfile_0_has_no_geometry_and_cannot_be_used,
+ readCalculation.DikeProfile),
+ calculation.Name);
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -r09fb591f0e8017e22b62ca554f6eceeeafa51219 -r1144837cd4defc65250e08e83d9ab8583324e21b
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 09fb591f0e8017e22b62ca554f6eceeeafa51219)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -1,4 +1,25 @@
-//------------------------------------------------------------------------------
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets 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.
+
+//------------------------------------------------------------------------------
//
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
@@ -108,5 +129,55 @@
return ResourceManager.GetString("GEKBConfiguratieSchema", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to Het dijkprofiel '{0}' bestaat niet..
+ ///
+ internal static string GrassCoverErosionInwardsCalculationConfigurationImporter_ReadDikeProfile_DikeProfile_0_does_not_exist {
+ get {
+ return ResourceManager.GetString("GrassCoverErosionInwardsCalculationConfigurationImporter_ReadDikeProfile_DikeProf" +
+ "ile_0_does_not_exist", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Een waarde van '{0}' als oriëntatie is ongeldig..
+ ///
+ internal static string GrassCoverErosionInwardsCalculationConfigurationImporter_ReadOrientation_Orientation_0_invalid {
+ get {
+ return ResourceManager.GetString("GrassCoverErosionInwardsCalculationConfigurationImporter_ReadOrientation_Orientat" +
+ "ion_0_invalid", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Het opgegeven dijkprofiel '{0}' heeft geen geometrie en kan daarom niet gebruikt worden..
+ ///
+ internal static string GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_DikeProfile_0_has_no_geometry_and_cannot_be_used {
+ get {
+ return ResourceManager.GetString("GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_Di" +
+ "keProfile_0_has_no_geometry_and_cannot_be_used", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Er is geen dijkprofiel opgegeven om golfreductie parameters aan toe te voegen..
+ ///
+ internal static string GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_No_DikeProfile_provided_for_BreakWater_parameters {
+ get {
+ return ResourceManager.GetString("GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_No" +
+ "_DikeProfile_provided_for_BreakWater_parameters", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Er is geen dijkprofiel opgegeven om de dijkhoogte aan toe te voegen..
+ ///
+ internal static string GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_No_DikeProfile_provided_for_DikeHeight {
+ get {
+ return ResourceManager.GetString("GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_No" +
+ "_DikeProfile_provided_for_DikeHeight", resourceCulture);
+ }
+ }
}
}
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.resx
===================================================================
diff -u -r09fb591f0e8017e22b62ca554f6eceeeafa51219 -r1144837cd4defc65250e08e83d9ab8583324e21b
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.resx (.../Resources.resx) (revision 09fb591f0e8017e22b62ca554f6eceeeafa51219)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.resx (.../Resources.resx) (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -130,4 +130,19 @@
doorsnede
+
+ Het dijkprofiel '{0}' bestaat niet.
+
+
+ Een waarde van '{0}' als oriëntatie is ongeldig.
+
+
+ Het opgegeven dijkprofiel '{0}' heeft geen geometrie en kan daarom niet gebruikt worden.
+
+
+ Er is geen dijkprofiel opgegeven om golfreductie parameters aan toe te voegen.
+
+
+ Er is geen dijkprofiel opgegeven om de dijkhoogte aan toe te voegen.
+
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Ringtoets.GrassCoverErosionInwards.IO.csproj
===================================================================
diff -u -r09fb591f0e8017e22b62ca554f6eceeeafa51219 -r1144837cd4defc65250e08e83d9ab8583324e21b
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Ringtoets.GrassCoverErosionInwards.IO.csproj (.../Ringtoets.GrassCoverErosionInwards.IO.csproj) (revision 09fb591f0e8017e22b62ca554f6eceeeafa51219)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Ringtoets.GrassCoverErosionInwards.IO.csproj (.../Ringtoets.GrassCoverErosionInwards.IO.csproj) (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -44,6 +44,7 @@
+
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Importers/GrassCoverErosionInwardsCalculationConfigurationImporterTest.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Importers/GrassCoverErosionInwardsCalculationConfigurationImporterTest.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Importers/GrassCoverErosionInwardsCalculationConfigurationImporterTest.cs (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -0,0 +1,324 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets 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.IO;
+using System.Linq;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.IO.FileImporters;
+using Ringtoets.GrassCoverErosionInwards.Data;
+using Ringtoets.GrassCoverErosionInwards.IO.Importers;
+using Ringtoets.GrassCoverErosionInwards.IO.Readers;
+
+namespace Ringtoets.GrassCoverErosionInwards.IO.Test.Importers
+{
+ [TestFixture]
+ public class GrassCoverErosionInwardsCalculationConfigurationImporterTest
+ {
+ private readonly string path = TestHelper.GetTestDataPath(
+ TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
+ nameof(GrassCoverErosionInwardsCalculationConfigurationImporter));
+
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var importer = new GrassCoverErosionInwardsCalculationConfigurationImporter(
+ "",
+ new CalculationGroup(),
+ Enumerable.Empty(),
+ Enumerable.Empty());
+
+ // Assert
+ Assert.IsInstanceOf<
+ CalculationConfigurationImporter<
+ GrassCoverErosionInwardsCalculationConfigurationReader,
+ ReadGrassCoverErosionInwardsCalculation>>(importer);
+ }
+
+ [Test]
+ public void Constructor_HydraulicBoundaryLocationsNull_ThrowArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new GrassCoverErosionInwardsCalculationConfigurationImporter(
+ "",
+ new CalculationGroup(),
+ null,
+ Enumerable.Empty());
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("hydraulicBoundaryLocations", exception.ParamName);
+ }
+
+ [Test]
+ public void Constructor_DikeProfilesNull_ThrowArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new GrassCoverErosionInwardsCalculationConfigurationImporter(
+ "",
+ new CalculationGroup(),
+ Enumerable.Empty(),
+ null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("dikeProfiles", exception.ParamName);
+ }
+
+ [Test]
+ [SetCulture("nl-NL")]
+ public void Import_ValidConfigurationInvalidOrientation_LogMessageAndContinueImport()
+ {
+ // Setup
+ string filePath = Path.Combine(path, "validConfigurationInvalidOrientation.xml");
+
+ var calculationGroup = new CalculationGroup();
+ var importer = new GrassCoverErosionInwardsCalculationConfigurationImporter(
+ filePath,
+ calculationGroup,
+ Enumerable.Empty(),
+ Enumerable.Empty());
+
+ // Call
+ var successful = false;
+ Action call = () => successful = importer.Import();
+
+ // Assert
+ string expectedMessage = "Een waarde van '380,00' als oriëntatie is ongeldig. De waarde voor de oriëntatie moet in het bereik [0,00, 360,00] liggen. " +
+ "Berekening 'Berekening 1' is overgeslagen.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsTrue(successful);
+ CollectionAssert.IsEmpty(calculationGroup.Children);
+ }
+
+ [Test]
+ public void Import_HydraulicBoundaryLocationUnknown_LogMessageAndContinueImport()
+ {
+ // Setup
+ string filePath = Path.Combine(path, "validConfigurationCalculationUnknownHydraulicBoundaryLocation.xml");
+
+ var calculationGroup = new CalculationGroup();
+ var importer = new GrassCoverErosionInwardsCalculationConfigurationImporter(
+ filePath,
+ calculationGroup,
+ Enumerable.Empty(),
+ Enumerable.Empty());
+
+ // Call
+ var successful = false;
+ Action call = () => successful = importer.Import();
+
+ // Assert
+ const string expectedMessage = "De locatie met hydraulische randvoorwaarden 'HRlocatie' bestaat niet. Berekening 'Calculation' is overgeslagen.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsTrue(successful);
+ CollectionAssert.IsEmpty(calculationGroup.Children);
+ }
+
+ [Test]
+ public void Import_DikeProfileUnknown_LogMessageAndContinueImport()
+ {
+ // Setup
+ string filePath = Path.Combine(path, "validConfigurationCalculationUnknownDikeProfile.xml");
+
+ var calculationGroup = new CalculationGroup();
+ var importer = new GrassCoverErosionInwardsCalculationConfigurationImporter(
+ filePath,
+ calculationGroup,
+ Enumerable.Empty(),
+ Enumerable.Empty());
+
+ // Call
+ var successful = false;
+ Action call = () => successful = importer.Import();
+
+ // Assert
+ const string expectedMessage = "Het dijkprofiel 'Dijkprofiel' bestaat niet. Berekening 'Berekening 1' is overgeslagen.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsTrue(successful);
+ CollectionAssert.IsEmpty(calculationGroup.Children);
+ }
+
+ [Test]
+ public void Import_WaveReductionWithoutDikeProfile_LogMessageAndContinueImport()
+ {
+ // Setup
+ string filePath = Path.Combine(path, "validConfigurationCalculationWaveReductionWithoutDikeProfile.xml");
+
+ var calculationGroup = new CalculationGroup();
+ var importer = new GrassCoverErosionInwardsCalculationConfigurationImporter(
+ filePath,
+ calculationGroup,
+ Enumerable.Empty(),
+ Enumerable.Empty());
+
+ // Call
+ var successful = false;
+ Action call = () => successful = importer.Import();
+
+ // Assert
+ const string expectedMessage = "Er is geen dijkprofiel opgegeven om golfreductie parameters aan toe te voegen. Berekening 'Berekening 1' is overgeslagen.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsTrue(successful);
+ CollectionAssert.IsEmpty(calculationGroup.Children);
+ }
+
+ [Test]
+ public void Import_DikeHeightWithoutDikeProfile_LogMessageAndContinueImport()
+ {
+ // Setup
+ string filePath = Path.Combine(path, "validConfigurationCalculationDikeHeightWithoutDikeProfile.xml");
+
+ var calculationGroup = new CalculationGroup();
+ var importer = new GrassCoverErosionInwardsCalculationConfigurationImporter(
+ filePath,
+ calculationGroup,
+ Enumerable.Empty(),
+ Enumerable.Empty());
+
+ // Call
+ var successful = false;
+ Action call = () => successful = importer.Import();
+
+ // Assert
+ const string expectedMessage = "Er is geen dijkprofiel opgegeven om de dijkhoogte aan toe te voegen. Berekening 'Berekening 1' is overgeslagen.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsTrue(successful);
+ CollectionAssert.IsEmpty(calculationGroup.Children);
+ }
+
+ [Test]
+ public void Import_UseForeshoreButProfileWithoutGeometry_LogMessageAndContinueImport()
+ {
+ // Setup
+ string filePath = Path.Combine(path, "validConfigurationCalculationUseForeshoreWithoutGeometry.xml");
+
+ var calculationGroup = new CalculationGroup();
+ var dikeProfile = new TestDikeProfile("Dijkprofiel");
+ var importer = new GrassCoverErosionInwardsCalculationConfigurationImporter(
+ filePath,
+ calculationGroup,
+ Enumerable.Empty(),
+ new[]
+ {
+ dikeProfile
+ });
+
+ // Call
+ var successful = false;
+ Action call = () => successful = importer.Import();
+
+ // Assert
+ const string expectedMessage = "Het opgegeven dijkprofiel 'Dijkprofiel' heeft geen geometrie en kan daarom niet gebruikt worden. Berekening 'Berekening 1' is overgeslagen.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsTrue(successful);
+ CollectionAssert.IsEmpty(calculationGroup.Children);
+ }
+
+ [Test]
+ public void Import_ValidConfigurationWithValidData_DataAddedToModel()
+ {
+ // Setup
+ string filePath = Path.Combine(path, "validConfigurationFullCalculation.xml");
+
+ var calculationGroup = new CalculationGroup();
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "HRlocatie", 10, 20);
+ var dikeProfile = new DikeProfile(new Point2D(0, 0), new[]
+ {
+ new RoughnessPoint(new Point2D(0, 0), 2.1),
+ new RoughnessPoint(new Point2D(1, 1), 3.9),
+ new RoughnessPoint(new Point2D(2, 2), 5.2)
+ }, new[]
+ {
+ new Point2D(1, 0),
+ new Point2D(3, 4),
+ new Point2D(6, 5)
+ }, new BreakWater(BreakWaterType.Caisson, 0), new DikeProfile.ConstructionProperties
+ {
+ Id = "id",
+ Name = "Dijkprofiel",
+ DikeHeight = 3.45
+ });
+
+ var importer = new GrassCoverErosionInwardsCalculationConfigurationImporter(
+ filePath,
+ calculationGroup,
+ new[]
+ {
+ hydraulicBoundaryLocation
+ },
+ new[]
+ {
+ dikeProfile
+ });
+
+ // Call
+ bool successful = importer.Import();
+
+ // Assert
+ Assert.IsTrue(successful);
+
+ var expectedCalculation = new GrassCoverErosionInwardsCalculation
+ {
+ Name = "Berekening 1",
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = hydraulicBoundaryLocation,
+ DikeProfile = dikeProfile,
+ DikeHeightCalculationType = DikeHeightCalculationType.CalculateByAssessmentSectionNorm,
+ Orientation = (RoundedDouble) 5.5,
+ UseForeshore = false,
+ UseBreakWater = true,
+ BreakWater =
+ {
+ Height = (RoundedDouble) 6.6,
+ Type = BreakWaterType.Caisson
+ }
+ }
+ };
+
+ Assert.AreEqual(1, calculationGroup.Children.Count);
+ AssertCalculation(expectedCalculation, (GrassCoverErosionInwardsCalculation)calculationGroup.Children[0]);
+ }
+
+ private void AssertCalculation(GrassCoverErosionInwardsCalculation expectedCalculation, GrassCoverErosionInwardsCalculation actualCalculation)
+ {
+ Assert.AreEqual(expectedCalculation.Name, actualCalculation.Name);
+ Assert.AreSame(expectedCalculation.InputParameters.HydraulicBoundaryLocation, actualCalculation.InputParameters.HydraulicBoundaryLocation);
+ Assert.AreEqual(expectedCalculation.InputParameters.Orientation, actualCalculation.InputParameters.Orientation);
+ Assert.AreEqual(expectedCalculation.InputParameters.DikeProfile, actualCalculation.InputParameters.DikeProfile);
+ Assert.AreEqual(expectedCalculation.InputParameters.DikeHeightCalculationType, actualCalculation.InputParameters.DikeHeightCalculationType);
+ Assert.AreEqual(expectedCalculation.InputParameters.DikeHeight, actualCalculation.InputParameters.DikeHeight);
+ Assert.AreEqual(expectedCalculation.InputParameters.UseForeshore, actualCalculation.InputParameters.UseForeshore);
+ Assert.AreEqual(expectedCalculation.InputParameters.UseBreakWater, actualCalculation.InputParameters.UseBreakWater);
+ Assert.AreEqual(expectedCalculation.InputParameters.BreakWater.Height, actualCalculation.InputParameters.BreakWater.Height);
+ Assert.AreEqual(expectedCalculation.InputParameters.BreakWater.Type, actualCalculation.InputParameters.BreakWater.Type);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Ringtoets.GrassCoverErosionInwards.IO.Test.csproj
===================================================================
diff -u -rb731017e828e47ed72aa803dfcc7eeaa7f770933 -r1144837cd4defc65250e08e83d9ab8583324e21b
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Ringtoets.GrassCoverErosionInwards.IO.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.IO.Test.csproj) (revision b731017e828e47ed72aa803dfcc7eeaa7f770933)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Ringtoets.GrassCoverErosionInwards.IO.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.IO.Test.csproj) (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -51,6 +51,7 @@
Properties\GlobalAssembly.cs
+
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationCalculationDikeHeightWithoutDikeProfile.xml
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationCalculationDikeHeightWithoutDikeProfile.xml (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationCalculationDikeHeightWithoutDikeProfile.xml (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -0,0 +1,6 @@
+
+
+
+ 3.45
+
+
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationCalculationUnknownDikeProfile.xml
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationCalculationUnknownDikeProfile.xml (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationCalculationUnknownDikeProfile.xml (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -0,0 +1,6 @@
+
+
+
+ Dijkprofiel
+
+
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationCalculationUnknownHydraulicBoundaryLocation.xml
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationCalculationUnknownHydraulicBoundaryLocation.xml (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationCalculationUnknownHydraulicBoundaryLocation.xml (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -0,0 +1,6 @@
+
+
+
+ HRlocatie
+
+
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationCalculationUseForeshoreWithoutGeometry.xml
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationCalculationUseForeshoreWithoutGeometry.xml (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationCalculationUseForeshoreWithoutGeometry.xml (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -0,0 +1,9 @@
+
+
+
+ Dijkprofiel
+
+ false
+
+
+
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationCalculationWaveReductionWithoutDikeProfile.xml
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationCalculationWaveReductionWithoutDikeProfile.xml (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationCalculationWaveReductionWithoutDikeProfile.xml (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -0,0 +1,11 @@
+
+
+
+
+ true
+ caisson
+ 6.6
+ false
+
+
+
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationFullCalculation.xml
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationFullCalculation.xml (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationFullCalculation.xml (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -0,0 +1,16 @@
+
+
+
+ HRlocatie
+ Dijkprofiel
+ 5.5
+ 3.45
+ norm
+
+ true
+ caisson
+ 6.6
+ false
+
+
+
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationInvalidOrientation.xml
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationInvalidOrientation.xml (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationInvalidOrientation.xml (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -0,0 +1,6 @@
+
+
+
+ 380
+
+
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationReader/validConfigurationFullCalculation.xml
===================================================================
diff -u -r7a466d4ccb9d859b47f565b400808eb6933b18f0 -r1144837cd4defc65250e08e83d9ab8583324e21b
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationReader/validConfigurationFullCalculation.xml (.../validConfigurationFullCalculation.xml) (revision 7a466d4ccb9d859b47f565b400808eb6933b18f0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationReader/validConfigurationFullCalculation.xml (.../validConfigurationFullCalculation.xml) (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -5,18 +5,18 @@
some_dike_profile
67.1
3.45
- norm
+ norm
- true
- havendam
- 1.234
- false
+ true
+ havendam
+ 1.234
+ false
-
- 0.1
- 0.2
-
+
+ 0.1
+ 0.2
+
\ No newline at end of file
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Readers/ReadWaveConditionsCalculationTest.cs
===================================================================
diff -u -r3f40ee696a93367a869de85b3ed0fad2c54a23f2 -r1144837cd4defc65250e08e83d9ab8583324e21b
--- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Readers/ReadWaveConditionsCalculationTest.cs (.../ReadWaveConditionsCalculationTest.cs) (revision 3f40ee696a93367a869de85b3ed0fad2c54a23f2)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Readers/ReadWaveConditionsCalculationTest.cs (.../ReadWaveConditionsCalculationTest.cs) (revision 1144837cd4defc65250e08e83d9ab8583324e21b)
@@ -77,7 +77,7 @@
const string foreshoreProfileName = "Name of the foreshore profile";
const double orientation = 6.6;
const bool useBreakWater = true;
- const string breakWaterType = "Caisson";
+ const string breakWaterType = "caisson";
const double breakWaterHeight = 7.7;
const bool useForeshore = false;