Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Configurations/ClosingStructuresCalculationConfigurationImporter.cs
===================================================================
diff -u
--- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Configurations/ClosingStructuresCalculationConfigurationImporter.cs (revision 0)
+++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Configurations/ClosingStructuresCalculationConfigurationImporter.cs (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -0,0 +1,317 @@
+// 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 Core.Common.Base.Data;
+using Ringtoets.ClosingStructures.Data;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.Structures;
+using Ringtoets.Common.IO.Configurations;
+using Ringtoets.Common.IO.Configurations.Helpers;
+using Ringtoets.Common.IO.FileImporters;
+using Ringtoets.Common.IO.Schema;
+using RingtoetsCommonIOResources = Ringtoets.Common.IO.Properties.Resources;
+
+namespace Ringtoets.ClosingStructures.IO.Configurations
+{
+ ///
+ /// Class for importing a configuration of from an XML file and storing
+ /// it on a .
+ ///
+ public class ClosingStructuresCalculationConfigurationImporter
+ : CalculationConfigurationImporter
+ {
+ private readonly IEnumerable availableHydraulicBoundaryLocations;
+ private readonly IEnumerable availableForeshoreProfiles;
+ private readonly IEnumerable availableStructures;
+
+ ///
+ /// Create 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 foreshore profiles used to check if
+ /// the imported objects contain the right foreshore profile.
+ /// The structures used to check if
+ /// the imported objects contain the right structure.
+ /// Thrown when any parameter is null.
+ public ClosingStructuresCalculationConfigurationImporter(
+ string xmlFilePath,
+ CalculationGroup importTarget,
+ IEnumerable hydraulicBoundaryLocations,
+ IEnumerable foreshoreProfiles,
+ IEnumerable structures)
+ : base(xmlFilePath, importTarget)
+ {
+ if (hydraulicBoundaryLocations == null)
+ {
+ throw new ArgumentNullException(nameof(hydraulicBoundaryLocations));
+ }
+ if (foreshoreProfiles == null)
+ {
+ throw new ArgumentNullException(nameof(foreshoreProfiles));
+ }
+ if (structures == null)
+ {
+ throw new ArgumentNullException(nameof(structures));
+ }
+ availableHydraulicBoundaryLocations = hydraulicBoundaryLocations;
+ availableForeshoreProfiles = foreshoreProfiles;
+ availableStructures = structures;
+ }
+
+ protected override ClosingStructuresCalculationConfigurationReader CreateCalculationConfigurationReader(string xmlFilePath)
+ {
+ return new ClosingStructuresCalculationConfigurationReader(xmlFilePath);
+ }
+
+ protected override ICalculation ParseReadCalculation(ClosingStructuresCalculationConfiguration readCalculation)
+ {
+ var calculation = new StructuresCalculation
+ {
+ Name = readCalculation.Name
+ };
+
+ if (TryReadStructure(readCalculation.StructureName, calculation)
+ && TryReadHydraulicBoundaryLocation(readCalculation.HydraulicBoundaryLocationName, calculation)
+ && TryReadForeshoreProfile(readCalculation.ForeshoreProfileName, calculation)
+ && TryReadStochasts(readCalculation, calculation)
+ && TryReadOrientation(readCalculation, calculation)
+ && TryReadFailureProbabilityStructureWithErosion(readCalculation, calculation)
+ && readCalculation.WaveReduction.ValidateWaveReduction(calculation.InputParameters.ForeshoreProfile, calculation.Name, Log))
+ {
+ ReadWaveReductionParameters(readCalculation.WaveReduction, calculation.InputParameters);
+ return calculation;
+ }
+ return null;
+ }
+
+ private bool TryReadStochasts(ClosingStructuresCalculationConfiguration readCalculation, StructuresCalculation calculation)
+ {
+ if (!readCalculation.ValidateStochasts(Log))
+ {
+ return false;
+ }
+
+ return TryReadStandardDeviationStochast(
+ calculation.Name,
+ ClosingStructuresConfigurationSchemaIdentifiers.LevelCrestStructureNotClosingStochastName,
+ calculation.InputParameters,
+ readCalculation.LevelCrestStructureNotClosing,
+ i => i.LevelCrestStructureNotClosing,
+ (i, d) => i.LevelCrestStructureNotClosing = d)
+ && TryReadStandardDeviationStochast(
+ calculation.Name,
+ ClosingStructuresConfigurationSchemaIdentifiers.AreaFlowAperturesStochastName,
+ calculation.InputParameters, readCalculation.AreaFlowApertures,
+ i => i.AreaFlowApertures,
+ (i, d) => i.AreaFlowApertures = d)
+ && TryReadStandardDeviationStochast(
+ calculation.Name,
+ ClosingStructuresConfigurationSchemaIdentifiers.DrainCoefficientStochastName,
+ calculation.InputParameters, readCalculation.DrainCoefficient,
+ i => i.DrainCoefficient,
+ (i, d) => i.DrainCoefficient = d)
+ && TryReadStandardDeviationStochast(
+ calculation.Name,
+ ClosingStructuresConfigurationSchemaIdentifiers.InsideWaterLevelStochastName,
+ calculation.InputParameters, readCalculation.InsideWaterLevel,
+ i => i.InsideWaterLevel,
+ (i, d) => i.InsideWaterLevel = d)
+ && TryReadStandardDeviationStochast(
+ calculation.Name,
+ ClosingStructuresConfigurationSchemaIdentifiers.ThresholdHeightOpenWeirStochastName,
+ calculation.InputParameters, readCalculation.ThresholdHeightOpenWeir,
+ i => i.ThresholdHeightOpenWeir,
+ (i, d) => i.ThresholdHeightOpenWeir = d)
+ && TryReadStandardDeviationStochast(
+ calculation.Name,
+ ConfigurationSchemaIdentifiers.AllowedLevelIncreaseStorageStochastName,
+ calculation.InputParameters, readCalculation.AllowedLevelIncreaseStorage,
+ i => i.AllowedLevelIncreaseStorage,
+ (i, d) => i.AllowedLevelIncreaseStorage = d)
+ && TryReadStandardDeviationStochast(
+ calculation.Name,
+ ConfigurationSchemaIdentifiers.FlowWidthAtBottomProtectionStochastName,
+ calculation.InputParameters, readCalculation.FlowWidthAtBottomProtection,
+ i => i.FlowWidthAtBottomProtection,
+ (i, d) => i.FlowWidthAtBottomProtection = d)
+ && TryReadStandardDeviationStochast(
+ calculation.Name,
+ ConfigurationSchemaIdentifiers.ModelFactorSuperCriticalFlowStochastName,
+ calculation.InputParameters, readCalculation.ModelFactorSuperCriticalFlow,
+ i => i.ModelFactorSuperCriticalFlow,
+ (i, d) => i.ModelFactorSuperCriticalFlow = d)
+ && TryReadStandardDeviationStochast(
+ calculation.Name,
+ ConfigurationSchemaIdentifiers.WidthFlowAperturesStochastName,
+ calculation.InputParameters, readCalculation.WidthFlowApertures,
+ i => i.WidthFlowApertures, (i, d) => i.WidthFlowApertures = d)
+ && TryReadVariationCoefficientStochast(
+ calculation.Name,
+ ConfigurationSchemaIdentifiers.CriticalOvertoppingDischargeStochastName,
+ calculation.InputParameters, readCalculation.CriticalOvertoppingDischarge,
+ i => i.CriticalOvertoppingDischarge,
+ (i, d) => i.CriticalOvertoppingDischarge = d)
+ && TryReadVariationCoefficientStochast(
+ calculation.Name,
+ ConfigurationSchemaIdentifiers.StorageStructureAreaStochastName,
+ calculation.InputParameters,
+ readCalculation.StorageStructureArea,
+ i => i.StorageStructureArea,
+ (i, d) => i.StorageStructureArea = d)
+ && TryReadVariationCoefficientStochast(
+ calculation.Name,
+ ConfigurationSchemaIdentifiers.StormDurationStochastName,
+ calculation.InputParameters,
+ readCalculation.StormDuration,
+ i => i.StormDuration,
+ (i, d) => i.StormDuration = d);
+ }
+
+ ///
+ /// Reads the orientation.
+ ///
+ /// The calculation read from the imported file.
+ /// The calculation to configure.
+ /// false when the orientation is invalid or when there is an orientation but
+ /// no structure defined, true otherwise.
+ private bool TryReadOrientation(StructuresCalculationConfiguration readCalculation, StructuresCalculation calculation)
+ {
+ if (readCalculation.StructureNormalOrientation.HasValue)
+ {
+ if (calculation.InputParameters.Structure == null)
+ {
+ Log.LogCalculationConversionError(string.Format(RingtoetsCommonIOResources.CalculationConfigurationImporter_TryParameter_No_Structure_to_assign_Parameter_0_,
+ RingtoetsCommonIOResources.CalculationConfigurationImporter_Orientation_DisplayName),
+ calculation.Name);
+
+ return false;
+ }
+
+ double orientation = readCalculation.StructureNormalOrientation.Value;
+
+ try
+ {
+ calculation.InputParameters.StructureNormalOrientation = (RoundedDouble) orientation;
+ }
+ catch (ArgumentOutOfRangeException e)
+ {
+ Log.LogOutOfRangeException(string.Format(RingtoetsCommonIOResources.TryReadParameter_Value_0_ParameterName_1_is_invalid,
+ orientation,
+ RingtoetsCommonIOResources.CalculationConfigurationImporter_Orientation_DisplayName),
+ calculation.Name,
+ e);
+
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ ///
+ /// Reads the failure probability structure with erosion.
+ ///
+ /// The calculation read from the imported file.
+ /// The calculation to configure.
+ /// false when the orientation is invalid or when there is a failure probability
+ /// structure with erosion but no structure defined, true otherwise.
+ private bool TryReadFailureProbabilityStructureWithErosion(StructuresCalculationConfiguration readCalculation, StructuresCalculation calculation)
+ {
+ if (readCalculation.FailureProbabilityStructureWithErosion.HasValue)
+ {
+ if (calculation.InputParameters.Structure == null)
+ {
+ Log.LogCalculationConversionError(string.Format(RingtoetsCommonIOResources.CalculationConfigurationImporter_TryParameter_No_Structure_to_assign_Parameter_0_,
+ RingtoetsCommonIOResources.CalculationConfigurationImporter_FailureProbabilityStructureWithErosion_DisplayName),
+ calculation.Name);
+
+ return false;
+ }
+
+ double failureProbability = readCalculation.FailureProbabilityStructureWithErosion.Value;
+
+ try
+ {
+ calculation.InputParameters.FailureProbabilityStructureWithErosion = (RoundedDouble) failureProbability;
+ }
+ catch (ArgumentOutOfRangeException e)
+ {
+ Log.LogOutOfRangeException(string.Format(
+ RingtoetsCommonIOResources.TryReadParameter_Value_0_ParameterName_1_is_invalid,
+ failureProbability,
+ RingtoetsCommonIOResources.CalculationConfigurationImporter_FailureProbabilityStructureWithErosion_DisplayName),
+ calculation.Name,
+ e);
+
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private bool TryReadHydraulicBoundaryLocation(string locationName, StructuresCalculation calculation)
+ {
+ HydraulicBoundaryLocation location;
+
+ if (TryReadHydraulicBoundaryLocation(locationName, calculation.Name, availableHydraulicBoundaryLocations, out location))
+ {
+ calculation.InputParameters.HydraulicBoundaryLocation = location;
+ return true;
+ }
+
+ return false;
+ }
+
+ private bool TryReadStructure(string structureName, StructuresCalculation calculation)
+ {
+ ClosingStructure structure;
+
+ if (TryReadStructure(structureName, calculation.Name, availableStructures, out structure))
+ {
+ calculation.InputParameters.Structure = structure;
+ return true;
+ }
+
+ return false;
+ }
+
+ private bool TryReadForeshoreProfile(string foreshoreProfileName, StructuresCalculation calculation)
+ {
+ ForeshoreProfile foreshoreProfile;
+
+ if (TryReadForeshoreProfile(foreshoreProfileName, calculation.Name, availableForeshoreProfiles, out foreshoreProfile))
+ {
+ calculation.InputParameters.ForeshoreProfile = foreshoreProfile;
+ return true;
+ }
+
+ return false;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Ringtoets.ClosingStructures.IO.csproj
===================================================================
diff -u -r16c94d05c67237dec9fcab0f3f03c6b48d3c335b -r335523a40d190e19b1061804de21c28f74140f52
--- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Ringtoets.ClosingStructures.IO.csproj (.../Ringtoets.ClosingStructures.IO.csproj) (revision 16c94d05c67237dec9fcab0f3f03c6b48d3c335b)
+++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.IO/Ringtoets.ClosingStructures.IO.csproj (.../Ringtoets.ClosingStructures.IO.csproj) (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -50,6 +50,7 @@
+
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/Helpers/ConfigurationValidationExtensions.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/Helpers/ConfigurationValidationExtensions.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/Helpers/ConfigurationValidationExtensions.cs (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -0,0 +1,118 @@
+// 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.Linq;
+using log4net;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.IO.Properties;
+
+namespace Ringtoets.Common.IO.Configurations.Helpers
+{
+ ///
+ /// Helper methods for validation of configuration elements.
+ ///
+ public static class ConfigurationValidationExtensions
+ {
+ ///
+ /// Validate the defined wave reduction parameters in combination with a given foreshore profile.
+ ///
+ /// Configuration possibly containing wave reduction parameters.
+ /// The foreshore profile currently assigned to the calculation.
+ /// The name of the calculation which is being validated.
+ /// Log used to write out errors.
+ /// false when there is an invalid wave reduction parameter defined, true otherwise.
+ /// Thrown when is null.
+ public static bool ValidateWaveReduction(this WaveReductionConfiguration waveReduction, ForeshoreProfile foreshoreProfile, string calculationName, ILog log)
+ {
+ if (calculationName == null)
+ {
+ throw new ArgumentNullException(nameof(calculationName));
+ }
+ if (log == null)
+ {
+ throw new ArgumentNullException(nameof(log));
+ }
+
+ if (foreshoreProfile == null)
+ {
+ if (HasParametersDefined(waveReduction))
+ {
+ log.LogCalculationConversionError(Resources.CalculationConfigurationImporter_ValidateWaveReduction_No_foreshore_profile_provided,
+ calculationName);
+
+ return false;
+ }
+ }
+ else if (!foreshoreProfile.Geometry.Any() && waveReduction.UseForeshoreProfile == true)
+ {
+ log.LogCalculationConversionError(String.Format(
+ Resources.ReadForeshoreProfile_ForeshoreProfile_0_has_no_geometry_and_cannot_be_used,
+ foreshoreProfile.Name),
+ calculationName);
+
+ return false;
+ }
+ return true;
+ }
+ ///
+ /// Validates the parameters of shared stochasts in a structure calculation.
+ ///
+ /// Configuration of the structure calculation.
+ /// Log used to write out errors.
+ /// false when there is an invalid stochast parameter defined, true otherwise.
+ /// Thrown when any parameter is null.
+ public static bool ValidateStochasts(this StructuresCalculationConfiguration configuration, ILog log)
+ {
+ if (configuration == null)
+ {
+ throw new ArgumentNullException(nameof(configuration));
+ }
+ if (log == null)
+ {
+ throw new ArgumentNullException(nameof(log));
+ }
+
+ if (configuration.StormDuration?.VariationCoefficient != null)
+ {
+ log.LogCalculationConversionError(Resources.CalculationConfigurationImporter_ValidateStochasts_Cannot_define_VariationCoefficient_for_StormDuration,
+ configuration.Name);
+ return false;
+ }
+ if (configuration.ModelFactorSuperCriticalFlow?.StandardDeviation != null)
+ {
+ log.LogCalculationConversionError(Resources.CalculationConfigurationImporter_ValidateStochasts_Cannot_define_StandardDeviation_for_ModelFactorSuperCriticalFlow,
+ configuration.Name);
+ return false;
+ }
+ return true;
+ }
+
+ private static bool HasParametersDefined(WaveReductionConfiguration waveReduction)
+ {
+ return waveReduction != null
+ && (waveReduction.UseBreakWater.HasValue
+ || waveReduction.UseForeshoreProfile.HasValue
+ || waveReduction.BreakWaterHeight.HasValue
+ || waveReduction.BreakWaterType.HasValue);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/Helpers/ILogExtensions.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/Helpers/ILogExtensions.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/Helpers/ILogExtensions.cs (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -0,0 +1,44 @@
+// 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 log4net;
+using Ringtoets.Common.IO.Properties;
+
+namespace Ringtoets.Common.IO.Configurations.Helpers
+{
+ ///
+ /// Extension methods for for logging problems occuring during import or export of configurations.
+ ///
+ public static class ILogExtensions
+ {
+ public static void LogOutOfRangeException(this ILog log, string errorMessage, string calculationName, ArgumentOutOfRangeException e)
+ {
+ log.LogCalculationConversionError($"{errorMessage} {e.Message}", calculationName);
+ }
+
+ public static void LogCalculationConversionError(this ILog log, string message, string calculationName)
+ {
+ log.ErrorFormat(Resources.CalculationConfigurationImporter_ValidateCalculation_ErrorMessage_0_Calculation_1_skipped,
+ message, calculationName);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/CalculationConfigurationImporter.cs
===================================================================
diff -u -rb80222df5e484e90e255f10116a7e88ead10a289 -r335523a40d190e19b1061804de21c28f74140f52
--- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/CalculationConfigurationImporter.cs (.../CalculationConfigurationImporter.cs) (revision b80222df5e484e90e255f10116a7e88ead10a289)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/CalculationConfigurationImporter.cs (.../CalculationConfigurationImporter.cs) (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -30,6 +30,7 @@
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.Probabilistics;
using Ringtoets.Common.IO.Configurations;
using Ringtoets.Common.IO.Configurations.Helpers;
using Ringtoets.Common.IO.Properties;
@@ -47,7 +48,7 @@
where TCalculationConfigurationReader : CalculationConfigurationReader
where TReadCalculation : class, IConfigurationItem
{
- private static readonly ILog log = LogManager.GetLogger(typeof(CalculationConfigurationImporter));
+ protected readonly ILog Log = LogManager.GetLogger(typeof(CalculationConfigurationImporter));
///
/// Creates a new instance of .
@@ -60,7 +61,7 @@
protected override void LogImportCanceledMessage()
{
- log.Info(Resources.CalculationConfigurationImporter_LogImportCanceledMessage_Import_canceled_no_data_read);
+ Log.Info(Resources.CalculationConfigurationImporter_LogImportCanceledMessage_Import_canceled_no_data_read);
}
protected override bool OnImport()
@@ -121,57 +122,7 @@
/// A parsed calculation instance, or null when something goes wrong while parsing.
protected abstract ICalculation ParseReadCalculation(TReadCalculation readCalculation);
- 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_ErrorMessage_0_Calculation_1_skipped,
- message, calculationName);
- }
-
///
- /// Validate the defined wave reduction parameters in combination with a given foreshore profile.
- ///
- /// Configuration possibly containing wave reduction parameters.
- /// The foreshore profile currently assigned to the calculation.
- /// The name of the calculation which is being validated.
- /// false when there is an invalid wave reduction parameter defined, true otherwise.
- /// Thrown when is null.
- protected bool ValidateWaveReduction(WaveReductionConfiguration waveReduction, ForeshoreProfile foreshoreProfile, string calculationName)
- {
- if (calculationName == null)
- {
- throw new ArgumentNullException(nameof(calculationName));
- }
-
- if (foreshoreProfile == null)
- {
- if (HasParametersDefined(waveReduction))
- {
- LogReadCalculationConversionError(
- Resources.CalculationConfigurationImporter_ValidateWaveReduction_No_foreshore_profile_provided,
- calculationName);
-
- return false;
- }
- }
- else if (!foreshoreProfile.Geometry.Any() && waveReduction.UseForeshoreProfile == true)
- {
- LogReadCalculationConversionError(
- string.Format(
- Resources.ReadForeshoreProfile_ForeshoreProfile_0_has_no_geometry_and_cannot_be_used,
- foreshoreProfile.Name),
- calculationName);
-
- return false;
- }
- return true;
- }
-
- ///
/// Tries to find the hydraulic boundary location with the given
/// in the .
///
@@ -204,11 +155,10 @@
if (location == null)
{
- LogReadCalculationConversionError(
- string.Format(
- Resources.CalculationConfigurationImporter_ReadHydraulicBoundaryLocation_HydraulicBoundaryLocation_0_does_not_exist,
- locationName),
- calculationName);
+ Log.LogCalculationConversionError(string.Format(
+ Resources.CalculationConfigurationImporter_ReadHydraulicBoundaryLocation_HydraulicBoundaryLocation_0_does_not_exist,
+ locationName),
+ calculationName);
return false;
}
@@ -222,6 +172,7 @@
/// Tries to find the structure with the given
/// in the .
///
+ /// The type of the to read.
/// The name of the structure to find.
/// Name of the calculation to assign the structure to.
/// The collection of to search in.
@@ -249,11 +200,10 @@
if (structure == null)
{
- LogReadCalculationConversionError(
- string.Format(
- Resources.CalculationConfigurationImporter_ReadStructure_Structure_0_does_not_exist,
- structureName),
- calculationName);
+ Log.LogCalculationConversionError(string.Format(
+ Resources.CalculationConfigurationImporter_ReadStructure_Structure_0_does_not_exist,
+ structureName),
+ calculationName);
return false;
}
@@ -296,11 +246,10 @@
if (foreshoreProfile == null)
{
- LogReadCalculationConversionError(
- string.Format(
- Resources.CalculationConfigurationImporter_ReadForeshoreProfile_ForeshoreProfile_0_does_not_exist,
- foreshoreProfileName),
- calculationName);
+ Log.LogCalculationConversionError(string.Format(
+ Resources.CalculationConfigurationImporter_ReadForeshoreProfile_ForeshoreProfile_0_does_not_exist,
+ foreshoreProfileName),
+ calculationName);
return false;
}
@@ -344,6 +293,84 @@
}
}
+ ///
+ /// Reads the stochast parameters.
+ ///
+ /// The type of the distribution to read.
+ /// The type of the calculation input.
+ /// The name of the calculation to configure.
+ /// The stochast's name.
+ ///
+ /// The configuration of the stochast.
+ /// The function for obtaining the stochast to read.
+ /// The function to set the stochast with the read parameters.
+ /// true if reading all required stochast parameters was successful,
+ /// false otherwise.
+ protected bool TryReadStandardDeviationStochast(
+ string calculationName,
+ string stochastName,
+ TCalculationInput input,
+ MeanStandardDeviationStochastConfiguration stochastConfiguration,
+ Func getStochast,
+ Action setStochast)
+ where TDistribution : IDistribution
+ where TCalculationInput : ICalculationInput
+ {
+ if (stochastConfiguration == null)
+ {
+ return true;
+ }
+ var distribution = (TDistribution) getStochast(input).Clone();
+
+ if (!distribution.TrySetDistributionProperties(stochastConfiguration,
+ stochastName,
+ calculationName))
+ {
+ return false;
+ }
+ setStochast(input, distribution);
+ return true;
+ }
+
+ ///
+ /// Reads the stochast parameters.
+ ///
+ /// The type of the distribution to read.
+ /// The type of the calculation input.
+ /// The name of the calculation to configure.
+ /// The stochast's name.
+ ///
+ /// The configuration of the stochast.
+ /// The function for obtaining the stochast to read.
+ /// The function to set the stochast with the read parameters.
+ /// true if reading all required stochast parameters was successful,
+ /// false otherwise.
+ protected bool TryReadVariationCoefficientStochast(
+ string calculationName,
+ string stochastName,
+ TCalculationInput input,
+ MeanVariationCoefficientStochastConfiguration stochastConfiguration,
+ Func getStochast,
+ Action setStochast)
+ where TDistribution : IVariationCoefficientDistribution
+ where TCalculationInput : ICalculationInput
+ {
+ if (stochastConfiguration == null)
+ {
+ return true;
+ }
+ var distribution = (TDistribution) getStochast(input).Clone();
+
+ if (!distribution.TrySetDistributionProperties(stochastConfiguration,
+ stochastName,
+ calculationName))
+ {
+ return false;
+ }
+ setStochast(input, distribution);
+ return true;
+ }
+
private ReadResult ReadConfiguration()
{
try
@@ -358,7 +385,7 @@
{
string errorMessage = string.Format(Resources.CalculationConfigurationImporter_HandleCriticalFileReadError_Error_0_no_configuration_imported,
exception.Message);
- log.Error(errorMessage, exception);
+ Log.Error(errorMessage, exception);
return new ReadResult(true);
}
}
@@ -416,14 +443,5 @@
ImportTarget.Children.Add(parsedCalculationItem);
}
}
-
- private static bool HasParametersDefined(WaveReductionConfiguration waveReduction)
- {
- return waveReduction != null
- && (waveReduction.UseBreakWater.HasValue
- || waveReduction.UseForeshoreProfile.HasValue
- || waveReduction.BreakWaterHeight.HasValue
- || waveReduction.BreakWaterType.HasValue);
- }
}
}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -r512bebcd5570951b18657513c56843d9e2f8e969 -r335523a40d190e19b1061804de21c28f74140f52
--- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 512bebcd5570951b18657513c56843d9e2f8e969)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -1,25 +1,4 @@
-// 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
@@ -199,6 +178,26 @@
}
///
+ /// Looks up a localized string similar to Er kan geen standaardafwijking voor stochast 'modelfactoroverloopdebiet' opgegeven worden..
+ ///
+ public static string CalculationConfigurationImporter_ValidateStochasts_Cannot_define_StandardDeviation_for_ModelFactorSuperCriticalFlow {
+ get {
+ return ResourceManager.GetString("CalculationConfigurationImporter_ValidateStochasts_Cannot_define_StandardDeviatio" +
+ "n_for_ModelFactorSuperCriticalFlow", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Er kan geen variatiecoëfficiënt voor stochast 'stormduur' opgegeven worden..
+ ///
+ public static string CalculationConfigurationImporter_ValidateStochasts_Cannot_define_VariationCoefficient_for_StormDuration {
+ get {
+ return ResourceManager.GetString("CalculationConfigurationImporter_ValidateStochasts_Cannot_define_VariationCoeffic" +
+ "ient_for_StormDuration", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Er is geen voorlandprofiel opgegeven om golfreductie parameters aan toe te voegen..
///
public static string CalculationConfigurationImporter_ValidateWaveReduction_No_foreshore_profile_provided {
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx
===================================================================
diff -u -r512bebcd5570951b18657513c56843d9e2f8e969 -r335523a40d190e19b1061804de21c28f74140f52
--- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 512bebcd5570951b18657513c56843d9e2f8e969)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -613,4 +613,10 @@
Het opgegeven voorlandprofiel '{0}' heeft geen voorlandgeometrie en kan daarom niet gebruikt worden.
+
+ Er kan geen variatiecoëfficiënt voor stochast 'stormduur' opgegeven worden.
+
+
+ Er kan geen standaardafwijking voor stochast 'modelfactoroverloopdebiet' opgegeven worden.
+
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj
===================================================================
diff -u -r512bebcd5570951b18657513c56843d9e2f8e969 -r335523a40d190e19b1061804de21c28f74140f52
--- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 512bebcd5570951b18657513c56843d9e2f8e969)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -54,7 +54,9 @@
+
+
Fisheye: Tag 335523a40d190e19b1061804de21c28f74140f52 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/ConfigurationBreakWaterTypeConverterTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 335523a40d190e19b1061804de21c28f74140f52 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/DistributionConversionExtensionsTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/Helpers/ConfigurationBreakWaterTypeConverterTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/Helpers/ConfigurationBreakWaterTypeConverterTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/Helpers/ConfigurationBreakWaterTypeConverterTest.cs (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -0,0 +1,218 @@
+// 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.ComponentModel;
+using NUnit.Framework;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.IO.Configurations;
+using Ringtoets.Common.IO.Configurations.Helpers;
+using Ringtoets.Common.IO.Schema;
+
+namespace Ringtoets.Common.IO.Test.Configurations.Helpers
+{
+ [TestFixture]
+ public class ConfigurationBreakWaterTypeConverterTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var converter = new ConfigurationBreakWaterTypeConverter();
+
+ // Assert
+ Assert.IsInstanceOf(converter);
+ }
+
+ [Test]
+ public void CanConvertTo_String_ReturnTrue()
+ {
+ // Setup
+ var converter = new ConfigurationBreakWaterTypeConverter();
+
+ // Call
+ bool canConvertToString = converter.CanConvertTo(typeof(string));
+
+ // Assert
+ Assert.IsTrue(canConvertToString);
+ }
+
+ [Test]
+ public void CanConvertTo_BreakWaterType_ReturnTrue()
+ {
+ // Setup
+ var converter = new ConfigurationBreakWaterTypeConverter();
+
+ // Call
+ bool canConvertToString = converter.CanConvertTo(typeof(BreakWaterType));
+
+ // Assert
+ Assert.IsTrue(canConvertToString);
+ }
+
+ [Test]
+ public void CanConvertTo_OtherThanStringOrBreakWaterType_ReturnFalse()
+ {
+ // Setup
+ var converter = new ConfigurationBreakWaterTypeConverter();
+
+ // Call
+ bool canConvertToString = converter.CanConvertTo(typeof(object));
+
+ // Assert
+ Assert.IsFalse(canConvertToString);
+ }
+
+ [Test]
+ [TestCase(ConfigurationBreakWaterType.Caisson, ConfigurationSchemaIdentifiers.BreakWaterCaisson)]
+ [TestCase(ConfigurationBreakWaterType.Dam, ConfigurationSchemaIdentifiers.BreakWaterDam)]
+ [TestCase(ConfigurationBreakWaterType.Wall, ConfigurationSchemaIdentifiers.BreakWaterWall)]
+ public void ConvertTo_VariousCases_ReturnExpectedText(ConfigurationBreakWaterType value,
+ string expectedResult)
+ {
+ // Setup
+ var converter = new ConfigurationBreakWaterTypeConverter();
+
+ // Call
+ object result = converter.ConvertTo(value, typeof(string));
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+
+ [Test]
+ public void ConvertTo_InvalidBreakWaterType_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new ConfigurationBreakWaterTypeConverter();
+ var invalidValue = (ConfigurationBreakWaterType) 99999999;
+
+ // Call
+ TestDelegate call = () => converter.ConvertTo(invalidValue, typeof(string));
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ [TestCase(ConfigurationBreakWaterType.Caisson, BreakWaterType.Caisson)]
+ [TestCase(ConfigurationBreakWaterType.Dam, BreakWaterType.Dam)]
+ [TestCase(ConfigurationBreakWaterType.Wall, BreakWaterType.Wall)]
+ public void ConvertTo_VariousCases_ReturnExpectedText(ConfigurationBreakWaterType value,
+ BreakWaterType expectedResult)
+ {
+ // Setup
+ var converter = new ConfigurationBreakWaterTypeConverter();
+
+ // Call
+ object result = converter.ConvertTo(value, typeof(BreakWaterType));
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+
+ [Test]
+ public void CanConvertFrom_String_ReturnTrue()
+ {
+ // Setup
+ var converter = new ConfigurationBreakWaterTypeConverter();
+
+ // Call
+ bool canConvertFromString = converter.CanConvertFrom(typeof(string));
+
+ // Assert
+ Assert.IsTrue(canConvertFromString);
+ }
+
+ [Test]
+ public void CanConvertFrom_BreakWaterType_ReturnTrue()
+ {
+ // Setup
+ var converter = new ConfigurationBreakWaterTypeConverter();
+
+ // Call
+ bool canConvertFromString = converter.CanConvertFrom(typeof(BreakWaterType));
+
+ // Assert
+ Assert.IsTrue(canConvertFromString);
+ }
+
+ [Test]
+ public void CanConvertFrom_OtherThanStringOrBreakWaterType_ReturnFalse()
+ {
+ // Setup
+ var converter = new ConfigurationBreakWaterTypeConverter();
+
+ // Call
+ bool canConvertFromString = converter.CanConvertFrom(typeof(object));
+
+ // Assert
+ Assert.IsFalse(canConvertFromString);
+ }
+
+ [Test]
+ [TestCase(ConfigurationSchemaIdentifiers.BreakWaterCaisson, ConfigurationBreakWaterType.Caisson)]
+ [TestCase(ConfigurationSchemaIdentifiers.BreakWaterDam, ConfigurationBreakWaterType.Dam)]
+ [TestCase(ConfigurationSchemaIdentifiers.BreakWaterWall, ConfigurationBreakWaterType.Wall)]
+ public void ConvertFrom_Text_ReturnExpectedBreakWaterType(string value,
+ ConfigurationBreakWaterType expectedResult)
+ {
+ // Setup
+ var converter = new ConfigurationBreakWaterTypeConverter();
+
+ // Call
+ object result = converter.ConvertFrom(value);
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+
+ [Test]
+ public void ConvertFrom_InvalidText_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new ConfigurationBreakWaterTypeConverter();
+
+ // Call
+ TestDelegate call = () => converter.ConvertFrom("A");
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ [TestCase(BreakWaterType.Caisson, ConfigurationBreakWaterType.Caisson)]
+ [TestCase(BreakWaterType.Dam, ConfigurationBreakWaterType.Dam)]
+ [TestCase(BreakWaterType.Wall, ConfigurationBreakWaterType.Wall)]
+ public void ConvertFrom_BreakWaterType_ReturnExpectedBreakWaterType(BreakWaterType value,
+ ConfigurationBreakWaterType expectedResult)
+ {
+ // Setup
+ var converter = new ConfigurationBreakWaterTypeConverter();
+
+ // Call
+ object result = converter.ConvertFrom(value);
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/Helpers/ConfigurationValidationExtensionsTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/Helpers/ConfigurationValidationExtensionsTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/Helpers/ConfigurationValidationExtensionsTest.cs (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -0,0 +1,359 @@
+// 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 Core.Common.Base.Geometry;
+using Core.Common.TestUtil;
+using log4net;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.IO.Configurations;
+using Ringtoets.Common.IO.Configurations.Helpers;
+
+namespace Ringtoets.Common.IO.Test.Configurations.Helpers
+{
+ [TestFixture]
+ public class ConfigurationValidationExtensionsTest
+ {
+ [Test]
+ public void ValidateWaveReduction_NoLog_ThrowsArgumentNullException()
+ {
+ // Setup
+ const string calculationName = "calculation";
+
+ // Call
+ TestDelegate test = () => ((WaveReductionConfiguration)null).ValidateWaveReduction(null, calculationName, null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("log", exception.ParamName);
+ }
+
+ [Test]
+ public void ValidateWaveReduction_NoCalculationName_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var log = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => ((WaveReductionConfiguration)null).ValidateWaveReduction(null, null, log);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("calculationName", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ValidateWaveReduction_NoForeshoreProfileNoParameters_ReturnsTrue()
+ {
+ // Setup
+ const string calculationName = "calculation";
+
+ var mocks = new MockRepository();
+ var log = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ // Call
+ bool valid = ((WaveReductionConfiguration)null).ValidateWaveReduction(null, calculationName, log);
+
+ // Assert
+ Assert.IsTrue(valid);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ValidateWaveReduction_NoForeshoreProfileWaveReductionWithoutParameters_ReturnsTrue()
+ {
+ // Setup
+ const string calculationName = "calculation";
+
+ var mocks = new MockRepository();
+ var log = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ // Call
+ bool valid = new WaveReductionConfiguration().ValidateWaveReduction(null, calculationName, log);
+
+ // Assert
+ Assert.IsTrue(valid);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ValidateWaveReduction_NoForeshoreProfileWaveReductionWithParameter_LogsErrorReturnsFalse([Values(0, 1, 2, 3)] int propertyToSet)
+ {
+ // Setup
+ const string calculationName = "calculation";
+ const string error = "Er is geen voorlandprofiel opgegeven om golfreductie parameters aan toe te voegen.";
+ const string expectedMessage = "{0} Berekening '{1}' is overgeslagen.";
+
+ var mocks = new MockRepository();
+ var log = mocks.StrictMock();
+ log.Expect(l => l.ErrorFormat(expectedMessage, error, calculationName));
+ mocks.ReplayAll();
+
+ var waveReductionConfiguration = new WaveReductionConfiguration();
+ var random = new Random(21);
+
+ switch (propertyToSet)
+ {
+ case 0:
+ waveReductionConfiguration.BreakWaterType = random.NextEnumValue();
+ break;
+ case 1:
+ waveReductionConfiguration.BreakWaterHeight = random.NextDouble();
+ break;
+ case 2:
+ waveReductionConfiguration.UseBreakWater = random.NextBoolean();
+ break;
+ case 3:
+ waveReductionConfiguration.UseForeshoreProfile = random.NextBoolean();
+ break;
+ }
+ ;
+
+ // Call
+ bool valid = waveReductionConfiguration.ValidateWaveReduction(null, calculationName, log);
+
+ // Assert
+ Assert.IsFalse(valid);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ValidateWaveReduction_ForeshoreProfileWithGeometryForeshoreProfileUsed_ReturnsTrue()
+ {
+ // Setup
+ const string calculationName = "calculation";
+
+ var mocks = new MockRepository();
+ var log = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ var waveReductionConfiguration = new WaveReductionConfiguration
+ {
+ UseForeshoreProfile = true
+ };
+
+ // Call
+ bool valid = waveReductionConfiguration.ValidateWaveReduction(new TestForeshoreProfile("voorland", new[]
+ {
+ new Point2D(0, 2)
+ }), calculationName, log);
+
+ // Assert
+ Assert.IsTrue(valid);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ValidateWaveReduction_ForeshoreProfileWithoutGeometryForeshoreProfileUsed_LogsErrorReturnsFalse()
+ {
+ // Setup
+ const string profileName = "voorland";
+ const string calculationName = "calculation";
+ const string expectedMessage = "{0} Berekening '{1}' is overgeslagen.";
+
+ string error = $"Het opgegeven voorlandprofiel '{profileName}' heeft geen voorlandgeometrie en kan daarom niet gebruikt worden.";
+
+ var mocks = new MockRepository();
+ var log = mocks.StrictMock();
+ log.Expect(l => l.ErrorFormat(expectedMessage, error, calculationName));
+ mocks.ReplayAll();
+
+ var waveReductionConfiguration = new WaveReductionConfiguration
+ {
+ UseForeshoreProfile = true
+ };
+
+ // Call
+ bool valid = waveReductionConfiguration.ValidateWaveReduction(new TestForeshoreProfile(profileName), calculationName, log);
+
+ // Assert
+ Assert.IsFalse(valid);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ValidateStochasts_NoLog_ThrowsArgumentNullException()
+ {
+ // Setup
+ const string calculationName = "calculation";
+
+ // Call
+ TestDelegate test = () => new TestStructuresCalculationConfiguration(calculationName).ValidateStochasts(null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("log", exception.ParamName);
+ }
+
+ [Test]
+ public void ValidateStochasts_NoConfiguration_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var log = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => ((StructuresCalculationConfiguration)null).ValidateStochasts(log);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("configuration", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ValidateStochasts_ConfigurationWithoutStochasts_ReturnsTrue()
+ {
+ // Setup
+ const string calculationName = "calculation";
+
+ var mocks = new MockRepository();
+ var log = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ var configuration = new TestStructuresCalculationConfiguration(calculationName);
+
+ // Call
+ configuration.ValidateStochasts(log);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ValidateStochasts_StormDurationWithVariationCoefficient_ReturnsFalseLogsError()
+ {
+ // Setup
+ const string calculationName = "calculation";
+ const string expectedMessage = "{0} Berekening '{1}' is overgeslagen.";
+ string error = "Er kan geen variatiecoëfficiënt voor stochast 'stormduur' opgegeven worden.";
+
+ var mocks = new MockRepository();
+ var log = mocks.StrictMock();
+ log.Expect(l => l.ErrorFormat(expectedMessage, error, calculationName));
+ mocks.ReplayAll();
+
+ var configuration = new TestStructuresCalculationConfiguration(calculationName)
+ {
+ StormDuration = new MeanVariationCoefficientStochastConfiguration
+ {
+ VariationCoefficient = new Random(21).NextDouble()
+ }
+ };
+
+ // Call
+ configuration.ValidateStochasts(log);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ValidateStochasts_StormDurationWithMean_ReturnsTrue()
+ {
+ // Setup
+ const string calculationName = "calculation";
+
+ var mocks = new MockRepository();
+ var log = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ var configuration = new TestStructuresCalculationConfiguration(calculationName)
+ {
+ StormDuration = new MeanVariationCoefficientStochastConfiguration
+ {
+ Mean = new Random(21).NextDouble()
+ }
+ };
+
+ // Call
+ configuration.ValidateStochasts(log);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ValidateStochasts_ModelFactorSuperCriticalFlowWithStandardDeviation_ReturnsFalseLogsError()
+ {
+ // Setup
+ const string calculationName = "calculation";
+ const string expectedMessage = "{0} Berekening '{1}' is overgeslagen.";
+ string error = "Er kan geen standaardafwijking voor stochast 'modelfactoroverloopdebiet' opgegeven worden.";
+
+ var mocks = new MockRepository();
+ var log = mocks.StrictMock();
+ log.Expect(l => l.ErrorFormat(expectedMessage, error, calculationName));
+ mocks.ReplayAll();
+
+ var configuration = new TestStructuresCalculationConfiguration(calculationName)
+ {
+ ModelFactorSuperCriticalFlow = new MeanStandardDeviationStochastConfiguration()
+ {
+ StandardDeviation = new Random(21).NextDouble()
+ }
+ };
+
+ // Call
+ configuration.ValidateStochasts(log);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ValidateStochasts_ModelFactorSuperCriticalFlowWithMean_ReturnsTrue()
+ {
+ // Setup
+ const string calculationName = "calculation";
+
+ var mocks = new MockRepository();
+ var log = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ var configuration = new TestStructuresCalculationConfiguration(calculationName)
+ {
+ ModelFactorSuperCriticalFlow = new MeanStandardDeviationStochastConfiguration()
+ {
+ Mean = new Random(21).NextDouble()
+ }
+ };
+
+ // Call
+ configuration.ValidateStochasts(log);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+ }
+
+ public class TestStructuresCalculationConfiguration : StructuresCalculationConfiguration {
+ public TestStructuresCalculationConfiguration(string name) : base(name) {}
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/Helpers/DistributionConversionExtensionsTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/Helpers/DistributionConversionExtensionsTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/Helpers/DistributionConversionExtensionsTest.cs (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -0,0 +1,815 @@
+// 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 Core.Common.Base.Data;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.Probabilistics;
+using Ringtoets.Common.IO.Configurations;
+using Ringtoets.Common.IO.Configurations.Helpers;
+
+namespace Ringtoets.Common.IO.Test.Configurations.Helpers
+{
+ [TestFixture]
+ public class DistributionConversionExtensionsTest
+ {
+ [Test]
+ public void ToStochastConfiguration_DistributionNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ IDistribution distribution = null;
+
+ // Call
+ TestDelegate test = () => distribution.ToStochastConfiguration();
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("distribution", exception.ParamName);
+ }
+
+ [Test]
+ public void ToStochastConfiguration_WithDistribution_InstanceWithExpectedParametersSet()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var distribution = mocks.Stub();
+ mocks.ReplayAll();
+
+ var random = new Random(21);
+ RoundedDouble mean = random.NextRoundedDouble();
+ RoundedDouble standardDeviation = random.NextRoundedDouble();
+
+ distribution.Mean = mean;
+ distribution.StandardDeviation = standardDeviation;
+
+ // Call
+ MeanStandardDeviationStochastConfiguration configuration = distribution.ToStochastConfiguration();
+
+ // Assert
+ Assert.AreEqual(mean, configuration.Mean);
+ Assert.AreEqual(standardDeviation, configuration.StandardDeviation);
+ }
+
+ [Test]
+ public void ToStochastConfigurationWithMean_DistributionNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ IDistribution distribution = null;
+
+ // Call
+ TestDelegate test = () => distribution.ToStochastConfigurationWithMean();
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("distribution", exception.ParamName);
+ }
+
+ [Test]
+ public void ToStochastConfigurationWithMean_WithDistribution_InstanceWithExpectedParametersSet()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var distribution = mocks.Stub();
+ mocks.ReplayAll();
+
+ var random = new Random(21);
+ RoundedDouble mean = random.NextRoundedDouble();
+
+ distribution.Mean = mean;
+
+ // Call
+ MeanStandardDeviationStochastConfiguration configuration = distribution.ToStochastConfigurationWithMean();
+
+ // Assert
+ Assert.AreEqual(mean, configuration.Mean);
+ Assert.IsNull(configuration.StandardDeviation);
+ }
+
+ [Test]
+ public void ToStochastConfigurationWithStandardDeviation_DistributionNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ IDistribution distribution = null;
+
+ // Call
+ TestDelegate test = () => distribution.ToStochastConfigurationWithStandardDeviation();
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("distribution", exception.ParamName);
+ }
+
+ [Test]
+ public void ToStochastConfigurationWithStandardDeviation_WithDistribution_InstanceWithExpectedParametersSet()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var distribution = mocks.Stub();
+ mocks.ReplayAll();
+
+ var random = new Random(21);
+ RoundedDouble StandardDeviation = random.NextRoundedDouble();
+
+ distribution.StandardDeviation = StandardDeviation;
+
+ // Call
+ MeanStandardDeviationStochastConfiguration configuration = distribution.ToStochastConfigurationWithStandardDeviation();
+
+ // Assert
+ Assert.IsNull(configuration.Mean);
+ Assert.AreEqual(StandardDeviation, configuration.StandardDeviation);
+ }
+
+ [Test]
+ public void ToStochastConfiguration_VariationCoefficientDistributionNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ IVariationCoefficientDistribution distribution = null;
+
+ // Call
+ TestDelegate test = () => distribution.ToStochastConfiguration();
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("distribution", exception.ParamName);
+ }
+
+ [Test]
+ public void ToStochastConfiguration_WithVariationCoefficientDistribution_InstanceWithExpectedParametersSet()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var distribution = mocks.Stub();
+ mocks.ReplayAll();
+
+ var random = new Random(21);
+ RoundedDouble mean = random.NextRoundedDouble();
+ RoundedDouble variationCoefficient = random.NextRoundedDouble();
+
+ distribution.Mean = mean;
+ distribution.CoefficientOfVariation = variationCoefficient;
+
+ // Call
+ MeanVariationCoefficientStochastConfiguration configuration = distribution.ToStochastConfiguration();
+
+ // Assert
+ Assert.AreEqual(mean, configuration.Mean);
+ Assert.AreEqual(variationCoefficient, configuration.VariationCoefficient);
+ }
+
+ [Test]
+ public void ToStochastConfigurationWithMean_VariationCoefficientDistributionNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ IVariationCoefficientDistribution distribution = null;
+
+ // Call
+ TestDelegate test = () => distribution.ToStochastConfigurationWithMean();
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("distribution", exception.ParamName);
+ }
+
+ [Test]
+ public void ToStochastConfigurationWithMean_WithVariationCoefficientDistribution_InstanceWithExpectedParametersSet()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var distribution = mocks.Stub();
+ mocks.ReplayAll();
+
+ var random = new Random(21);
+ RoundedDouble mean = random.NextRoundedDouble();
+
+ distribution.Mean = mean;
+
+ // Call
+ MeanVariationCoefficientStochastConfiguration configuration = distribution.ToStochastConfigurationWithMean();
+
+ // Assert
+ Assert.AreEqual(mean, configuration.Mean);
+ Assert.IsNull(configuration.VariationCoefficient);
+ }
+
+ [Test]
+ public void ToStochastConfigurationWithVariationCoefficient_DistributionNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ IVariationCoefficientDistribution distribution = null;
+
+ // Call
+ TestDelegate test = () => distribution.ToStochastConfigurationWithVariationCoefficient();
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("distribution", exception.ParamName);
+ }
+
+ [Test]
+ public void ToStochastConfigurationWithVariationCoefficient_WithDistribution_InstanceWithExpectedParametersSet()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var distribution = mocks.Stub();
+ mocks.ReplayAll();
+
+ var random = new Random(21);
+ RoundedDouble variationCoefficient = random.NextRoundedDouble();
+
+ distribution.CoefficientOfVariation = variationCoefficient;
+
+ // Call
+ MeanVariationCoefficientStochastConfiguration configuration = distribution.ToStochastConfigurationWithVariationCoefficient();
+
+ // Assert
+ Assert.IsNull(configuration.Mean);
+ Assert.AreEqual(variationCoefficient, configuration.VariationCoefficient);
+ }
+
+ [Test]
+ public void TrySetMean_DistributionNull_ThrownArgumentNullException()
+ {
+ // Setup
+ IDistribution distribution = null;
+
+ const double mean = 1.1;
+
+ // Call
+ TestDelegate call = () => distribution.TrySetMean(mean, "A", "B");
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("distribution", paramName);
+ }
+
+ [Test]
+ public void TrySetMean_DistributionMeanNull_ReturnTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var distribution = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ // Call
+ bool result = distribution.TrySetMean(null, "A", "B");
+
+ // Assert
+ Assert.IsTrue(result);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void TrySetMean_DistributionMeanValid_SetMeanAndReturnTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var distribution = mocks.Stub();
+ mocks.ReplayAll();
+
+ const double mean = 1.1;
+
+ // Call
+ bool result = distribution.TrySetMean(mean, "A", "B");
+
+ // Assert
+ Assert.AreEqual(mean, distribution.Mean);
+ Assert.IsTrue(result);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void TrySetMean_SettingDistributionMeanThrowArgumentOutOfRangeException_LogErrorAndReturnFalse()
+ {
+ // Setup
+ const string exceptionMessage = "A";
+ var mocks = new MockRepository();
+ var distribution = mocks.StrictMock();
+ distribution.Expect(d => d.Mean)
+ .SetPropertyAndIgnoreArgument()
+ .Throw(new ArgumentOutOfRangeException(null, exceptionMessage));
+ mocks.ReplayAll();
+
+ const int mean = 5;
+ const string stochastName = "B";
+ const string calculationName = "C";
+
+ // Call
+ bool result = true;
+ Action call = () => result = distribution.TrySetMean(mean, "B", "C");
+
+ // Assert
+ var expectedMessage = Tuple.Create($"Een gemiddelde van '{mean}' is ongeldig voor stochast '{stochastName}'. " +
+ exceptionMessage +
+ $" Berekening '{calculationName}' is overgeslagen.",
+ LogLevelConstant.Error);
+ TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedMessage, 1);
+ Assert.IsFalse(result);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void TrySetStandardDeviation_DistributionNull_ThrownArgumentNullException()
+ {
+ // Setup
+ IDistribution distribution = null;
+
+ const double mean = 1.1;
+
+ // Call
+ TestDelegate call = () => distribution.TrySetStandardDeviation(mean, "A", "B");
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("distribution", paramName);
+ }
+
+ [Test]
+ public void TrySetStandardDeviation_DistributionStandardDeviationNull_ReturnTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var distribution = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ // Call
+ bool result = distribution.TrySetStandardDeviation(null, "A", "B");
+
+ // Assert
+ Assert.IsTrue(result);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void TrySetStandardDeviation_DistributionStandardDeviationValid_SetStandardDeviationAndReturnTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var distribution = mocks.Stub();
+ mocks.ReplayAll();
+
+ const double standardDeviation = 1.1;
+
+ // Call
+ bool result = distribution.TrySetStandardDeviation(standardDeviation, "A", "B");
+
+ // Assert
+ Assert.AreEqual(standardDeviation, distribution.StandardDeviation);
+ Assert.IsTrue(result);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void TrySetStandardDeviation_SettingDistributionStandardDeviationThrowArgumentOutOfRangeException_LogErrorAndReturnFalse()
+ {
+ // Setup
+ const string exceptionMessage = "A";
+ var mocks = new MockRepository();
+ var distribution = mocks.StrictMock();
+ distribution.Expect(d => d.StandardDeviation)
+ .SetPropertyAndIgnoreArgument()
+ .Throw(new ArgumentOutOfRangeException(null, exceptionMessage));
+ mocks.ReplayAll();
+
+ const int standardDeviation = 5;
+ const string stochastName = "B";
+ const string calculationName = "C";
+
+ // Call
+ bool result = true;
+ Action call = () => result = distribution.TrySetStandardDeviation(standardDeviation, "B", "C");
+
+ // Assert
+ var expectedMessage = Tuple.Create($"Een standaardafwijking van '{standardDeviation}' is ongeldig voor stochast '{stochastName}'. " +
+ exceptionMessage +
+ $" Berekening '{calculationName}' is overgeslagen.",
+ LogLevelConstant.Error);
+ TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedMessage, 1);
+ Assert.IsFalse(result);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void TrySetDistributionProperties_DistributionNull_ThrownArgumentNullException()
+ {
+ // Setup
+ IDistribution distribution = null;
+
+ const double mean = 1.1;
+ const double standardDeviation = 2.2;
+
+ // Call
+ TestDelegate call = () => distribution.TrySetDistributionProperties(mean, standardDeviation, "A", "B");
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("distribution", paramName);
+ }
+
+ [Test]
+ [TestCase(null, null)]
+ [TestCase(1.0, null)]
+ [TestCase(null, 2.0)]
+ [TestCase(3.0, 4.0)]
+ public void TrySetMean_DistributionMeanValidValue_ReturnTrue(double? mean, double? standardDeviation)
+ {
+ // Setup
+ var defaultMean = new RoundedDouble(2, -1.0);
+ var defaultStandardDeviation = new RoundedDouble(2, -2.0);
+
+ var mocks = new MockRepository();
+ var distribution = mocks.Stub();
+ mocks.ReplayAll();
+
+ distribution.Mean = defaultMean;
+ distribution.StandardDeviation = defaultStandardDeviation;
+
+ // Call
+ bool result = distribution.TrySetDistributionProperties(mean, standardDeviation, "A", "B");
+
+ // Assert
+ Assert.IsTrue(result);
+
+ Assert.AreEqual(mean ?? defaultMean.Value, distribution.Mean.Value);
+ Assert.AreEqual(standardDeviation ?? defaultStandardDeviation.Value, distribution.StandardDeviation.Value);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void TrySetDistributionProperties_SettingDistributionMeanThrowArgumentOutOfRangeException_LogErrorAndReturnFalse()
+ {
+ // Setup
+ const string exceptionMessage = "A";
+ var mocks = new MockRepository();
+ var distribution = mocks.StrictMock();
+ distribution.Expect(d => d.Mean)
+ .SetPropertyAndIgnoreArgument()
+ .Throw(new ArgumentOutOfRangeException(null, exceptionMessage));
+ distribution.Stub(d => d.StandardDeviation)
+ .SetPropertyAndIgnoreArgument()
+ .Repeat.Any();
+ mocks.ReplayAll();
+
+ const int mean = 5;
+ const string stochastName = "B";
+ const string calculationName = "C";
+
+ // Call
+ bool result = true;
+ Action call = () => result = distribution.TrySetDistributionProperties(mean, 2.2, "B", "C");
+
+ // Assert
+ var expectedMessage = Tuple.Create($"Een gemiddelde van '{mean}' is ongeldig voor stochast '{stochastName}'. " +
+ exceptionMessage +
+ $" Berekening '{calculationName}' is overgeslagen.",
+ LogLevelConstant.Error);
+ TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedMessage, 1);
+ Assert.IsFalse(result);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void TrySetDistributionProperties_SettingDistributionStandardDeviationThrowArgumentOutOfRangeException_LogErrorAndReturnFalse()
+ {
+ // Setup
+ const string exceptionMessage = "A";
+ var mocks = new MockRepository();
+ var distribution = mocks.StrictMock();
+ distribution.Expect(d => d.StandardDeviation)
+ .SetPropertyAndIgnoreArgument()
+ .Throw(new ArgumentOutOfRangeException(null, exceptionMessage));
+ distribution.Stub(d => d.Mean)
+ .SetPropertyAndIgnoreArgument()
+ .Repeat.Any();
+ mocks.ReplayAll();
+
+ const int standardDeviation = 5;
+ const string stochastName = "B";
+ const string calculationName = "C";
+
+ // Call
+ bool result = true;
+ Action call = () => result = distribution.TrySetDistributionProperties(1.1, standardDeviation, "B", "C");
+
+ // Assert
+ var expectedMessage = Tuple.Create($"Een standaardafwijking van '{standardDeviation}' is ongeldig voor stochast '{stochastName}'. " +
+ exceptionMessage +
+ $" Berekening '{calculationName}' is overgeslagen.",
+ LogLevelConstant.Error);
+ TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedMessage, 1);
+ Assert.IsFalse(result);
+
+ mocks.VerifyAll();
+ }
+ [Test]
+ public void TrySetMean_VariationCoefficientDistributionNull_ThrownArgumentNullException()
+ {
+ // Setup
+ IVariationCoefficientDistribution distribution = null;
+
+ const double mean = 1.1;
+
+ // Call
+ TestDelegate call = () => distribution.TrySetMean(mean, "A", "B");
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("distribution", paramName);
+ }
+
+ [Test]
+ public void TrySetMean_VariationCoefficientDistributionMeanNull_ReturnTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var distribution = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ // Call
+ bool result = distribution.TrySetMean(null, "A", "B");
+
+ // Assert
+ Assert.IsTrue(result);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void TrySetMean_VariationCoefficientDistributionMeanValid_SetMeanAndReturnTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var distribution = mocks.Stub();
+ mocks.ReplayAll();
+
+ const double mean = 1.1;
+
+ // Call
+ bool result = distribution.TrySetMean(mean, "A", "B");
+
+ // Assert
+ Assert.AreEqual(mean, distribution.Mean);
+ Assert.IsTrue(result);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void TrySetMean_SettingVariationCoefficientDistributionMeanThrowArgumentOutOfRangeException_LogErrorAndReturnFalse()
+ {
+ // Setup
+ const string exceptionMessage = "A";
+ var mocks = new MockRepository();
+ var distribution = mocks.StrictMock();
+ distribution.Expect(d => d.Mean)
+ .SetPropertyAndIgnoreArgument()
+ .Throw(new ArgumentOutOfRangeException(null, exceptionMessage));
+ mocks.ReplayAll();
+
+ const int mean = 5;
+ const string stochastName = "B";
+ const string calculationName = "C";
+
+ // Call
+ bool result = true;
+ Action call = () => result = distribution.TrySetMean(mean, "B", "C");
+
+ // Assert
+ var expectedMessage = Tuple.Create($"Een gemiddelde van '{mean}' is ongeldig voor stochast '{stochastName}'. " +
+ exceptionMessage +
+ $" Berekening '{calculationName}' is overgeslagen.",
+ LogLevelConstant.Error);
+ TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedMessage, 1);
+ Assert.IsFalse(result);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void TrySetVariationCoefficient_VariationCoefficientDistributionNull_ThrownArgumentNullException()
+ {
+ // Setup
+ IVariationCoefficientDistribution distribution = null;
+
+ const double mean = 1.1;
+
+ // Call
+ TestDelegate call = () => distribution.TrySetVariationCoefficient(mean, "A", "B");
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("distribution", paramName);
+ }
+
+ [Test]
+ public void TrySetVariationCoefficient_VariationCoefficientDistributionVariationCoefficientNull_ReturnTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var distribution = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ // Call
+ bool result = distribution.TrySetVariationCoefficient(null, "A", "B");
+
+ // Assert
+ Assert.IsTrue(result);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void TrySetVariationCoefficient_VariationCoefficientDistributionVariationCoefficientValid_SetVariationCoefficientAndReturnTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var distribution = mocks.Stub();
+ mocks.ReplayAll();
+
+ const double variationCoefficient = 1.1;
+
+ // Call
+ bool result = distribution.TrySetVariationCoefficient(variationCoefficient, "A", "B");
+
+ // Assert
+ Assert.AreEqual(variationCoefficient, distribution.CoefficientOfVariation);
+ Assert.IsTrue(result);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void TrySetVariationCoefficient_SettingVariationCoefficientDistributionVariationCoefficientThrowArgumentOutOfRangeException_LogErrorAndReturnFalse()
+ {
+ // Setup
+ const string exceptionMessage = "A";
+ var mocks = new MockRepository();
+ var distribution = mocks.StrictMock();
+ distribution.Expect(d => d.CoefficientOfVariation)
+ .SetPropertyAndIgnoreArgument()
+ .Throw(new ArgumentOutOfRangeException(null, exceptionMessage));
+ mocks.ReplayAll();
+
+ const int variationCoefficient = 5;
+ const string stochastName = "B";
+ const string calculationName = "C";
+
+ // Call
+ bool result = true;
+ Action call = () => result = distribution.TrySetVariationCoefficient(variationCoefficient, "B", "C");
+
+ // Assert
+ var expectedMessage = Tuple.Create($"Een variatiecoëfficiënt van '{variationCoefficient}' is ongeldig voor stochast '{stochastName}'. " +
+ exceptionMessage +
+ $" Berekening '{calculationName}' is overgeslagen.",
+ LogLevelConstant.Error);
+ TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedMessage, 1);
+ Assert.IsFalse(result);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void TrySetDistributionProperties_VariationCoefficientDistributionNull_ThrownArgumentNullException()
+ {
+ // Setup
+ IVariationCoefficientDistribution distribution = null;
+
+ const double mean = 1.1;
+ const double variationCoefficient = 2.2;
+
+ // Call
+ TestDelegate call = () => distribution.TrySetDistributionProperties(mean, variationCoefficient, "A", "B");
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("distribution", paramName);
+ }
+
+ [Test]
+ [TestCase(null, null)]
+ [TestCase(1.0, null)]
+ [TestCase(null, 2.0)]
+ [TestCase(3.0, 4.0)]
+ public void TrySetMean_VariationCoefficientDistributionMeanValidValue_ReturnTrue(double? mean, double? variationCoefficient)
+ {
+ // Setup
+ var defaultMean = new RoundedDouble(2, -1.0);
+ var defaultVariationCoefficient = new RoundedDouble(2, -2.0);
+
+ var mocks = new MockRepository();
+ var distribution = mocks.Stub();
+ mocks.ReplayAll();
+
+ distribution.Mean = defaultMean;
+ distribution.CoefficientOfVariation = defaultVariationCoefficient;
+
+ // Call
+ bool result = distribution.TrySetDistributionProperties(mean, variationCoefficient, "A", "B");
+
+ // Assert
+ Assert.IsTrue(result);
+
+ Assert.AreEqual(mean ?? defaultMean.Value, distribution.Mean.Value);
+ Assert.AreEqual(variationCoefficient ?? defaultVariationCoefficient.Value, distribution.CoefficientOfVariation.Value);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void TrySetDistributionProperties_SettingVariationCoefficientDistributionMeanThrowArgumentOutOfRangeException_LogErrorAndReturnFalse()
+ {
+ // Setup
+ const string exceptionMessage = "A";
+ var mocks = new MockRepository();
+ var distribution = mocks.StrictMock();
+ distribution.Expect(d => d.Mean)
+ .SetPropertyAndIgnoreArgument()
+ .Throw(new ArgumentOutOfRangeException(null, exceptionMessage));
+ distribution.Stub(d => d.CoefficientOfVariation)
+ .SetPropertyAndIgnoreArgument()
+ .Repeat.Any();
+ mocks.ReplayAll();
+
+ const int mean = 5;
+ const string stochastName = "B";
+ const string calculationName = "C";
+
+ // Call
+ bool result = true;
+ Action call = () => result = distribution.TrySetDistributionProperties(mean, 2.2, "B", "C");
+
+ // Assert
+ var expectedMessage = Tuple.Create($"Een gemiddelde van '{mean}' is ongeldig voor stochast '{stochastName}'. " +
+ exceptionMessage +
+ $" Berekening '{calculationName}' is overgeslagen.",
+ LogLevelConstant.Error);
+ TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedMessage, 1);
+ Assert.IsFalse(result);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void TrySetDistributionProperties_SettingVariationCoefficientDistributionVariationCoefficientThrowArgumentOutOfRangeException_LogErrorAndReturnFalse()
+ {
+ // Setup
+ const string exceptionMessage = "A";
+ var mocks = new MockRepository();
+ var distribution = mocks.StrictMock();
+ distribution.Expect(d => d.CoefficientOfVariation)
+ .SetPropertyAndIgnoreArgument()
+ .Throw(new ArgumentOutOfRangeException(null, exceptionMessage));
+ distribution.Stub(d => d.Mean)
+ .SetPropertyAndIgnoreArgument()
+ .Repeat.Any();
+ mocks.ReplayAll();
+
+ const int variationCoefficient = 5;
+ const string stochastName = "B";
+ const string calculationName = "C";
+
+ // Call
+ bool result = true;
+ Action call = () => result = distribution.TrySetDistributionProperties(1.1, variationCoefficient, "B", "C");
+
+ // Assert
+ var expectedMessage = Tuple.Create($"Een variatiecoëfficiënt van '{variationCoefficient}' is ongeldig voor stochast '{stochastName}'. " +
+ exceptionMessage +
+ $" Berekening '{calculationName}' is overgeslagen.",
+ LogLevelConstant.Error);
+ TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedMessage, 1);
+ Assert.IsFalse(result);
+
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/Helpers/ILogExtensionsTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/Helpers/ILogExtensionsTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/Helpers/ILogExtensionsTest.cs (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -0,0 +1,74 @@
+// 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 log4net;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.IO.Configurations.Helpers;
+
+namespace Ringtoets.Common.IO.Test.Configurations.Helpers
+{
+ [TestFixture]
+ public class ILogExtensionsTest
+ {
+ [Test]
+ public void LogOutOfRangeException_Always_LogMessage()
+ {
+ // Setup
+ const string message = "an error";
+ const string calculationName = "calculationA";
+ const string innerMessage = "Inner message";
+
+ var mocks = new MockRepository();
+ var log = mocks.StrictMock();
+ log.Expect(l => l.ErrorFormat("{0} Berekening '{1}' is overgeslagen.", $"{message} {innerMessage}", calculationName));
+ mocks.ReplayAll();
+
+ var exception = new ArgumentOutOfRangeException(null, innerMessage);
+
+ // Call
+ log.LogOutOfRangeException(message, calculationName, exception);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void LogCalculationConversionError_Always_LogMessage()
+ {
+ // Setup
+ const string message = "an error";
+ const string calculationName = "calculationA";
+
+ var mocks = new MockRepository();
+ var log = mocks.StrictMock();
+ log.Expect(l => l.ErrorFormat("{0} Berekening '{1}' is overgeslagen.", message, calculationName));
+ mocks.ReplayAll();
+
+ // Call
+ log.LogCalculationConversionError(message, calculationName);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/CalculationConfigurationImporterTest.cs
===================================================================
diff -u -rb80222df5e484e90e255f10116a7e88ead10a289 -r335523a40d190e19b1061804de21c28f74140f52
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/CalculationConfigurationImporterTest.cs (.../CalculationConfigurationImporterTest.cs) (revision b80222df5e484e90e255f10116a7e88ead10a289)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/CalculationConfigurationImporterTest.cs (.../CalculationConfigurationImporterTest.cs) (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -36,6 +36,7 @@
using Ringtoets.Common.Data.Hydraulics;
using Ringtoets.Common.Data.TestUtil;
using Ringtoets.Common.IO.Configurations;
+using Ringtoets.Common.IO.Configurations.Helpers;
using Ringtoets.Common.IO.FileImporters;
using Ringtoets.Common.IO.Readers;
using Ringtoets.Common.IO.Schema;
@@ -209,167 +210,8 @@
Assert.IsTrue(successful);
AssertCalculationGroup(GetExpectedNestedData(), calculationGroup);
}
-
+
[Test]
- public void ValidateWaveReduction_NoCalculationName_ThrowsArgumentNullException()
- {
- // Setup
- string filePath = Path.Combine(readerPath, "validConfiguration.xml");
-
- var calculationGroup = new CalculationGroup();
-
- var importer = new CalculationConfigurationImporter(filePath,
- calculationGroup);
-
- // Call
- TestDelegate test = () => importer.PublicValidateWaveReduction(null, null, null);
-
- // Assert
- var exception = Assert.Throws(test);
- Assert.AreEqual("calculationName", exception.ParamName);
- }
-
- [Test]
- public void ValidateWaveReduction_NoForeshoreProfileNoParameters_ReturnsTrue()
- {
- // Setup
- string filePath = Path.Combine(readerPath, "validConfiguration.xml");
- const string calculationName = "calculation";
-
- var calculationGroup = new CalculationGroup();
-
- var importer = new CalculationConfigurationImporter(filePath,
- calculationGroup);
-
- // Call
- bool valid = importer.PublicValidateWaveReduction(null, null, calculationName);
-
- // Assert
- Assert.IsTrue(valid);
- }
-
- [Test]
- public void ValidateWaveReduction_NoForeshoreProfileWaveReductionWithoutParameters_ReturnsTrue()
- {
- // Setup
- string filePath = Path.Combine(readerPath, "validConfiguration.xml");
- const string calculationName = "calculation";
-
- var calculationGroup = new CalculationGroup();
-
- var importer = new CalculationConfigurationImporter(filePath,
- calculationGroup);
-
- // Call
- bool valid = importer.PublicValidateWaveReduction(new WaveReductionConfiguration(), null, calculationName);
-
- // Assert
- Assert.IsTrue(valid);
- }
-
- [Test]
- public void ValidateWaveReduction_NoForeshoreProfileWaveReductionWithParameter_LogsErrorReturnsFalse([Values(0, 1, 2, 3)] int propertyToSet)
- {
- // Setup
- string filePath = Path.Combine(readerPath, "validConfiguration.xml");
- const string calculationName = "calculation";
-
- var calculationGroup = new CalculationGroup();
-
- var importer = new CalculationConfigurationImporter(filePath,
- calculationGroup);
-
- var waveReductionConfiguration = new WaveReductionConfiguration();
- var random = new Random(21);
-
- switch (propertyToSet)
- {
- case 0:
- waveReductionConfiguration.BreakWaterType = random.NextEnumValue();
- break;
- case 1:
- waveReductionConfiguration.BreakWaterHeight = random.NextDouble();
- break;
- case 2:
- waveReductionConfiguration.UseBreakWater = random.NextBoolean();
- break;
- case 3:
- waveReductionConfiguration.UseForeshoreProfile = random.NextBoolean();
- break;
- }
- ;
-
- var valid = true;
-
- // Call
- Action validate = () => valid = importer.PublicValidateWaveReduction(waveReductionConfiguration, null, calculationName);
-
- // Assert
- string expectedMessage = $"Er is geen voorlandprofiel opgegeven om golfreductie parameters aan toe te voegen. Berekening '{calculationName}' is overgeslagen.";
- TestHelper.AssertLogMessageWithLevelIsGenerated(validate, Tuple.Create(expectedMessage, LogLevelConstant.Error));
- Assert.IsFalse(valid);
- }
-
- [Test]
- public void ValidateWaveReduction_ForeshoreProfileWithGeometryForeshoreProfileUsed_ReturnsTrue()
- {
- // Setup
- string filePath = Path.Combine(readerPath, "validConfiguration.xml");
- const string calculationName = "calculation";
-
- var calculationGroup = new CalculationGroup();
-
- var importer = new CalculationConfigurationImporter(filePath,
- calculationGroup);
-
- var waveReductionConfiguration = new WaveReductionConfiguration
- {
- UseForeshoreProfile = true
- };
-
- // Call
- bool valid = importer.PublicValidateWaveReduction(
- waveReductionConfiguration,
- new TestForeshoreProfile("voorland", new[]
- {
- new Point2D(0, 2)
- }),
- calculationName);
-
- // Assert
- Assert.IsTrue(valid);
- }
-
- [Test]
- public void ValidateWaveReduction_ForeshoreProfileWithoutGeometryForeshoreProfileUsed_LogsErrorReturnsFalse()
- {
- // Setup
- string filePath = Path.Combine(readerPath, "validConfiguration.xml");
- const string calculationName = "calculation";
-
- var calculationGroup = new CalculationGroup();
-
- var importer = new CalculationConfigurationImporter(filePath,
- calculationGroup);
-
- var waveReductionConfiguration = new WaveReductionConfiguration
- {
- UseForeshoreProfile = true
- };
-
- var valid = true;
- var profileName = "voorland";
-
- // Call
- Action validate = () => valid = importer.PublicValidateWaveReduction(waveReductionConfiguration, new TestForeshoreProfile(profileName), calculationName);
-
- // Assert
- string expectedMessage = $"Het opgegeven voorlandprofiel '{profileName}' heeft geen voorlandgeometrie en kan daarom niet gebruikt worden. Berekening '{calculationName}' is overgeslagen.";
- TestHelper.AssertLogMessageWithLevelIsGenerated(validate, Tuple.Create(expectedMessage, LogLevelConstant.Error));
- Assert.IsFalse(valid);
- }
-
- [Test]
[TestCase(true, true, 1.2, ConfigurationBreakWaterType.Wall, BreakWaterType.Wall)]
[TestCase(false, false, 2.2, ConfigurationBreakWaterType.Caisson, BreakWaterType.Caisson)]
[TestCase(false, true, 11.332, ConfigurationBreakWaterType.Wall, BreakWaterType.Wall)]
@@ -862,44 +704,11 @@
Assert.AreSame(expectedProfile, structure);
}
- [Test]
- public void LogOutOfRangeException_Always_LogMessage()
- {
- // Setup
- string filePath = Path.Combine(readerPath, "validConfiguration.xml");
-
- var calculationGroup = new CalculationGroup();
-
- var importer = new CalculationConfigurationImporter(filePath,
- calculationGroup);
-
- const string message = "an error";
- const string calculationName = "calculationA";
- const string innerMessage = "Inner message";
- var exception = new ArgumentOutOfRangeException(null, innerMessage);
-
- // Call
- Action log = () => importer.PublicLogOutOfRangeException(message, calculationName, exception);
-
- // Assert
- TestHelper.AssertLogMessageWithLevelIsGenerated(log, Tuple.Create($"{message} {innerMessage} Berekening '{calculationName}' is overgeslagen.", LogLevelConstant.Error));
- }
-
private class CalculationConfigurationImporter : CalculationConfigurationImporter
{
public CalculationConfigurationImporter(string filePath, CalculationGroup importTarget)
: base(filePath, importTarget) {}
- public void PublicLogOutOfRangeException(string errorMessage, string calculationName, ArgumentOutOfRangeException e)
- {
- LogOutOfRangeException(errorMessage, calculationName, e);
- }
-
- public bool PublicValidateWaveReduction(WaveReductionConfiguration waveReduction, ForeshoreProfile foreshoreProfile, string calculationName)
- {
- return ValidateWaveReduction(waveReduction, foreshoreProfile, calculationName);
- }
-
public void PublicReadWaveReductionParameters(WaveReductionConfiguration waveReduction, T input)
where T : IUseBreakWater, IUseForeshore
{
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj
===================================================================
diff -u -r512bebcd5570951b18657513c56843d9e2f8e969 -r335523a40d190e19b1061804de21c28f74140f52
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 512bebcd5570951b18657513c56843d9e2f8e969)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -36,6 +36,10 @@
none
+
+ ..\..\..\..\packages\log4net.2.0.4\lib\net40-full\log4net.dll
+ True
+
..\..\..\..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll
True
@@ -59,12 +63,14 @@
-
+
+
+
-
+
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/packages.config
===================================================================
diff -u -r6a5d7b40b7ba4dcb73e393075338352d194e97c2 -r335523a40d190e19b1061804de21c28f74140f52
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/packages.config (.../packages.config) (revision 6a5d7b40b7ba4dcb73e393075338352d194e97c2)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/packages.config (.../packages.config) (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -22,6 +22,7 @@
All rights reserved.
-->
+
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Importers/GrassCoverErosionInwardsCalculationConfigurationImporter.cs
===================================================================
diff -u -r512bebcd5570951b18657513c56843d9e2f8e969 -r335523a40d190e19b1061804de21c28f74140f52
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Importers/GrassCoverErosionInwardsCalculationConfigurationImporter.cs (.../GrassCoverErosionInwardsCalculationConfigurationImporter.cs) (revision 512bebcd5570951b18657513c56843d9e2f8e969)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Importers/GrassCoverErosionInwardsCalculationConfigurationImporter.cs (.../GrassCoverErosionInwardsCalculationConfigurationImporter.cs) (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -113,11 +113,10 @@
if (location == null)
{
- LogReadCalculationConversionError(
- string.Format(
- RingtoetsCommonIOResources.CalculationConfigurationImporter_ReadHydraulicBoundaryLocation_HydraulicBoundaryLocation_0_does_not_exist,
- readCalculation.HydraulicBoundaryLocation),
- calculation.Name);
+ Log.LogCalculationConversionError(string.Format(
+ RingtoetsCommonIOResources.CalculationConfigurationImporter_ReadHydraulicBoundaryLocation_HydraulicBoundaryLocation_0_does_not_exist,
+ readCalculation.HydraulicBoundaryLocation),
+ calculation.Name);
return false;
}
@@ -143,11 +142,10 @@
if (dikeProfile == null)
{
- LogReadCalculationConversionError(
- string.Format(
- Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ReadDikeProfile_DikeProfile_0_does_not_exist,
- readCalculation.DikeProfile),
- calculation.Name);
+ Log.LogCalculationConversionError(string.Format(
+ Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ReadDikeProfile_DikeProfile_0_does_not_exist,
+ readCalculation.DikeProfile),
+ calculation.Name);
return false;
}
@@ -171,9 +169,8 @@
{
if (calculation.InputParameters.DikeProfile == null)
{
- LogReadCalculationConversionError(
- Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_No_DikeProfile_provided_for_Orientation,
- calculation.Name);
+ Log.LogCalculationConversionError(Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_No_DikeProfile_provided_for_Orientation,
+ calculation.Name);
return false;
}
@@ -186,10 +183,9 @@
}
catch (ArgumentOutOfRangeException e)
{
- LogOutOfRangeException(
- string.Format(Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ReadOrientation_Orientation_0_invalid, orientation),
- calculation.Name,
- e);
+ Log.LogOutOfRangeException(string.Format(Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ReadOrientation_Orientation_0_invalid, orientation),
+ calculation.Name,
+ e);
return false;
}
@@ -246,9 +242,8 @@
{
if (calculation.InputParameters.DikeProfile == null)
{
- LogReadCalculationConversionError(
- Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_No_DikeProfile_provided_for_DikeHeight,
- calculation.Name);
+ Log.LogCalculationConversionError(Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_No_DikeProfile_provided_for_DikeHeight,
+ calculation.Name);
return false;
}
@@ -308,9 +303,8 @@
|| readCalculation.BreakWaterHeight != null
|| readCalculation.BreakWaterType != null)
{
- LogReadCalculationConversionError(
- Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_No_DikeProfile_provided_for_BreakWater_parameters,
- calculation.Name);
+ Log.LogCalculationConversionError(Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_No_DikeProfile_provided_for_BreakWater_parameters,
+ calculation.Name);
return false;
}
@@ -319,11 +313,10 @@
{
if (readCalculation.UseForeshore.HasValue && readCalculation.UseForeshore.Value)
{
- LogReadCalculationConversionError(
- string.Format(
- Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_DikeProfile_0_has_no_geometry_and_cannot_be_used,
- readCalculation.DikeProfile),
- calculation.Name);
+ Log.LogCalculationConversionError(string.Format(
+ Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_DikeProfile_0_has_no_geometry_and_cannot_be_used,
+ readCalculation.DikeProfile),
+ calculation.Name);
return false;
}
}
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Ringtoets.GrassCoverErosionInwards.IO.csproj
===================================================================
diff -u -r56daaecf144ac21035cad0977ae4c2c8294449c0 -r335523a40d190e19b1061804de21c28f74140f52
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Ringtoets.GrassCoverErosionInwards.IO.csproj (.../Ringtoets.GrassCoverErosionInwards.IO.csproj) (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Ringtoets.GrassCoverErosionInwards.IO.csproj (.../Ringtoets.GrassCoverErosionInwards.IO.csproj) (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -32,6 +32,10 @@
AllRules.ruleset
+
+ ..\..\..\..\packages\log4net.2.0.4\lib\net40-full\log4net.dll
+ True
+
@@ -60,6 +64,7 @@
Copying.licenseheader
+
Designer
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/packages.config
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/packages.config (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/packages.config (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -0,0 +1,26 @@
+
+
+
+
+
\ No newline at end of file
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Configurations/HeightStructuresCalculationConfigurationImporter.cs
===================================================================
diff -u -r9a0e768e9ddbc5e4917201fdb864bb2247e5cd90 -r335523a40d190e19b1061804de21c28f74140f52
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Configurations/HeightStructuresCalculationConfigurationImporter.cs (.../HeightStructuresCalculationConfigurationImporter.cs) (revision 9a0e768e9ddbc5e4917201fdb864bb2247e5cd90)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Configurations/HeightStructuresCalculationConfigurationImporter.cs (.../HeightStructuresCalculationConfigurationImporter.cs) (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -22,6 +22,7 @@
using System;
using System.Collections.Generic;
using Core.Common.Base.Data;
+using log4net;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.Hydraulics;
@@ -30,6 +31,7 @@
using Ringtoets.Common.IO.Configurations;
using Ringtoets.Common.IO.Configurations.Helpers;
using Ringtoets.Common.IO.FileImporters;
+using Ringtoets.Common.IO.Properties;
using Ringtoets.Common.IO.Schema;
using Ringtoets.HeightStructures.Data;
using RingtoetsCommonIOResources = Ringtoets.Common.IO.Properties.Resources;
@@ -102,7 +104,7 @@
&& TryReadStochasts(readCalculation, calculation)
&& TryReadOrientation(readCalculation, calculation)
&& TryReadFailureProbabilityStructureWithErosion(readCalculation, calculation)
- && ValidateWaveReduction(readCalculation.WaveReduction, calculation.InputParameters.ForeshoreProfile, calculation.Name))
+ && readCalculation.WaveReduction.ValidateWaveReduction(calculation.InputParameters.ForeshoreProfile, calculation.Name, Log))
{
ReadWaveReductionParameters(readCalculation.WaveReduction, calculation.InputParameters);
return calculation;
@@ -112,145 +114,64 @@
private bool TryReadStochasts(HeightStructuresCalculationConfiguration readCalculation, StructuresCalculation calculation)
{
- if (!ValidateStochasts(readCalculation))
+ if (!readCalculation.ValidateStochasts(Log))
{
return false;
}
return TryReadStandardDeviationStochast(
- calculation,
+ calculation.Name,
HeightStructuresConfigurationSchemaIdentifiers.LevelCrestStructureStochastName,
+ calculation.InputParameters,
readCalculation.LevelCrestStructure,
i => i.LevelCrestStructure,
(i, d) => i.LevelCrestStructure = d)
&& TryReadStandardDeviationStochast(
- calculation,
+ calculation.Name,
ConfigurationSchemaIdentifiers.AllowedLevelIncreaseStorageStochastName,
- readCalculation.AllowedLevelIncreaseStorage,
+ calculation.InputParameters, readCalculation.AllowedLevelIncreaseStorage,
i => i.AllowedLevelIncreaseStorage,
(i, d) => i.AllowedLevelIncreaseStorage = d)
&& TryReadStandardDeviationStochast(
- calculation,
+ calculation.Name,
ConfigurationSchemaIdentifiers.FlowWidthAtBottomProtectionStochastName,
- readCalculation.FlowWidthAtBottomProtection,
+ calculation.InputParameters, readCalculation.FlowWidthAtBottomProtection,
i => i.FlowWidthAtBottomProtection,
(i, d) => i.FlowWidthAtBottomProtection = d)
&& TryReadStandardDeviationStochast(
- calculation,
+ calculation.Name,
ConfigurationSchemaIdentifiers.ModelFactorSuperCriticalFlowStochastName,
- readCalculation.ModelFactorSuperCriticalFlow,
+ calculation.InputParameters, readCalculation.ModelFactorSuperCriticalFlow,
i => i.ModelFactorSuperCriticalFlow,
(i, d) => i.ModelFactorSuperCriticalFlow = d)
&& TryReadStandardDeviationStochast(
- calculation,
+ calculation.Name,
ConfigurationSchemaIdentifiers.WidthFlowAperturesStochastName,
- readCalculation.WidthFlowApertures,
- i => i.WidthFlowApertures,
- (i, d) => i.WidthFlowApertures = d)
+ calculation.InputParameters, readCalculation.WidthFlowApertures,
+ i => i.WidthFlowApertures, (i, d) => i.WidthFlowApertures = d)
&& TryReadVariationCoefficientStochast(
- calculation,
+ calculation.Name,
ConfigurationSchemaIdentifiers.CriticalOvertoppingDischargeStochastName,
- readCalculation.CriticalOvertoppingDischarge,
+ calculation.InputParameters, readCalculation.CriticalOvertoppingDischarge,
i => i.CriticalOvertoppingDischarge,
(i, d) => i.CriticalOvertoppingDischarge = d)
&& TryReadVariationCoefficientStochast(
- calculation,
+ calculation.Name,
ConfigurationSchemaIdentifiers.StorageStructureAreaStochastName,
+ calculation.InputParameters,
readCalculation.StorageStructureArea,
i => i.StorageStructureArea,
(i, d) => i.StorageStructureArea = d)
&& TryReadVariationCoefficientStochast(
- calculation,
+ calculation.Name,
ConfigurationSchemaIdentifiers.StormDurationStochastName,
+ calculation.InputParameters,
readCalculation.StormDuration,
i => i.StormDuration,
(i, d) => i.StormDuration = d);
}
- private bool ValidateStochasts(HeightStructuresCalculationConfiguration readCalculation)
- {
- if (readCalculation.StormDuration?.VariationCoefficient != null)
- {
- LogReadCalculationConversionError("Er kan geen variatiecoëfficiënt voor stochast 'stormduur' opgegeven worden.", readCalculation.Name);
- return false;
- }
- if (readCalculation.ModelFactorSuperCriticalFlow?.StandardDeviation != null)
- {
- LogReadCalculationConversionError("Er kan geen standaardafwijking voor stochast 'modelfactoroverloopdebiet' opgegeven worden.", readCalculation.Name);
- return false;
- }
- return true;
- }
-
///
- /// Reads the stochast parameters.
- ///
- /// The calculation to configure.
- /// The stochast's name.
- /// The configuration of the stochast.
- /// The function for obtaining the stochast to read.
- /// The function to set the stochast with the read parameters.
- /// true if reading all required stochast parameters was successful,
- /// false otherwise.
- private bool TryReadStandardDeviationStochast(
- StructuresCalculation calculation,
- string stochastName,
- MeanStandardDeviationStochastConfiguration stochastConfiguration,
- Func getStochast,
- Action setStochast)
- where T : IDistribution
- {
- if (stochastConfiguration == null)
- {
- return true;
- }
- var distribution = (T) getStochast(calculation.InputParameters).Clone();
-
- if (!distribution.TrySetDistributionProperties(stochastConfiguration,
- stochastName,
- calculation.Name))
- {
- return false;
- }
- setStochast(calculation.InputParameters, distribution);
- return true;
- }
-
- ///
- /// Reads the stochast parameters.
- ///
- /// The calculation to configure.
- /// The stochast's name.
- /// The configuration of the stochast.
- /// The function for obtaining the stochast to read.
- /// The function to set the stochast with the read parameters.
- /// true if reading all required stochast parameters was successful,
- /// false otherwise.
- private bool TryReadVariationCoefficientStochast(
- StructuresCalculation calculation,
- string stochastName,
- MeanVariationCoefficientStochastConfiguration stochastConfiguration,
- Func getStochast,
- Action setStochast)
- where T : IVariationCoefficientDistribution
- {
- if (stochastConfiguration == null)
- {
- return true;
- }
- var distribution = (T) getStochast(calculation.InputParameters).Clone();
-
- if (!distribution.TrySetDistributionProperties(stochastConfiguration,
- stochastName,
- calculation.Name))
- {
- return false;
- }
- setStochast(calculation.InputParameters, distribution);
- return true;
- }
-
- ///
/// Reads the orientation.
///
/// The calculation read from the imported file.
@@ -263,10 +184,9 @@
{
if (calculation.InputParameters.Structure == null)
{
- LogReadCalculationConversionError(
- string.Format(RingtoetsCommonIOResources.CalculationConfigurationImporter_TryParameter_No_Structure_to_assign_Parameter_0_,
- RingtoetsCommonIOResources.CalculationConfigurationImporter_Orientation_DisplayName),
- calculation.Name);
+ Log.LogCalculationConversionError(string.Format(RingtoetsCommonIOResources.CalculationConfigurationImporter_TryParameter_No_Structure_to_assign_Parameter_0_,
+ RingtoetsCommonIOResources.CalculationConfigurationImporter_Orientation_DisplayName),
+ calculation.Name);
return false;
}
@@ -279,12 +199,11 @@
}
catch (ArgumentOutOfRangeException e)
{
- LogOutOfRangeException(
- string.Format(RingtoetsCommonIOResources.TryReadParameter_Value_0_ParameterName_1_is_invalid,
- orientation,
- RingtoetsCommonIOResources.CalculationConfigurationImporter_Orientation_DisplayName),
- calculation.Name,
- e);
+ Log.LogOutOfRangeException(string.Format(RingtoetsCommonIOResources.TryReadParameter_Value_0_ParameterName_1_is_invalid,
+ orientation,
+ RingtoetsCommonIOResources.CalculationConfigurationImporter_Orientation_DisplayName),
+ calculation.Name,
+ e);
return false;
}
@@ -306,10 +225,9 @@
{
if (calculation.InputParameters.Structure == null)
{
- LogReadCalculationConversionError(
- string.Format(RingtoetsCommonIOResources.CalculationConfigurationImporter_TryParameter_No_Structure_to_assign_Parameter_0_,
- RingtoetsCommonIOResources.CalculationConfigurationImporter_FailureProbabilityStructureWithErosion_DisplayName),
- calculation.Name);
+ Log.LogCalculationConversionError(string.Format(RingtoetsCommonIOResources.CalculationConfigurationImporter_TryParameter_No_Structure_to_assign_Parameter_0_,
+ RingtoetsCommonIOResources.CalculationConfigurationImporter_FailureProbabilityStructureWithErosion_DisplayName),
+ calculation.Name);
return false;
}
@@ -322,13 +240,12 @@
}
catch (ArgumentOutOfRangeException e)
{
- LogOutOfRangeException(
- string.Format(
- RingtoetsCommonIOResources.TryReadParameter_Value_0_ParameterName_1_is_invalid,
- failureProbability,
- RingtoetsCommonIOResources.CalculationConfigurationImporter_FailureProbabilityStructureWithErosion_DisplayName),
- calculation.Name,
- e);
+ Log.LogOutOfRangeException(string.Format(
+ RingtoetsCommonIOResources.TryReadParameter_Value_0_ParameterName_1_is_invalid,
+ failureProbability,
+ RingtoetsCommonIOResources.CalculationConfigurationImporter_FailureProbabilityStructureWithErosion_DisplayName),
+ calculation.Name,
+ e);
return false;
}
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingCalculationConfigurationImporter.cs
===================================================================
diff -u -r512bebcd5570951b18657513c56843d9e2f8e969 -r335523a40d190e19b1061804de21c28f74140f52
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingCalculationConfigurationImporter.cs (.../PipingCalculationConfigurationImporter.cs) (revision 512bebcd5570951b18657513c56843d9e2f8e969)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingCalculationConfigurationImporter.cs (.../PipingCalculationConfigurationImporter.cs) (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -115,11 +115,10 @@
if (location == null)
{
- LogReadCalculationConversionError(
- string.Format(
- RingtoetsCommonIOResources.CalculationConfigurationImporter_ReadHydraulicBoundaryLocation_HydraulicBoundaryLocation_0_does_not_exist,
- readCalculation.HydraulicBoundaryLocation),
- pipingCalculation.Name);
+ Log.LogCalculationConversionError(string.Format(
+ RingtoetsCommonIOResources.CalculationConfigurationImporter_ReadHydraulicBoundaryLocation_HydraulicBoundaryLocation_0_does_not_exist,
+ readCalculation.HydraulicBoundaryLocation),
+ pipingCalculation.Name);
return false;
}
@@ -150,10 +149,10 @@
if (surfaceLine == null)
{
- LogReadCalculationConversionError(string.Format(
- Resources.PipingCalculationConfigurationImporter_ReadSurfaceLine_SurfaceLine_0_does_not_exist,
- readCalculation.SurfaceLine),
- pipingCalculation.Name);
+ Log.LogCalculationConversionError(string.Format(
+ Resources.PipingCalculationConfigurationImporter_ReadSurfaceLine_SurfaceLine_0_does_not_exist,
+ readCalculation.SurfaceLine),
+ pipingCalculation.Name);
return false;
}
@@ -176,8 +175,8 @@
if (readCalculation.SurfaceLine == null && (hasEntryPoint || hasExitPoint))
{
- LogReadCalculationConversionError(Resources.PipingCalculationConfigurationImporter_ReadSurfaceLine_EntryPointL_or_ExitPointL_defined_without_SurfaceLine,
- pipingCalculation.Name);
+ Log.LogCalculationConversionError(Resources.PipingCalculationConfigurationImporter_ReadSurfaceLine_EntryPointL_or_ExitPointL_defined_without_SurfaceLine,
+ pipingCalculation.Name);
return false;
}
@@ -191,8 +190,9 @@
}
catch (ArgumentOutOfRangeException e)
{
- LogOutOfRangeException(string.Format(Resources.PipingCalculationConfigurationImporter_ReadEntryExitPoint_Entry_point_invalid, entryPoint),
- pipingCalculation.Name, e);
+ Log.LogOutOfRangeException(string.Format(Resources.PipingCalculationConfigurationImporter_ReadEntryExitPoint_Entry_point_invalid, entryPoint),
+ pipingCalculation.Name,
+ e);
return false;
}
}
@@ -207,8 +207,9 @@
}
catch (ArgumentOutOfRangeException e)
{
- LogOutOfRangeException(string.Format(Resources.PipingCalculationConfigurationImporter_ReadEntryExitPoint_Exit_point_invalid, exitPoint),
- pipingCalculation.Name, e);
+ Log.LogOutOfRangeException(string.Format(Resources.PipingCalculationConfigurationImporter_ReadEntryExitPoint_Exit_point_invalid, exitPoint),
+ pipingCalculation.Name,
+ e);
return false;
}
}
@@ -238,21 +239,21 @@
if (soilModel == null)
{
- LogReadCalculationConversionError(string.Format(
- Resources.PipingCalculationConfigurationImporter_ReadStochasticSoilModel_Stochastische_soil_model_0_does_not_exist,
- readCalculation.StochasticSoilModel),
- pipingCalculation.Name);
+ Log.LogCalculationConversionError(string.Format(
+ Resources.PipingCalculationConfigurationImporter_ReadStochasticSoilModel_Stochastische_soil_model_0_does_not_exist,
+ readCalculation.StochasticSoilModel),
+ pipingCalculation.Name);
return false;
}
if (pipingCalculation.InputParameters.SurfaceLine != null
&& !soilModel.IntersectsWithSurfaceLineGeometry(pipingCalculation.InputParameters.SurfaceLine))
{
- LogReadCalculationConversionError(string.Format(
- Resources.PipingCalculationConfigurationImporter_ReadStochasticSoilModel_Stochastische_soil_model_0_does_not_intersect_with_surfaceLine_1,
- readCalculation.StochasticSoilModel,
- readCalculation.SurfaceLine),
- pipingCalculation.Name);
+ Log.LogCalculationConversionError(string.Format(
+ Resources.PipingCalculationConfigurationImporter_ReadStochasticSoilModel_Stochastische_soil_model_0_does_not_intersect_with_surfaceLine_1,
+ readCalculation.StochasticSoilModel,
+ readCalculation.SurfaceLine),
+ pipingCalculation.Name);
return false;
}
@@ -278,10 +279,10 @@
{
if (pipingCalculation.InputParameters.StochasticSoilModel == null)
{
- LogReadCalculationConversionError(string.Format(
- Resources.PipingCalculationConfigurationImporter_ReadStochasticSoilProfile_No_soil_model_provided_for_soil_profile_with_name_0,
- readCalculation.StochasticSoilProfile),
- pipingCalculation.Name);
+ Log.LogCalculationConversionError(string.Format(
+ Resources.PipingCalculationConfigurationImporter_ReadStochasticSoilProfile_No_soil_model_provided_for_soil_profile_with_name_0,
+ readCalculation.StochasticSoilProfile),
+ pipingCalculation.Name);
return false;
}
@@ -290,10 +291,10 @@
if (soilProfile == null)
{
- LogReadCalculationConversionError(string.Format(
- Resources.PipingCalculationConfigurationImporter_ReadStochasticSoilProfile_Stochastic_soil_profile_0_does_not_exist_within_soil_model_1,
- readCalculation.StochasticSoilProfile, readCalculation.StochasticSoilModel),
- pipingCalculation.Name);
+ Log.LogCalculationConversionError(string.Format(
+ Resources.PipingCalculationConfigurationImporter_ReadStochasticSoilProfile_Stochastic_soil_profile_0_does_not_exist_within_soil_model_1,
+ readCalculation.StochasticSoilProfile, readCalculation.StochasticSoilModel),
+ pipingCalculation.Name);
return false;
}
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Importers/WaveConditionsCalculationConfigurationImporter.cs
===================================================================
diff -u -r512bebcd5570951b18657513c56843d9e2f8e969 -r335523a40d190e19b1061804de21c28f74140f52
--- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Importers/WaveConditionsCalculationConfigurationImporter.cs (.../WaveConditionsCalculationConfigurationImporter.cs) (revision 512bebcd5570951b18657513c56843d9e2f8e969)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Importers/WaveConditionsCalculationConfigurationImporter.cs (.../WaveConditionsCalculationConfigurationImporter.cs) (revision 335523a40d190e19b1061804de21c28f74140f52)
@@ -26,6 +26,7 @@
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.IO.Configurations.Helpers;
using Ringtoets.Common.IO.FileImporters;
using Ringtoets.Revetment.Data;
using Ringtoets.Revetment.IO.Properties;
@@ -117,10 +118,10 @@
if (location == null)
{
- LogReadCalculationConversionError(string.Format(
- RingtoetsCommonIOResources.CalculationConfigurationImporter_ReadHydraulicBoundaryLocation_HydraulicBoundaryLocation_0_does_not_exist,
- readCalculation.HydraulicBoundaryLocation),
- calculation.Name);
+ Log.LogCalculationConversionError(string.Format(
+ RingtoetsCommonIOResources.CalculationConfigurationImporter_ReadHydraulicBoundaryLocation_HydraulicBoundaryLocation_0_does_not_exist,
+ readCalculation.HydraulicBoundaryLocation),
+ calculation.Name);
return false;
}
@@ -162,14 +163,14 @@
{
try
{
- setAsRoundedDouble((RoundedDouble)readValue.Value);
+ setAsRoundedDouble((RoundedDouble) readValue.Value);
}
catch (ArgumentOutOfRangeException e)
{
- LogOutOfRangeException(string.Format(
- RingtoetsCommonIOResources.TryReadParameter_Value_0_ParameterName_1_is_invalid,
- readValue.Value, parameterName),
- calculationName, e);
+ Log.LogOutOfRangeException(string.Format(
+ RingtoetsCommonIOResources.TryReadParameter_Value_0_ParameterName_1_is_invalid,
+ readValue.Value, parameterName),
+ calculationName, e);
return false;
}
}
@@ -200,10 +201,10 @@
if (foreshoreProfile == null)
{
- LogReadCalculationConversionError(string.Format(
- RingtoetsCommonIOResources.CalculationConfigurationImporter_ReadForeshoreProfile_ForeshoreProfile_0_does_not_exist,
- readCalculation.ForeshoreProfile),
- calculation.Name);
+ Log.LogCalculationConversionError(string.Format(
+ RingtoetsCommonIOResources.CalculationConfigurationImporter_ReadForeshoreProfile_ForeshoreProfile_0_does_not_exist,
+ readCalculation.ForeshoreProfile),
+ calculation.Name);
return false;
}
@@ -230,11 +231,11 @@
}
catch (ArgumentOutOfRangeException e)
{
- LogOutOfRangeException(string.Format(
- RingtoetsCommonIOResources.TryReadParameter_Value_0_ParameterName_1_is_invalid,
- orientation,
- RingtoetsCommonIOResources.CalculationConfigurationImporter_Orientation_DisplayName),
- calculation.Name, e);
+ Log.LogOutOfRangeException(string.Format(
+ RingtoetsCommonIOResources.TryReadParameter_Value_0_ParameterName_1_is_invalid,
+ orientation,
+ RingtoetsCommonIOResources.CalculationConfigurationImporter_Orientation_DisplayName),
+ calculation.Name, e);
return false;
}
}
@@ -293,20 +294,19 @@
|| readCalculation.BreakWaterHeight != null
|| readCalculation.BreakWaterType != null)
{
- LogReadCalculationConversionError(
- RingtoetsCommonIOResources.CalculationConfigurationImporter_ValidateWaveReduction_No_foreshore_profile_provided,
- calculation.Name);
+ Log.LogCalculationConversionError(RingtoetsCommonIOResources.CalculationConfigurationImporter_ValidateWaveReduction_No_foreshore_profile_provided,
+ calculation.Name);
return false;
}
}
else if (!calculation.InputParameters.ForeshoreGeometry.Any())
{
if (readCalculation.UseForeshore.HasValue && readCalculation.UseForeshore.Value)
{
- LogReadCalculationConversionError(string.Format(
- RingtoetsCommonIOResources.ReadForeshoreProfile_ForeshoreProfile_0_has_no_geometry_and_cannot_be_used,
- readCalculation.ForeshoreProfile),
- calculation.Name);
+ Log.LogCalculationConversionError(string.Format(
+ RingtoetsCommonIOResources.ReadForeshoreProfile_ForeshoreProfile_0_has_no_geometry_and_cannot_be_used,
+ readCalculation.ForeshoreProfile),
+ calculation.Name);
return false;
}
}