Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs =================================================================== diff -u -rf4f041e353f89e0e93a4243968acee599b2186a7 -rffe6f47c5c38e57f5c0c0d9c699c88ac6c818e7c --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs (.../HeightStructuresCalculationService.cs) (revision f4f041e353f89e0e93a4243968acee599b2186a7) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs (.../HeightStructuresCalculationService.cs) (revision ffe6f47c5c38e57f5c0c0d9c699c88ac6c818e7c) @@ -19,9 +19,11 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Core.Common.IO.Exceptions; using log4net; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; @@ -38,7 +40,6 @@ using Ringtoets.HydraRing.Calculation.Data.Input.Structures; using Ringtoets.HydraRing.Calculation.Exceptions; using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources; -using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.HeightStructures.Service @@ -60,8 +61,17 @@ /// The for which to validate the values. /// The for which to validate the values. /// True if has no validation errors; False otherwise. + /// Thrown when any parameter is null. public static bool Validate(StructuresCalculation calculation, IAssessmentSection assessmentSection) { + if (calculation == null) + { + throw new ArgumentNullException(nameof(calculation)); + } + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } CalculationServiceHelper.LogValidationBeginTime(calculation.Name); string[] messages = ValidateInput(calculation.InputParameters, assessmentSection); @@ -77,10 +87,7 @@ /// public void Cancel() { - if (calculator != null) - { - calculator.Cancel(); - } + calculator?.Cancel(); canceled = true; } @@ -93,13 +100,38 @@ /// The that holds the information about the contribution /// and the general inputs used in the calculation. /// The path which points to the hydraulic boundary database file. + /// Thrown when , + /// or is null. + /// Thrown when the + /// contains invalid characters. + /// Thrown when: + /// + /// No settings database file could be found at the location of + /// with the same name. + /// Unable to open settings database file. + /// Unable to read required data from database file. + /// + /// /// Thrown when an error occurs during parsing of the Hydra-Ring output. /// Thrown when an error occurs during the calculation. internal void Calculate(StructuresCalculation calculation, IAssessmentSection assessmentSection, HeightStructuresFailureMechanism failureMechanism, string hydraulicBoundaryDatabaseFilePath) { + if (calculation == null) + { + throw new ArgumentNullException(nameof(calculation)); + } + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + var calculationName = calculation.Name; FailureMechanismSection failureMechanismSection = StructuresHelper.FailureMechanismSectionForCalculation(failureMechanism.Sections, @@ -166,6 +198,24 @@ } } + /// + /// Creates the input for a structures overtopping calculation. + /// + /// The calculation to create the input for. + /// The failure mechanism section to use in the calculation. + /// The general input to use in the calculation. + /// The path to the hydraulic boundary database file. + /// A . + /// Thrown when the + /// contains invalid characters. + /// Thrown when: + /// + /// No settings database file could be found at the location of + /// with the same name. + /// Unable to open settings database file. + /// Unable to read required data from database file. + /// + /// private static StructuresOvertoppingCalculationInput CreateInput( StructuresCalculation calculation, FailureMechanismSection failureMechanismSection,