Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/ClosingStructuresCalculationService.cs
===================================================================
diff -u -rf8c28b3b04cdabb62ea37772efcb1f4ebbbf2b9e -ra2353e44937113273f8f48a0823965e79ea537cb
--- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/ClosingStructuresCalculationService.cs (.../ClosingStructuresCalculationService.cs) (revision f8c28b3b04cdabb62ea37772efcb1f4ebbbf2b9e)
+++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/ClosingStructuresCalculationService.cs (.../ClosingStructuresCalculationService.cs) (revision a2353e44937113273f8f48a0823965e79ea537cb)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.ComponentModel;
using Ringtoets.ClosingStructures.Data;
using Ringtoets.Common.Service;
@@ -44,8 +45,16 @@
bool usePreprocessor)
{
StructuresClosureCalculationInput input;
- switch (structureInput.InflowModelType)
+ ClosingStructureInflowModelType closingStructureInflowModelType = structureInput.InflowModelType;
+ if (!Enum.IsDefined(typeof(ClosingStructureInflowModelType), closingStructureInflowModelType))
{
+ throw new InvalidEnumArgumentException(nameof(structureInput),
+ (int) closingStructureInflowModelType,
+ typeof(ClosingStructureInflowModelType));
+ }
+
+ switch (closingStructureInflowModelType)
+ {
case ClosingStructureInflowModelType.VerticalWall:
input = CreateClosureVerticalWallCalculationInput(structureInput, generalInput);
break;
@@ -56,9 +65,7 @@
input = CreateFloodedCulvertCalculationInput(structureInput, generalInput);
break;
default:
- throw new InvalidEnumArgumentException(nameof(structureInput),
- (int) structureInput.InflowModelType,
- typeof(ClosingStructureInflowModelType));
+ throw new NotSupportedException($"The enum value {nameof(ClosingStructureInflowModelType)}.{closingStructureInflowModelType} is not supported.");
}
HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(input, hydraulicBoundaryDatabaseFilePath, usePreprocessor);
Index: Ringtoets/Common/src/Ringtoets.Common.Service/Structures/StructuresCalculationServiceBase.cs
===================================================================
diff -u -r35525b6135cc111e4af3803f7dcce0d7528bbb16 -ra2353e44937113273f8f48a0823965e79ea537cb
--- Ringtoets/Common/src/Ringtoets.Common.Service/Structures/StructuresCalculationServiceBase.cs (.../StructuresCalculationServiceBase.cs) (revision 35525b6135cc111e4af3803f7dcce0d7528bbb16)
+++ Ringtoets/Common/src/Ringtoets.Common.Service/Structures/StructuresCalculationServiceBase.cs (.../StructuresCalculationServiceBase.cs) (revision a2353e44937113273f8f48a0823965e79ea537cb)
@@ -95,8 +95,8 @@
/// The for which to validate the values.
/// true if has no validation errors; false otherwise.
/// Thrown when any parameter is null.
- /// Thrown when an unexpected
- /// enum value is encountered.
+ /// Thrown when an invalid enum value is encountered.
+ /// Thrown when an unsupported enum value is encountered.
public static bool Validate(StructuresCalculation calculation, IAssessmentSection assessmentSection)
{
if (calculation == null)
Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/StabilityPointStructuresCalculationService.cs
===================================================================
diff -u -r997a7c7aec4c8fc0466687fe09b09463c4628a6b -ra2353e44937113273f8f48a0823965e79ea537cb
--- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/StabilityPointStructuresCalculationService.cs (.../StabilityPointStructuresCalculationService.cs) (revision 997a7c7aec4c8fc0466687fe09b09463c4628a6b)
+++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/StabilityPointStructuresCalculationService.cs (.../StabilityPointStructuresCalculationService.cs) (revision a2353e44937113273f8f48a0823965e79ea537cb)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.ComponentModel;
using Ringtoets.Common.Service;
using Ringtoets.Common.Service.Structures;
@@ -48,56 +49,104 @@
bool usePreprocessor)
{
StructuresStabilityPointCalculationInput input;
- switch (structureInput.InflowModelType)
+ StabilityPointStructureInflowModelType inflowModelType = structureInput.InflowModelType;
+ if (!Enum.IsDefined(typeof(StabilityPointStructureInflowModelType), inflowModelType))
{
+ throw new InvalidEnumArgumentException(nameof(structureInput),
+ (int)inflowModelType,
+ typeof(StabilityPointStructureInflowModelType));
+ }
+
+ switch (inflowModelType)
+ {
case StabilityPointStructureInflowModelType.LowSill:
- switch (structureInput.LoadSchematizationType)
- {
- case LoadSchematizationType.Linear:
- input = CreateLowSillLinearCalculationInput(
- structureInput,
- generalInput);
- break;
- case LoadSchematizationType.Quadratic:
- input = CreateLowSillQuadraticCalculationInput(
- structureInput,
- generalInput);
- break;
- default:
- throw new InvalidEnumArgumentException(nameof(structureInput),
- (int) structureInput.LoadSchematizationType,
- typeof(LoadSchematizationType));
- }
+ input = CreateLowSillInput(structureInput, generalInput);
break;
case StabilityPointStructureInflowModelType.FloodedCulvert:
- switch (structureInput.LoadSchematizationType)
- {
- case LoadSchematizationType.Linear:
- input = CreateFloodedCulvertLinearCalculationInput(
- structureInput,
- generalInput);
- break;
- case LoadSchematizationType.Quadratic:
- input = CreateFloodedCulvertQuadraticCalculationInput(
- structureInput,
- generalInput);
- break;
- default:
- throw new InvalidEnumArgumentException(nameof(structureInput),
- (int) structureInput.LoadSchematizationType,
- typeof(LoadSchematizationType));
- }
+ input = CreateFloodedCulvertInput(structureInput, generalInput);
break;
default:
- throw new InvalidEnumArgumentException(nameof(structureInput),
- (int) structureInput.InflowModelType,
- typeof(StabilityPointStructureInflowModelType));
+ throw new NotSupportedException($"The enum value {nameof(StabilityPointStructureInflowModelType)}.{inflowModelType} is not supported.");
}
HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(input, hydraulicBoundaryDatabaseFilePath, usePreprocessor);
return input;
}
+ ///
+ /// Creates calculation input based on the and
+ /// for flooded culvert calculations.
+ ///
+ /// The to base the calculation on.
+ /// The to base the calculation on.
+ /// A configured .
+ /// Thrown when contains
+ /// an invalid value of .
+ /// Thrown when contains
+ /// an unsupported value of
+ private static StructuresStabilityPointCalculationInput CreateFloodedCulvertInput(StabilityPointStructuresInput structureInput,
+ GeneralStabilityPointStructuresInput generalInput)
+ {
+ LoadSchematizationType loadSchematizationType = structureInput.LoadSchematizationType;
+ if (!Enum.IsDefined(typeof(LoadSchematizationType), loadSchematizationType))
+ {
+ throw new InvalidEnumArgumentException(nameof(structureInput),
+ (int)loadSchematizationType,
+ typeof(LoadSchematizationType));
+ }
+
+ switch (structureInput.LoadSchematizationType)
+ {
+ case LoadSchematizationType.Linear:
+ return CreateFloodedCulvertLinearCalculationInput(
+ structureInput,
+ generalInput);
+ case LoadSchematizationType.Quadratic:
+ return CreateFloodedCulvertQuadraticCalculationInput(
+ structureInput,
+ generalInput);
+ default:
+ throw new NotSupportedException($"The enum value {nameof(LoadSchematizationType)}.{loadSchematizationType} is not supported.");
+ }
+ }
+
+ ///
+ /// Creates calculation input based on the and
+ /// for low sill calculations.
+ ///
+ /// The to base the calculation on.
+ /// The to base the calculation on.
+ /// A configured .
+ /// Thrown when contains
+ /// an invalid value of .
+ /// Thrown when contains
+ /// an unsupported value of
+ private static StructuresStabilityPointCalculationInput CreateLowSillInput(StabilityPointStructuresInput structureInput,
+ GeneralStabilityPointStructuresInput generalInput)
+ {
+ LoadSchematizationType loadSchematizationType = structureInput.LoadSchematizationType;
+ if (!Enum.IsDefined(typeof(LoadSchematizationType), loadSchematizationType))
+ {
+ throw new InvalidEnumArgumentException(nameof(structureInput),
+ (int) loadSchematizationType,
+ typeof(LoadSchematizationType));
+ }
+
+ switch (loadSchematizationType)
+ {
+ case LoadSchematizationType.Linear:
+ return CreateLowSillLinearCalculationInput(
+ structureInput,
+ generalInput);
+ case LoadSchematizationType.Quadratic:
+ return CreateLowSillQuadraticCalculationInput(
+ structureInput,
+ generalInput);
+ default:
+ throw new NotSupportedException($"The enum value {nameof(LoadSchematizationType)}.{loadSchematizationType} is not supported.");
+ }
+ }
+
private static StructuresStabilityPointLowSillLinearCalculationInput CreateLowSillLinearCalculationInput(
StabilityPointStructuresInput structureInput,
GeneralStabilityPointStructuresInput generalInput)