Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfiguration.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfiguration.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfiguration.cs (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -0,0 +1,185 @@
+// Copyright (C) Stichting Deltares 2017. 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 Ringtoets.Common.IO.Configurations;
+
+namespace Ringtoets.Piping.IO.Configurations
+{
+ ///
+ /// Configuration of a piping calculation.
+ ///
+ public class PipingCalculationConfiguration : IConfigurationItem
+ {
+ private string name;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The name of the .
+ /// Thrown when is null.
+ public PipingCalculationConfiguration(string name)
+ {
+ Name = name;
+ }
+
+ ///
+ /// Gets the assessment level of the piping calculation.
+ ///
+ public double? AssessmentLevel { get; set; }
+
+ ///
+ /// Gets the name of the hydraulic boundary location of the piping calculation.
+ ///
+ public string HydraulicBoundaryLocation { get; set; }
+
+ ///
+ /// Gets the name of the surface line of the piping calculation.
+ ///
+ public string SurfaceLine { get; set; }
+
+ ///
+ /// Gets the l-coordinate of the entry point of the piping calculation.
+ ///
+ public double? EntryPointL { get; set; }
+
+ ///
+ /// Gets the l-coordinate of the exit point of the piping calculation.
+ ///
+ public double? ExitPointL { get; set; }
+
+ ///
+ /// Gets the name of the stochastic soil model of the piping calculation.
+ ///
+ public string StochasticSoilModel { get; set; }
+
+ ///
+ /// Gets the name of the stochastic soil profile of the piping calculation.
+ ///
+ public string StochasticSoilProfile { get; set; }
+
+ ///
+ /// Gets the mean of the phreatic level exit of the piping calculation.
+ ///
+ public double? PhreaticLevelExitMean { get; set; }
+
+ ///
+ /// Gets the standard deviation of the phreatic level exit of the piping calculation.
+ ///
+ public double? PhreaticLevelExitStandardDeviation { get; set; }
+
+ ///
+ /// Gets the mean of the damping factor exit of the piping calculation.
+ ///
+ public double? DampingFactorExitMean { get; set; }
+
+ ///
+ /// Gets the standard deviation of the damping factor exit of the piping calculation.
+ ///
+ public double? DampingFactorExitStandardDeviation { get; set; }
+
+ ///
+ /// Gets or sets the name of the piping calculation.
+ ///
+ /// Thrown when is null.
+ public string Name
+ {
+ get
+ {
+ return name;
+ }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value), @"Name is required for a structure calculation configuration.");
+ }
+ name = value;
+ }
+ }
+
+ ///
+ /// Class holding the various construction parameters for .
+ ///
+ public class ConstructionProperties
+ {
+ ///
+ /// Gets or sets the value for .
+ ///
+ public string Name { internal get; set; }
+
+ ///
+ /// Gets or sets the value for .
+ ///
+ public double? AssessmentLevel { internal get; set; }
+
+ ///
+ /// Gets or sets the value for .
+ ///
+ public string HydraulicBoundaryLocation { internal get; set; }
+
+ ///
+ /// Gets or sets the value for .
+ ///
+ public string SurfaceLine { internal get; set; }
+
+ ///
+ /// Gets or sets the value for .
+ ///
+ public double? EntryPointL { internal get; set; }
+
+ ///
+ /// Gets or sets the value for .
+ ///
+ public double? ExitPointL { internal get; set; }
+
+ ///
+ /// Gets or sets the value for .
+ ///
+ public string StochasticSoilModel { internal get; set; }
+
+ ///
+ /// Gets or sets the value for .
+ ///
+ public string StochasticSoilProfile { internal get; set; }
+
+ ///
+ /// Gets or sets the value for .
+ ///
+ public double? PhreaticLevelExitMean { internal get; set; }
+
+ ///
+ /// Gets or sets the value for .
+ ///
+ public double? PhreaticLevelExitStandardDeviation { internal get; set; }
+
+ ///
+ /// Gets or sets the value for .
+ ///
+ public double? DampingFactorExitMean { internal get; set; }
+
+ ///
+ /// Gets or sets the value for .
+ ///
+ public double? DampingFactorExitStandardDeviation { internal get; set; }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationExporter.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationExporter.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationExporter.cs (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -0,0 +1,44 @@
+// Copyright (C) Stichting Deltares 2017. 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 Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.IO.Configurations.Export;
+using Ringtoets.Piping.Data;
+
+namespace Ringtoets.Piping.IO.Configurations
+{
+ ///
+ /// Exports a piping calculation configuration and stores it as an XML file.
+ ///
+ public class PipingCalculationConfigurationExporter : CalculationConfigurationExporter
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The calculation configuration to export.
+ /// The path of the XML file to export to.
+ /// Thrown when is null.
+ /// Thrown when is invalid.
+ public PipingCalculationConfigurationExporter(IEnumerable configuration, string filePath) : base(configuration, filePath) {}
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationImporter.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationImporter.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationImporter.cs (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -0,0 +1,344 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Base.Data;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.Probabilistics;
+using Ringtoets.Common.IO.Configurations.Helpers;
+using Ringtoets.Common.IO.Configurations.Import;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.IO.Properties;
+using Ringtoets.Piping.Primitives;
+
+namespace Ringtoets.Piping.IO.Configurations
+{
+ ///
+ /// Imports a piping calculation configuration from an XML file and stores it on a
+ /// .
+ ///
+ public class PipingCalculationConfigurationImporter : CalculationConfigurationImporter
+ {
+ private readonly IEnumerable availableHydraulicBoundaryLocations;
+ private readonly PipingFailureMechanism failureMechanism;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The path to the XML file to import from.
+ /// The calculation group to update.
+ /// The hydraulic boundary locations
+ /// used to check if the imported objects contain the right location.
+ /// The piping failure mechanism used to check
+ /// if the imported objects contain the right data.
+ /// Thrown when any parameter is
+ /// null.
+ public PipingCalculationConfigurationImporter(string xmlFilePath,
+ CalculationGroup importTarget,
+ IEnumerable availableHydraulicBoundaryLocations,
+ PipingFailureMechanism failureMechanism)
+ : base(xmlFilePath, importTarget)
+ {
+ if (availableHydraulicBoundaryLocations == null)
+ {
+ throw new ArgumentNullException(nameof(availableHydraulicBoundaryLocations));
+ }
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+ this.availableHydraulicBoundaryLocations = availableHydraulicBoundaryLocations;
+ this.failureMechanism = failureMechanism;
+ }
+
+ protected override PipingCalculationConfigurationReader CreateCalculationConfigurationReader(string xmlFilePath)
+ {
+ return new PipingCalculationConfigurationReader(xmlFilePath);
+ }
+
+ protected override ICalculation ParseReadCalculation(PipingCalculationConfiguration calculationConfiguration)
+ {
+ var pipingCalculation = new PipingCalculationScenario(new GeneralPipingInput())
+ {
+ Name = calculationConfiguration.Name
+ };
+
+ if (TryReadHydraulicBoundaryData(calculationConfiguration, pipingCalculation)
+ && TryReadSurfaceLine(calculationConfiguration, pipingCalculation)
+ && TryReadEntryExitPoint(calculationConfiguration, pipingCalculation)
+ && TryReadStochasticSoilModel(calculationConfiguration, pipingCalculation)
+ && TryReadStochasticSoilProfile(calculationConfiguration, pipingCalculation)
+ && TryReadStochasts(calculationConfiguration, pipingCalculation))
+ {
+ return pipingCalculation;
+ }
+ return null;
+ }
+
+ ///
+ /// Reads the hydraulic boundary location or the assessment level that is manually set.
+ ///
+ /// The calculation read from the imported file.
+ /// The calculation to configure.
+ /// false when the has a
+ /// set which is not available in , true otherwise.
+ private bool TryReadHydraulicBoundaryData(PipingCalculationConfiguration calculationConfiguration, PipingCalculationScenario pipingCalculation)
+ {
+ HydraulicBoundaryLocation location;
+
+ bool locationRead = TryReadHydraulicBoundaryLocation(calculationConfiguration.HydraulicBoundaryLocation, calculationConfiguration.Name, availableHydraulicBoundaryLocations, out location);
+
+ if (!locationRead)
+ {
+ return false;
+ }
+
+ if (location != null)
+ {
+ pipingCalculation.InputParameters.HydraulicBoundaryLocation = location;
+ }
+ else if (calculationConfiguration.AssessmentLevel.HasValue)
+ {
+ pipingCalculation.InputParameters.UseAssessmentLevelManualInput = true;
+ pipingCalculation.InputParameters.AssessmentLevel = (RoundedDouble) calculationConfiguration.AssessmentLevel.Value;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Reads the surface line.
+ ///
+ /// The calculation read from the imported file.
+ /// The calculation to configure.
+ /// false when the has a
+ /// set which is not available in , true otherwise.
+ private bool TryReadSurfaceLine(PipingCalculationConfiguration calculationConfiguration, PipingCalculationScenario pipingCalculation)
+ {
+ if (calculationConfiguration.SurfaceLine != null)
+ {
+ RingtoetsPipingSurfaceLine surfaceLine = failureMechanism.SurfaceLines
+ .FirstOrDefault(sl => sl.Name == calculationConfiguration.SurfaceLine);
+
+ if (surfaceLine == null)
+ {
+ Log.LogCalculationConversionError(string.Format(
+ Resources.PipingCalculationConfigurationImporter_ReadSurfaceLine_SurfaceLine_0_does_not_exist,
+ calculationConfiguration.SurfaceLine),
+ pipingCalculation.Name);
+ return false;
+ }
+
+ pipingCalculation.InputParameters.SurfaceLine = surfaceLine;
+ }
+ return true;
+ }
+
+ ///
+ /// Reads the entry point and exit point.
+ ///
+ /// The calculation read from the imported file.
+ /// The calculation to configure.
+ /// false when entry or exit point is set without ,
+ /// or when entry or exit point is invalid, true otherwise.
+ private bool TryReadEntryExitPoint(PipingCalculationConfiguration calculationConfiguration, PipingCalculationScenario pipingCalculation)
+ {
+ bool hasEntryPoint = calculationConfiguration.EntryPointL.HasValue;
+ bool hasExitPoint = calculationConfiguration.ExitPointL.HasValue;
+
+ if (calculationConfiguration.SurfaceLine == null && (hasEntryPoint || hasExitPoint))
+ {
+ Log.LogCalculationConversionError(Resources.PipingCalculationConfigurationImporter_ReadSurfaceLine_EntryPointL_or_ExitPointL_defined_without_SurfaceLine,
+ pipingCalculation.Name);
+ return false;
+ }
+
+ if (hasEntryPoint)
+ {
+ double entryPoint = calculationConfiguration.EntryPointL.Value;
+
+ try
+ {
+ pipingCalculation.InputParameters.EntryPointL = (RoundedDouble) entryPoint;
+ }
+ catch (ArgumentOutOfRangeException e)
+ {
+ Log.LogOutOfRangeException(string.Format(Resources.PipingCalculationConfigurationImporter_ReadEntryExitPoint_Entry_point_invalid, entryPoint),
+ pipingCalculation.Name,
+ e);
+ return false;
+ }
+ }
+
+ if (hasExitPoint)
+ {
+ double exitPoint = calculationConfiguration.ExitPointL.Value;
+
+ try
+ {
+ pipingCalculation.InputParameters.ExitPointL = (RoundedDouble) exitPoint;
+ }
+ catch (ArgumentOutOfRangeException e)
+ {
+ Log.LogOutOfRangeException(string.Format(Resources.PipingCalculationConfigurationImporter_ReadEntryExitPoint_Exit_point_invalid, exitPoint),
+ pipingCalculation.Name,
+ e);
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ ///
+ /// Reads the stochastic soil model.
+ ///
+ /// The calculation read from the imported file.
+ /// The calculation to configure.
+ /// false when
+ ///
+ /// - the has a set
+ /// which is not available in the failure mechanism.
+ /// - The does not intersect with the
+ /// when this is set.
+ ///
+ /// true otherwise.
+ private bool TryReadStochasticSoilModel(PipingCalculationConfiguration calculationConfiguration, PipingCalculationScenario pipingCalculation)
+ {
+ if (calculationConfiguration.StochasticSoilModel != null)
+ {
+ StochasticSoilModel soilModel = failureMechanism.StochasticSoilModels
+ .FirstOrDefault(ssm => ssm.Name == calculationConfiguration.StochasticSoilModel);
+
+ if (soilModel == null)
+ {
+ Log.LogCalculationConversionError(string.Format(
+ Resources.PipingCalculationConfigurationImporter_ReadStochasticSoilModel_Stochastische_soil_model_0_does_not_exist,
+ calculationConfiguration.StochasticSoilModel),
+ pipingCalculation.Name);
+ return false;
+ }
+
+ if (pipingCalculation.InputParameters.SurfaceLine != null
+ && !soilModel.IntersectsWithSurfaceLineGeometry(pipingCalculation.InputParameters.SurfaceLine))
+ {
+ Log.LogCalculationConversionError(string.Format(
+ Resources.PipingCalculationConfigurationImporter_ReadStochasticSoilModel_Stochastische_soil_model_0_does_not_intersect_with_surfaceLine_1,
+ calculationConfiguration.StochasticSoilModel,
+ calculationConfiguration.SurfaceLine),
+ pipingCalculation.Name);
+ return false;
+ }
+
+ pipingCalculation.InputParameters.StochasticSoilModel = soilModel;
+ }
+ return true;
+ }
+
+ ///
+ /// Reads the stochastic soil profile.
+ ///
+ /// The calculation read from the imported file.
+ /// The calculation to configure.
+ /// false when the has:
+ ///
+ /// - a set but no is specified;
+ /// - a set which is not available in the .
+ ///
+ /// true otherwise.
+ private bool TryReadStochasticSoilProfile(PipingCalculationConfiguration calculationConfiguration, PipingCalculationScenario pipingCalculation)
+ {
+ if (calculationConfiguration.StochasticSoilProfile != null)
+ {
+ if (pipingCalculation.InputParameters.StochasticSoilModel == null)
+ {
+ Log.LogCalculationConversionError(string.Format(
+ Resources.PipingCalculationConfigurationImporter_ReadStochasticSoilProfile_No_soil_model_provided_for_soil_profile_with_name_0,
+ calculationConfiguration.StochasticSoilProfile),
+ pipingCalculation.Name);
+ return false;
+ }
+
+ StochasticSoilProfile soilProfile = pipingCalculation.InputParameters.StochasticSoilModel.StochasticSoilProfiles
+ .FirstOrDefault(ssp => ssp.SoilProfile.Name == calculationConfiguration.StochasticSoilProfile);
+
+ if (soilProfile == null)
+ {
+ Log.LogCalculationConversionError(string.Format(
+ Resources.PipingCalculationConfigurationImporter_ReadStochasticSoilProfile_Stochastic_soil_profile_0_does_not_exist_within_soil_model_1,
+ calculationConfiguration.StochasticSoilProfile, calculationConfiguration.StochasticSoilModel),
+ pipingCalculation.Name);
+ return false;
+ }
+
+ pipingCalculation.InputParameters.StochasticSoilProfile = soilProfile;
+ }
+ return true;
+ }
+
+ ///
+ /// Reads the stochasts.
+ ///
+ /// The calculation read from the imported file.
+ /// The calculation to configure.
+ /// false when a stochast value (mean or standard deviation) is invalid, true otherwise.
+ private bool TryReadStochasts(PipingCalculationConfiguration calculationConfiguration, PipingCalculationScenario pipingCalculation)
+ {
+ return TryReadPhreaticLevelExit(calculationConfiguration, pipingCalculation)
+ && TryReadDampingFactorExit(calculationConfiguration, pipingCalculation);
+ }
+
+ private bool TryReadDampingFactorExit(PipingCalculationConfiguration calculationConfiguration, PipingCalculationScenario pipingCalculation)
+ {
+ var distribution = (LogNormalDistribution) pipingCalculation.InputParameters.DampingFactorExit.Clone();
+
+ if (!distribution.TrySetDistributionProperties(calculationConfiguration.DampingFactorExitMean,
+ calculationConfiguration.DampingFactorExitStandardDeviation,
+ PipingCalculationConfigurationSchemaIdentifiers.DampingFactorExitStochastName,
+ pipingCalculation.Name))
+ {
+ return false;
+ }
+
+ pipingCalculation.InputParameters.DampingFactorExit = distribution;
+ return true;
+ }
+
+ private bool TryReadPhreaticLevelExit(PipingCalculationConfiguration calculationConfiguration, PipingCalculationScenario pipingCalculation)
+ {
+ var distribution = (NormalDistribution) pipingCalculation.InputParameters.PhreaticLevelExit.Clone();
+
+ if (!distribution.TrySetDistributionProperties(calculationConfiguration.PhreaticLevelExitMean,
+ calculationConfiguration.PhreaticLevelExitStandardDeviation,
+ PipingCalculationConfigurationSchemaIdentifiers.PhreaticLevelExitStochastName,
+ pipingCalculation.Name))
+ {
+ return false;
+ }
+
+ pipingCalculation.InputParameters.PhreaticLevelExit = distribution;
+ return true;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationReader.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationReader.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationReader.cs (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -0,0 +1,99 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Xml.Linq;
+using Core.Common.Base.IO;
+using Ringtoets.Common.IO.Configurations;
+using Ringtoets.Common.IO.Configurations.Helpers;
+using Ringtoets.Common.IO.Configurations.Import;
+using Ringtoets.Piping.IO.Properties;
+using RingtoetsCommonIOResources = Ringtoets.Common.IO.Properties.Resources;
+
+namespace Ringtoets.Piping.IO.Configurations
+{
+ ///
+ /// This class reads a piping calculation configuration from XML and creates a collection of corresponding
+ /// , typically containing one or more .
+ ///
+ public class PipingCalculationConfigurationReader : CalculationConfigurationReader
+ {
+ private const string stochastSchemaName = "StochastSchema.xsd";
+ private const string stochastStandaardafwijkingSchemaName = "StochastStandaardafwijkingSchema.xsd";
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The file path to the XML file.
+ /// Thrown when is invalid.
+ /// Thrown when:
+ ///
+ /// - points to a file that does not exist.
+ /// - points to a file that does not contain valid XML.
+ /// - points to a file that does not pass the schema validation.
+ /// - points to a file that does not contain configuration elements.
+ ///
+ ///
+ internal PipingCalculationConfigurationReader(string xmlFilePath)
+ : base(xmlFilePath,
+ Resources.PipingConfiguratieSchema,
+ new Dictionary
+ {
+ {
+ stochastSchemaName, RingtoetsCommonIOResources.StochastSchema
+ },
+ {
+ stochastStandaardafwijkingSchemaName, RingtoetsCommonIOResources.StochastStandaardafwijkingSchema
+ }
+ }) {}
+
+ protected override PipingCalculationConfiguration ParseCalculationElement(XElement calculationElement)
+ {
+ var calculation = new PipingCalculationConfiguration(calculationElement.Attribute(ConfigurationSchemaIdentifiers.NameAttribute).Value)
+ {
+ AssessmentLevel = calculationElement.GetDoubleValueFromDescendantElement(PipingCalculationConfigurationSchemaIdentifiers.AssessmentLevelElement),
+ HydraulicBoundaryLocation = calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement),
+ SurfaceLine = calculationElement.GetStringValueFromDescendantElement(PipingCalculationConfigurationSchemaIdentifiers.SurfaceLineElement),
+ EntryPointL = calculationElement.GetDoubleValueFromDescendantElement(PipingCalculationConfigurationSchemaIdentifiers.EntryPointLElement),
+ ExitPointL = calculationElement.GetDoubleValueFromDescendantElement(PipingCalculationConfigurationSchemaIdentifiers.ExitPointLElement),
+ StochasticSoilModel = calculationElement.GetStringValueFromDescendantElement(PipingCalculationConfigurationSchemaIdentifiers.StochasticSoilModelElement),
+ StochasticSoilProfile = calculationElement.GetStringValueFromDescendantElement(PipingCalculationConfigurationSchemaIdentifiers.StochasticSoilProfileElement)
+ };
+
+ XElement phreaticLevelExitElement = calculationElement.GetStochastElement(PipingCalculationConfigurationSchemaIdentifiers.PhreaticLevelExitStochastName);
+ if (phreaticLevelExitElement != null)
+ {
+ calculation.PhreaticLevelExitMean = phreaticLevelExitElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.MeanElement);
+ calculation.PhreaticLevelExitStandardDeviation = phreaticLevelExitElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.StandardDeviationElement);
+ }
+
+ XElement dampingFactorExitElement = calculationElement.GetStochastElement(PipingCalculationConfigurationSchemaIdentifiers.DampingFactorExitStochastName);
+ if (dampingFactorExitElement != null)
+ {
+ calculation.DampingFactorExitMean = dampingFactorExitElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.MeanElement);
+ calculation.DampingFactorExitStandardDeviation = dampingFactorExitElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.StandardDeviationElement);
+ }
+
+ return calculation;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationSchemaIdentifiers.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationSchemaIdentifiers.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationSchemaIdentifiers.cs (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -0,0 +1,69 @@
+// Copyright (C) Stichting Deltares 2017. 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.
+
+namespace Ringtoets.Piping.IO.Configurations
+{
+ ///
+ /// Container of identifiers related to the piping calculation configuration schema definition.
+ ///
+ internal static class PipingCalculationConfigurationSchemaIdentifiers
+ {
+ ///
+ /// The identifier for assessment level elements.
+ ///
+ internal const string AssessmentLevelElement = "toetspeil";
+
+ ///
+ /// The identifier for surface line elements.
+ ///
+ internal const string SurfaceLineElement = "profielschematisatie";
+
+ ///
+ /// The identifier for entry point elements.
+ ///
+ internal const string EntryPointLElement = "intredepunt";
+
+ ///
+ /// The identifier for exit point elements.
+ ///
+ internal const string ExitPointLElement = "uittredepunt";
+
+ ///
+ /// The identifier for stochastic soil model elements.
+ ///
+ internal const string StochasticSoilModelElement = "ondergrondmodel";
+
+ ///
+ /// The identifier for stochastic soil profile elements.
+ ///
+ internal const string StochasticSoilProfileElement = "ondergrondschematisatie";
+
+ ///
+ /// The identifier for the phreatic level exit stochast names.
+ ///
+ internal const string PhreaticLevelExitStochastName = "polderpeil";
+
+ ///
+ /// The identifier for the damping factor exit stochast names.
+ ///
+ internal const string DampingFactorExitStochastName = "dempingsfactor";
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationWriter.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationWriter.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Configurations/PipingCalculationConfigurationWriter.cs (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -0,0 +1,96 @@
+// Copyright (C) Stichting Deltares 2017. 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.Collections.Generic;
+using System.Xml;
+using Ringtoets.Common.Data.Probabilistics;
+using Ringtoets.Common.IO.Configurations;
+using Ringtoets.Common.IO.Configurations.Export;
+using Ringtoets.Piping.Data;
+
+namespace Ringtoets.Piping.IO.Configurations
+{
+ ///
+ /// Writer for writing a piping calculation configuration to XML.
+ ///
+ public class PipingCalculationConfigurationWriter : CalculationConfigurationWriter
+ {
+ protected override void WriteCalculation(PipingCalculation calculation, XmlWriter writer)
+ {
+ writer.WriteStartElement(ConfigurationSchemaIdentifiers.CalculationElement);
+ writer.WriteAttributeString(ConfigurationSchemaIdentifiers.NameAttribute, calculation.Name);
+
+ PipingInput calculationInputParameters = calculation.InputParameters;
+
+ if (calculationInputParameters.UseAssessmentLevelManualInput)
+ {
+ writer.WriteElementString(PipingCalculationConfigurationSchemaIdentifiers.AssessmentLevelElement,
+ XmlConvert.ToString(calculationInputParameters.AssessmentLevel));
+ }
+ else if (calculationInputParameters.HydraulicBoundaryLocation != null)
+ {
+ writer.WriteElementString(ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement,
+ calculationInputParameters.HydraulicBoundaryLocation.Name);
+ }
+
+ if (calculationInputParameters.SurfaceLine != null)
+ {
+ writer.WriteElementString(PipingCalculationConfigurationSchemaIdentifiers.SurfaceLineElement,
+ calculationInputParameters.SurfaceLine.Name);
+ writer.WriteElementString(PipingCalculationConfigurationSchemaIdentifiers.EntryPointLElement,
+ XmlConvert.ToString(calculationInputParameters.EntryPointL));
+ writer.WriteElementString(PipingCalculationConfigurationSchemaIdentifiers.ExitPointLElement,
+ XmlConvert.ToString(calculationInputParameters.ExitPointL));
+ }
+
+ if (calculationInputParameters.StochasticSoilModel != null)
+ {
+ writer.WriteElementString(PipingCalculationConfigurationSchemaIdentifiers.StochasticSoilModelElement,
+ calculationInputParameters.StochasticSoilModel.Name);
+
+ if (calculationInputParameters.StochasticSoilProfile?.SoilProfile != null)
+ {
+ writer.WriteElementString(PipingCalculationConfigurationSchemaIdentifiers.StochasticSoilProfileElement,
+ calculationInputParameters.StochasticSoilProfile.SoilProfile.Name);
+ }
+ }
+
+ WriteDistributions(CreateInputDistributions(calculationInputParameters), writer);
+
+ writer.WriteEndElement();
+ }
+
+ private static IDictionary CreateInputDistributions(PipingInput calculationInputParameters)
+ {
+ return new Dictionary
+ {
+ {
+ PipingCalculationConfigurationSchemaIdentifiers.PhreaticLevelExitStochastName,
+ calculationInputParameters.PhreaticLevelExit
+ },
+ {
+ PipingCalculationConfigurationSchemaIdentifiers.DampingFactorExitStochastName,
+ calculationInputParameters.DampingFactorExit
+ }
+ };
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 6df044b18d205d87d4f38a623cc6e29146d4e95e refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Exporters/PipingCalculationConfigurationExporter.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 6df044b18d205d87d4f38a623cc6e29146d4e95e refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Exporters/PipingCalculationConfigurationWriter.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 6df044b18d205d87d4f38a623cc6e29146d4e95e refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingCalculationConfigurationImporter.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 6df044b18d205d87d4f38a623cc6e29146d4e95e refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingCalculationConfigurationReader.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 6df044b18d205d87d4f38a623cc6e29146d4e95e refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/ReadPipingCalculation.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj
===================================================================
diff -u -r50597fbeb76b752bc250107dfa91b696bb6c4995 -r6df044b18d205d87d4f38a623cc6e29146d4e95e
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 50597fbeb76b752bc250107dfa91b696bb6c4995)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -52,20 +52,20 @@
-
-
+
+
-
+
True
True
Resources.resx
-
-
-
+
+
+
Fisheye: Tag 6df044b18d205d87d4f38a623cc6e29146d4e95e refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Schema/PipingCalculationConfigurationSchemaIdentifiers.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs
===================================================================
diff -u -re402805257d7185512020535bd0df9cd01a7734e -r6df044b18d205d87d4f38a623cc6e29146d4e95e
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision e402805257d7185512020535bd0df9cd01a7734e)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -47,7 +47,7 @@
using Ringtoets.Piping.Forms.PresentationObjects;
using Ringtoets.Piping.Forms.PropertyClasses;
using Ringtoets.Piping.Forms.Views;
-using Ringtoets.Piping.IO.Exporters;
+using Ringtoets.Piping.IO.Configurations;
using Ringtoets.Piping.IO.Importers;
using Ringtoets.Piping.Plugin.FileImporter;
using Ringtoets.Piping.Plugin.Properties;
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationExporterTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationExporterTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationExporterTest.cs (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -0,0 +1,99 @@
+// Copyright (C) Stichting Deltares 2017. 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.IO;
+using Core.Common.Base.Data;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.IO.TestUtil;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Integration.TestUtils;
+using Ringtoets.Piping.IO.Configurations;
+using Ringtoets.Piping.Primitives;
+
+namespace Ringtoets.Piping.IO.Test.Configurations
+{
+ [TestFixture]
+ public class PipingCalculationConfigurationExporterTest
+ : CustomCalculationConfigurationExporterDesignGuidelinesTestFixture<
+ PipingCalculationConfigurationExporter,
+ PipingCalculationConfigurationWriter,
+ PipingCalculation>
+ {
+ [Test]
+ public void Export_ValidData_ReturnTrueAndWritesFile()
+ {
+ // Setup
+ PipingCalculation calculation = PipingTestDataGenerator.GetPipingCalculation();
+ calculation.InputParameters.EntryPointL = (RoundedDouble) 0.1;
+ calculation.InputParameters.ExitPointL = (RoundedDouble) 0.2;
+
+ PipingCalculation calculation2 = PipingTestDataGenerator.GetPipingCalculation();
+ calculation2.Name = "PK001_0002 W1-6_4_1D1";
+ calculation2.InputParameters.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "PUNT_SCH_17", 0, 0);
+ calculation2.InputParameters.SurfaceLine.Name = "PK001_0002";
+ calculation2.InputParameters.EntryPointL = (RoundedDouble) 0.3;
+ calculation2.InputParameters.ExitPointL = (RoundedDouble) 0.4;
+ calculation2.InputParameters.StochasticSoilModel = new StochasticSoilModel(1, "PK001_0002_Piping", string.Empty);
+ calculation2.InputParameters.StochasticSoilProfile = new StochasticSoilProfile(0, SoilProfileType.SoilProfile1D, 0)
+ {
+ SoilProfile = new PipingSoilProfile("W1-6_4_1D1", 0, new[]
+ {
+ new PipingSoilLayer(0)
+ }, SoilProfileType.SoilProfile1D, 0)
+ };
+
+ var calculationGroup2 = new CalculationGroup("PK001_0002", false)
+ {
+ Children =
+ {
+ calculation2
+ }
+ };
+
+ var calculationGroup = new CalculationGroup("PK001_0001", false)
+ {
+ Children =
+ {
+ calculation,
+ calculationGroup2
+ }
+ };
+
+ string expectedXmlFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO,
+ Path.Combine(nameof(PipingCalculationConfigurationExporter),
+ "folderWithSubfolderAndCalculation.xml"));
+
+ // Call and Assert
+ WriteAndValidate(new[]
+ {
+ calculationGroup
+ }, expectedXmlFilePath);
+ }
+
+ protected override PipingCalculation CreateCalculation()
+ {
+ return PipingTestDataGenerator.GetPipingCalculation();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationImporterTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationImporterTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationImporterTest.cs (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -0,0 +1,592 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.IO;
+using System.Linq;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.IO.Configurations.Import;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.IO.Configurations;
+using Ringtoets.Piping.Primitives;
+
+namespace Ringtoets.Piping.IO.Test.Configurations
+{
+ [TestFixture]
+ public class PipingCalculationConfigurationImporterTest
+ {
+ private readonly string readerPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, nameof(PipingCalculationConfigurationReader));
+ private readonly string importerPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, nameof(PipingCalculationConfigurationImporter));
+
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var importer = new PipingCalculationConfigurationImporter("",
+ new CalculationGroup(),
+ Enumerable.Empty(),
+ new PipingFailureMechanism());
+
+ // Assert
+ Assert.IsInstanceOf>(importer);
+ }
+
+ [Test]
+ public void Constructor_HydraulicBoundaryLocationsNull_ThrowArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new PipingCalculationConfigurationImporter("",
+ new CalculationGroup(),
+ null,
+ new PipingFailureMechanism());
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("availableHydraulicBoundaryLocations", exception.ParamName);
+ }
+
+ [Test]
+ public void Constructor_FailureMechanismNull_ThrowArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new PipingCalculationConfigurationImporter("",
+ new CalculationGroup(),
+ Enumerable.Empty(),
+ null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ }
+
+ [Test]
+ [SetCulture("nl-NL")]
+ [TestCase("validConfigurationInvalidEntryExitPoint.xml",
+ "Een waarde van '2,2' als uittredepunt is ongeldig. Het uittredepunt moet landwaarts van het intredepunt liggen.")]
+ [TestCase("validConfigurationExitPointNotOnSurfaceLine.xml",
+ "Een waarde van '200,2' als uittredepunt is ongeldig. Het gespecificeerde punt moet op het profiel liggen (bereik [0,0, 10,0]).")]
+ [TestCase("validConfigurationEntryPointNotOnSurfaceLine.xml",
+ "Een waarde van '-10' als intredepunt is ongeldig. Het gespecificeerde punt moet op het profiel liggen (bereik [0,0, 10,0]).")]
+ [TestCase("validConfigurationCalculationContainingInfinityEntryPoint.xml",
+ "Een waarde van '-Infinity' als intredepunt is ongeldig. Het gespecificeerde punt moet op het profiel liggen (bereik [0,0, 10,0]).")]
+ [TestCase("validConfigurationCalculationContainingInfinityExitPoint.xml",
+ "Een waarde van 'Infinity' als uittredepunt is ongeldig. Het gespecificeerde punt moet op het profiel liggen (bereik [0,0, 10,0]).")]
+ [TestCase("validConfigurationInvalidStandardDeviationPhreaticLevelExit.xml",
+ "Een standaardafwijking van '-1' is ongeldig voor stochast 'polderpeil'. Standaardafwijking (σ) moet groter zijn dan of gelijk zijn aan 0.")]
+ [TestCase("validConfigurationInvalidMeanDampingFactorExit.xml",
+ "Een gemiddelde van '-1' is ongeldig voor stochast 'dempingsfactor'. Gemiddelde moet groter zijn dan 0.")]
+ [TestCase("validConfigurationInvalidStandardDeviationDampingFactorExit.xml",
+ "Een standaardafwijking van '-1' is ongeldig voor stochast 'dempingsfactor'. Standaardafwijking (σ) moet groter zijn dan of gelijk zijn aan 0.")]
+ public void Import_ValidConfigurationInvalidData_LogMessageAndContinueImport(string file, string expectedErrorMessage)
+ {
+ // Setup
+ string filePath = Path.Combine(importerPath, file);
+
+ var calculationGroup = new CalculationGroup();
+ var surfaceLine = new RingtoetsPipingSurfaceLine
+ {
+ Name = "Profielschematisatie"
+ };
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(3.0, 5.0, 0.0),
+ new Point3D(3.0, 0.0, 1.0),
+ new Point3D(3.0, -5.0, 0.0)
+ });
+
+ var pipingFailureMechanism = new PipingFailureMechanism();
+ pipingFailureMechanism.SurfaceLines.AddRange(new[]
+ {
+ surfaceLine
+ }, "readerPath");
+
+ var importer = new PipingCalculationConfigurationImporter(filePath,
+ calculationGroup,
+ new HydraulicBoundaryLocation[0],
+ pipingFailureMechanism);
+ var successful = false;
+
+ // Call
+ Action call = () => successful = importer.Import();
+
+ // Assert
+ string expectedMessage = $"{expectedErrorMessage} Berekening 'Calculation' is overgeslagen.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsTrue(successful);
+ CollectionAssert.IsEmpty(calculationGroup.Children);
+ }
+
+ [Test]
+ public void Import_HydraulicBoundaryLocationUnknown_LogMessageAndContinueImport()
+ {
+ // Setup
+ string filePath = Path.Combine(importerPath, "validConfigurationCalculationContainingUnknownHydraulicBoundaryLocation.xml");
+
+ var calculationGroup = new CalculationGroup();
+ var importer = new PipingCalculationConfigurationImporter(filePath,
+ calculationGroup,
+ Enumerable.Empty(),
+ new PipingFailureMechanism());
+
+ // Call
+ var successful = false;
+ Action call = () => successful = importer.Import();
+
+ // Assert
+ const string expectedMessage = "De locatie met hydraulische randvoorwaarden 'HRlocatie' bestaat niet. Berekening 'Calculation' is overgeslagen.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsTrue(successful);
+ CollectionAssert.IsEmpty(calculationGroup.Children);
+ }
+
+ [Test]
+ public void Import_SurfaceLineUnknown_LogMessageAndContinueImport()
+ {
+ // Setup
+ string filePath = Path.Combine(importerPath, "validConfigurationCalculationContainingUnknownSurfaceLine.xml");
+
+ var calculationGroup = new CalculationGroup();
+ var importer = new PipingCalculationConfigurationImporter(filePath,
+ calculationGroup,
+ new HydraulicBoundaryLocation[0],
+ new PipingFailureMechanism());
+
+ // Call
+ var successful = false;
+ Action call = () => successful = importer.Import();
+
+ // Assert
+ const string expectedMessage = "De profielschematisatie 'Profielschematisatie' bestaat niet. Berekening 'Calculation' is overgeslagen.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsTrue(successful);
+ CollectionAssert.IsEmpty(calculationGroup.Children);
+ }
+
+ [Test]
+ public void Import_StochasticSoilModelUnknown_LogMessageAndContinueImport()
+ {
+ // Setup
+ string filePath = Path.Combine(importerPath, "validConfigurationCalculationContainingUnknownSoilModel.xml");
+
+ var calculationGroup = new CalculationGroup();
+ var pipingFailureMechanism = new PipingFailureMechanism();
+ var importer = new PipingCalculationConfigurationImporter(filePath,
+ calculationGroup,
+ new HydraulicBoundaryLocation[0],
+ pipingFailureMechanism);
+
+ // Call
+ var successful = false;
+ Action call = () => successful = importer.Import();
+
+ // Assert
+ const string expectedMessage = "Het stochastische ondergrondmodel 'Ondergrondmodel' bestaat niet. Berekening 'Calculation' is overgeslagen.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsTrue(successful);
+ CollectionAssert.IsEmpty(calculationGroup.Children);
+ }
+
+ [Test]
+ public void Import_StochasticSoilModelNotIntersectingWithSurfaceLine_LogMessageAndContinueImport()
+ {
+ // Setup
+ string filePath = Path.Combine(importerPath, "validConfigurationCalculationContainingNonIntersectingSurfaceLineAndSoilModel.xml");
+
+ var calculationGroup = new CalculationGroup();
+ var surfaceLine = new RingtoetsPipingSurfaceLine
+ {
+ Name = "Profielschematisatie"
+ };
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(0.0, 1.0, 0.0),
+ new Point3D(2.5, 1.0, 1.0),
+ new Point3D(5.0, 1.0, 0.0)
+ });
+ var stochasticSoilModel = new StochasticSoilModel(1, "Ondergrondmodel", "Segment");
+ stochasticSoilModel.Geometry.AddRange(new[]
+ {
+ new Point2D(1.0, 0.0),
+ new Point2D(5.0, 0.0)
+ });
+
+ var pipingFailureMechanism = new PipingFailureMechanism();
+ pipingFailureMechanism.SurfaceLines.AddRange(new[]
+ {
+ surfaceLine
+ }, "readerPath");
+ pipingFailureMechanism.StochasticSoilModels.AddRange(new[]
+ {
+ stochasticSoilModel
+ }, "readerPath");
+
+ var importer = new PipingCalculationConfigurationImporter(filePath,
+ calculationGroup,
+ new HydraulicBoundaryLocation[0],
+ pipingFailureMechanism);
+
+ // Call
+ var successful = false;
+ Action call = () => successful = importer.Import();
+
+ // Assert
+ const string expectedMessage = "Het stochastische ondergrondmodel 'Ondergrondmodel'doorkruist de profielschematisatie 'Profielschematisatie' niet. Berekening 'Calculation' is overgeslagen.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsTrue(successful);
+ CollectionAssert.IsEmpty(calculationGroup.Children);
+ }
+
+ [Test]
+ public void Import_StochasticSoilProfileUnknown_LogMessageAndContinueImport()
+ {
+ // Setup
+ string filePath = Path.Combine(importerPath, "validConfigurationCalculationContainingUnknownSoilProfile.xml");
+
+ var calculationGroup = new CalculationGroup();
+ var surfaceLine = new RingtoetsPipingSurfaceLine
+ {
+ Name = "Profielschematisatie"
+ };
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(3.0, 5.0, 0.0),
+ new Point3D(3.0, 0.0, 1.0),
+ new Point3D(3.0, -5.0, 0.0)
+ });
+ var stochasticSoilModel = new StochasticSoilModel(1, "Ondergrondmodel", "Segment");
+ stochasticSoilModel.Geometry.AddRange(new[]
+ {
+ new Point2D(1.0, 0.0),
+ new Point2D(5.0, 0.0)
+ });
+
+ var pipingFailureMechanism = new PipingFailureMechanism();
+ pipingFailureMechanism.SurfaceLines.AddRange(new[]
+ {
+ surfaceLine
+ }, "readerPath");
+ pipingFailureMechanism.StochasticSoilModels.AddRange(new[]
+ {
+ stochasticSoilModel
+ }, "readerPath");
+
+ var importer = new PipingCalculationConfigurationImporter(filePath,
+ calculationGroup,
+ new HydraulicBoundaryLocation[0],
+ pipingFailureMechanism);
+
+ // Call
+ var successful = false;
+ Action call = () => successful = importer.Import();
+
+ // Assert
+ const string expectedMessage = "De ondergrondschematisatie 'Ondergrondschematisatie' bestaat niet binnen het stochastische ondergrondmodel 'Ondergrondmodel'. Berekening 'Calculation' is overgeslagen.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsTrue(successful);
+ CollectionAssert.IsEmpty(calculationGroup.Children);
+ }
+
+ [Test]
+ public void Import_StochasticSoilProfileSpecifiedWithoutSoilModel_LogMessageAndContinueImport()
+ {
+ // Setup
+ string filePath = Path.Combine(importerPath, "validConfigurationCalculationContainingSoilProfileWithoutSoilModel.xml");
+
+ var calculationGroup = new CalculationGroup();
+ var pipingFailureMechanism = new PipingFailureMechanism();
+ var importer = new PipingCalculationConfigurationImporter(filePath,
+ calculationGroup,
+ new HydraulicBoundaryLocation[0],
+ pipingFailureMechanism);
+
+ // Call
+ var successful = false;
+ Action call = () => successful = importer.Import();
+
+ // Assert
+ const string expectedMessage = "Er is geen stochastisch ondergrondmodel opgegeven bij ondergrondschematisatie 'Ondergrondschematisatie'. Berekening 'Calculation' is overgeslagen.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsTrue(successful);
+ CollectionAssert.IsEmpty(calculationGroup.Children);
+ }
+
+ [Test]
+ [TestCase("validConfigurationCalculationContainingEntryPointWithoutSurfaceLine.xml")]
+ [TestCase("validConfigurationCalculationContainingExitPointWithoutSurfaceLine.xml")]
+ [TestCase("validConfigurationCalculationContainingEntryPointAndExitPointWithoutSurfaceLine.xml")]
+ [TestCase("validConfigurationCalculationContainingNaNs.xml")]
+ public void Import_EntryAndOrExitPointDefinedWithoutSurfaceLine_LogMessageAndContinueImport(string file)
+ {
+ // Setup
+ string filePath = Path.Combine(importerPath, file);
+
+ var calculationGroup = new CalculationGroup();
+ var pipingFailureMechanism = new PipingFailureMechanism();
+ var importer = new PipingCalculationConfigurationImporter(filePath,
+ calculationGroup,
+ new HydraulicBoundaryLocation[0],
+ pipingFailureMechanism);
+
+ // Call
+ var successful = false;
+ Action call = () => successful = importer.Import();
+
+ // Assert
+ const string expectedMessage = "Er is geen profielschematisatie, maar wel een intrede- of uittredepunt opgegeven. Berekening 'Calculation' is overgeslagen.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsTrue(successful);
+ CollectionAssert.IsEmpty(calculationGroup.Children);
+ }
+
+ [Test]
+ public void Import_StochastsWithNoParametersSet_DataAddedToModel()
+ {
+ // Setup
+ string filePath = Path.Combine(importerPath, "validConfigurationStochastsNoParameters.xml");
+
+ var calculationGroup = new CalculationGroup();
+
+ var pipingFailureMechanism = new PipingFailureMechanism();
+
+ var importer = new PipingCalculationConfigurationImporter(filePath,
+ calculationGroup,
+ Enumerable.Empty(),
+ pipingFailureMechanism);
+
+ // Call
+ bool successful = importer.Import();
+
+ // Assert
+ Assert.IsTrue(successful);
+
+ var expectedCalculation = new PipingCalculationScenario(new GeneralPipingInput())
+ {
+ Name = "Calculation"
+ };
+
+ Assert.AreEqual(1, calculationGroup.Children.Count);
+ AssertPipingCalculationScenario(expectedCalculation, (PipingCalculationScenario) calculationGroup.Children[0]);
+ }
+
+ [Test]
+ public void Import_StochastsWithMeanSet_DataAddedToModel()
+ {
+ // Setup
+ string filePath = Path.Combine(importerPath, "validConfigurationStochastsMeanOnly.xml");
+
+ var calculationGroup = new CalculationGroup();
+
+ var pipingFailureMechanism = new PipingFailureMechanism();
+
+ var importer = new PipingCalculationConfigurationImporter(filePath,
+ calculationGroup,
+ Enumerable.Empty(),
+ pipingFailureMechanism);
+
+ // Call
+ bool successful = importer.Import();
+
+ // Assert
+ Assert.IsTrue(successful);
+
+ var expectedCalculation = new PipingCalculationScenario(new GeneralPipingInput())
+ {
+ Name = "Calculation",
+ InputParameters =
+ {
+ PhreaticLevelExit =
+ {
+ Mean = (RoundedDouble) 4.4
+ },
+ DampingFactorExit =
+ {
+ Mean = (RoundedDouble) 6.6
+ }
+ }
+ };
+
+ Assert.AreEqual(1, calculationGroup.Children.Count);
+ AssertPipingCalculationScenario(expectedCalculation, (PipingCalculationScenario) calculationGroup.Children[0]);
+ }
+
+ [Test]
+ public void Import_StochastsWithStandardDeviationSet_DataAddedToModel()
+ {
+ // Setup
+ string filePath = Path.Combine(importerPath, "validConfigurationStochastsStandardDeviationOnly.xml");
+
+ var calculationGroup = new CalculationGroup();
+
+ var pipingFailureMechanism = new PipingFailureMechanism();
+
+ var importer = new PipingCalculationConfigurationImporter(filePath,
+ calculationGroup,
+ Enumerable.Empty(),
+ pipingFailureMechanism);
+
+ // Call
+ bool successful = importer.Import();
+
+ // Assert
+ Assert.IsTrue(successful);
+
+ var expectedCalculation = new PipingCalculationScenario(new GeneralPipingInput())
+ {
+ Name = "Calculation",
+ InputParameters =
+ {
+ PhreaticLevelExit =
+ {
+ StandardDeviation = (RoundedDouble) 5.5
+ },
+ DampingFactorExit =
+ {
+ StandardDeviation = (RoundedDouble) 7.7
+ }
+ }
+ };
+
+ Assert.AreEqual(1, calculationGroup.Children.Count);
+ AssertPipingCalculationScenario(expectedCalculation, (PipingCalculationScenario) calculationGroup.Children[0]);
+ }
+
+ [Test]
+ [TestCase("validConfigurationFullCalculationContainingHydraulicBoundaryLocation.xml", false)]
+ [TestCase("validConfigurationFullCalculationContainingAssessmentLevel.xml", true)]
+ public void Import_ValidConfigurationWithValidHydraulicBoundaryData_DataAddedToModel(string file, bool manualAssessmentLevel)
+ {
+ // Setup
+ string filePath = Path.Combine(readerPath, file);
+
+ var calculationGroup = new CalculationGroup();
+ var surfaceLine = new RingtoetsPipingSurfaceLine
+ {
+ Name = "Profielschematisatie"
+ };
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(3.0, 5.0, 0.0),
+ new Point3D(3.0, 0.0, 1.0),
+ new Point3D(3.0, -5.0, 0.0)
+ });
+ var stochasticSoilProfile = new StochasticSoilProfile(0, SoilProfileType.SoilProfile1D, 1)
+ {
+ SoilProfile = new PipingSoilProfile("Ondergrondschematisatie", 0, new[]
+ {
+ new PipingSoilLayer(0)
+ }, SoilProfileType.SoilProfile1D, 0)
+ };
+
+ var stochasticSoilModel = new StochasticSoilModel(1, "Ondergrondmodel", "Segment");
+ stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfile);
+ stochasticSoilModel.Geometry.AddRange(new[]
+ {
+ new Point2D(1.0, 0.0),
+ new Point2D(5.0, 0.0)
+ });
+
+ var pipingFailureMechanism = new PipingFailureMechanism();
+ pipingFailureMechanism.SurfaceLines.AddRange(new[]
+ {
+ surfaceLine
+ }, "readerPath");
+ pipingFailureMechanism.StochasticSoilModels.AddRange(new[]
+ {
+ stochasticSoilModel
+ }, "readerPath");
+
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "HRlocatie", 10, 20);
+ var importer = new PipingCalculationConfigurationImporter(filePath,
+ calculationGroup,
+ new[]
+ {
+ hydraulicBoundaryLocation
+ },
+ pipingFailureMechanism);
+
+ // Call
+ bool successful = importer.Import();
+
+ // Assert
+ Assert.IsTrue(successful);
+
+ var expectedCalculation = new PipingCalculationScenario(new GeneralPipingInput())
+ {
+ Name = "Calculation",
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = hydraulicBoundaryLocation,
+ UseAssessmentLevelManualInput = manualAssessmentLevel,
+ SurfaceLine = surfaceLine,
+ EntryPointL = (RoundedDouble) 2.2,
+ ExitPointL = (RoundedDouble) 3.3,
+ StochasticSoilModel = stochasticSoilModel,
+ StochasticSoilProfile = stochasticSoilProfile,
+ PhreaticLevelExit =
+ {
+ Mean = (RoundedDouble) 4.4,
+ StandardDeviation = (RoundedDouble) 5.5
+ },
+ DampingFactorExit =
+ {
+ Mean = (RoundedDouble) 6.6,
+ StandardDeviation = (RoundedDouble) 7.7
+ }
+ }
+ };
+ if (manualAssessmentLevel)
+ {
+ expectedCalculation.InputParameters.AssessmentLevel = (RoundedDouble) 1.1;
+ }
+
+ Assert.AreEqual(1, calculationGroup.Children.Count);
+ AssertPipingCalculationScenario(expectedCalculation, (PipingCalculationScenario) calculationGroup.Children[0]);
+ }
+
+ private static void AssertPipingCalculationScenario(PipingCalculationScenario expectedCalculation, PipingCalculationScenario actualCalculation)
+ {
+ Assert.AreEqual(expectedCalculation.Name, actualCalculation.Name);
+ Assert.AreEqual(expectedCalculation.InputParameters.UseAssessmentLevelManualInput, actualCalculation.InputParameters.UseAssessmentLevelManualInput);
+ if (expectedCalculation.InputParameters.UseAssessmentLevelManualInput)
+ {
+ Assert.AreEqual(expectedCalculation.InputParameters.AssessmentLevel.Value, actualCalculation.InputParameters.AssessmentLevel.Value);
+ }
+ else
+ {
+ Assert.AreSame(expectedCalculation.InputParameters.HydraulicBoundaryLocation, actualCalculation.InputParameters.HydraulicBoundaryLocation);
+ }
+ Assert.AreSame(expectedCalculation.InputParameters.SurfaceLine, actualCalculation.InputParameters.SurfaceLine);
+ Assert.AreEqual(expectedCalculation.InputParameters.EntryPointL.Value, actualCalculation.InputParameters.EntryPointL.Value);
+ Assert.AreEqual(expectedCalculation.InputParameters.ExitPointL.Value, actualCalculation.InputParameters.ExitPointL.Value);
+ Assert.AreSame(expectedCalculation.InputParameters.StochasticSoilModel, actualCalculation.InputParameters.StochasticSoilModel);
+ Assert.AreSame(expectedCalculation.InputParameters.StochasticSoilProfile, actualCalculation.InputParameters.StochasticSoilProfile);
+ Assert.AreEqual(expectedCalculation.InputParameters.PhreaticLevelExit.Mean.Value, actualCalculation.InputParameters.PhreaticLevelExit.Mean.Value);
+ Assert.AreEqual(expectedCalculation.InputParameters.PhreaticLevelExit.StandardDeviation.Value, actualCalculation.InputParameters.PhreaticLevelExit.StandardDeviation.Value);
+ Assert.AreEqual(expectedCalculation.InputParameters.DampingFactorExit.Mean.Value, actualCalculation.InputParameters.DampingFactorExit.Mean.Value);
+ Assert.AreEqual(expectedCalculation.InputParameters.DampingFactorExit.StandardDeviation.Value, actualCalculation.InputParameters.DampingFactorExit.StandardDeviation.Value);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationReaderTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationReaderTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationReaderTest.cs (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -0,0 +1,419 @@
+// Copyright (C) Stichting Deltares 2017. 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.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Xml.Schema;
+using Core.Common.Base.IO;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.IO.Configurations;
+using Ringtoets.Common.IO.Configurations.Import;
+using Ringtoets.Piping.IO.Configurations;
+
+namespace Ringtoets.Piping.IO.Test.Configurations
+{
+ [TestFixture]
+ public class PipingCalculationConfigurationReaderTest
+ {
+ private readonly string testDirectoryPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO,
+ nameof(PipingCalculationConfigurationReader));
+
+ private static IEnumerable InvalidConfigurations
+ {
+ get
+ {
+ yield return new TestCaseData("invalidAssessmentLevelEmpty.xml",
+ "The 'toetspeil' element is invalid - The value '' is invalid according to its datatype 'Double'")
+ .SetName("invalidAssessmentLevelEmpty");
+ yield return new TestCaseData("invalidAssessmentLevelNoDouble.xml",
+ "The 'toetspeil' element is invalid - The value 'string' is invalid according to its datatype 'Double'")
+ .SetName("invalidAssessmentLevelNoDouble");
+ yield return new TestCaseData("invalidEntryPointEmpty.xml",
+ "The 'intredepunt' element is invalid - The value '' is invalid according to its datatype 'Double'")
+ .SetName("invalidEntryPointEmpty");
+ yield return new TestCaseData("invalidEntryPointNoDouble.xml",
+ "The 'intredepunt' element is invalid - The value 'string' is invalid according to its datatype 'Double'")
+ .SetName("invalidEntryPointNoDouble");
+ yield return new TestCaseData("invalidExitPointEmpty.xml",
+ "The 'uittredepunt' element is invalid - The value '' is invalid according to its datatype 'Double'")
+ .SetName("invalidExitPointEmpty");
+ yield return new TestCaseData("invalidExitPointNoDouble.xml",
+ "The 'uittredepunt' element is invalid - The value 'string' is invalid according to its datatype 'Double'")
+ .SetName("invalidExitPointNoDouble");
+ yield return new TestCaseData("invalidStochastNoName.xml",
+ "The required attribute 'naam' is missing.")
+ .SetName("invalidStochastNoName");
+ yield return new TestCaseData("invalidStochastUnknownName.xml",
+ "The 'naam' attribute is invalid - The value 'Test' is invalid according to its datatype 'nameType' - The Enumeration constraint failed.")
+ .SetName("invalidStochastUnknownName");
+ yield return new TestCaseData("invalidStochastMultipleMean.xml",
+ "Element 'verwachtingswaarde' cannot appear more than once if content model type is \"all\".")
+ .SetName("invalidStochastMultipleMean");
+ yield return new TestCaseData("invalidStochastMultipleStandardDeviation.xml",
+ "Element 'standaardafwijking' cannot appear more than once if content model type is \"all\".")
+ .SetName("invalidStochastMultipleStandardDeviation");
+ yield return new TestCaseData("invalidStochastMeanEmpty.xml",
+ "The 'verwachtingswaarde' element is invalid - The value '' is invalid according to its datatype 'Double'")
+ .SetName("invalidStochastMeanEmpty");
+ yield return new TestCaseData("invalidStochastMeanNoDouble.xml",
+ "The 'verwachtingswaarde' element is invalid - The value 'string' is invalid according to its datatype 'Double'")
+ .SetName("invalidStochastMeanNoDouble");
+ yield return new TestCaseData("invalidStochastStandardDeviationEmpty.xml",
+ "The 'standaardafwijking' element is invalid - The value '' is invalid according to its datatype 'Double'")
+ .SetName("invalidStochastStandardDeviationEmpty");
+ yield return new TestCaseData("invalidStochastStandardDeviationNoDouble.xml",
+ "The 'standaardafwijking' element is invalid - The value 'string' is invalid according to its datatype 'Double'")
+ .SetName("invalidStochastStandardDeviationNoDouble");
+ yield return new TestCaseData("invalidMultiplePhreaticLevelExitStochast.xml",
+ "There is a duplicate key sequence 'polderpeil' for the 'uniqueStochastNameConstraint' key or unique identity constraint.")
+ .SetName("invalidMultiplePhreaticLevelExitStochast");
+ yield return new TestCaseData("invalidMultipleDampingFactorExitStochast.xml",
+ "There is a duplicate key sequence 'dempingsfactor' for the 'uniqueStochastNameConstraint' key or unique identity constraint.")
+ .SetName("invalidMultipleDampingFactorExitStochast");
+ yield return new TestCaseData("invalidContainingBothAssessmentLevelAndHydraulicBoundaryLocation.xml",
+ "Element 'hrlocatie' cannot appear more than once if content model type is \"all\".")
+ .SetName("invalidContainingBothAssessmentLevelAndHydraulicBoundaryLocation");
+ yield return new TestCaseData("invalidCalculationMultipleAssessmentLevel.xml",
+ "Element 'toetspeil' cannot appear more than once if content model type is \"all\".")
+ .SetName("invalidCalculationMultipleAssessmentLevel");
+ yield return new TestCaseData("invalidCalculationMultipleHydraulicBoundaryLocation.xml",
+ "Element 'hrlocatie' cannot appear more than once if content model type is \"all\".")
+ .SetName("invalidCalculationMultipleHydraulicBoundaryLocation");
+ yield return new TestCaseData("invalidCalculationMultipleSurfaceLine.xml",
+ "Element 'profielschematisatie' cannot appear more than once if content model type is \"all\".")
+ .SetName("invalidCalculationMultipleSurfaceLine");
+ yield return new TestCaseData("invalidCalculationMultipleEntryPoint.xml",
+ "Element 'intredepunt' cannot appear more than once if content model type is \"all\".")
+ .SetName("invalidCalculationMultipleEntryPoint");
+ yield return new TestCaseData("invalidCalculationMultipleExitPoint.xml",
+ "Element 'uittredepunt' cannot appear more than once if content model type is \"all\".")
+ .SetName("invalidCalculationMultipleExitPoint");
+ yield return new TestCaseData("invalidCalculationMultipleStochasticSoilModel.xml",
+ "Element 'ondergrondmodel' cannot appear more than once if content model type is \"all\".")
+ .SetName("invalidCalculationMultipleStochasticSoilModel");
+ yield return new TestCaseData("invalidCalculationMultipleStochasticSoilProfile.xml",
+ "Element 'ondergrondschematisatie' cannot appear more than once if content model type is \"all\".")
+ .SetName("invalidCalculationMultipleStochasticSoilProfile");
+ yield return new TestCaseData("invalidCalculationMultipleStochasts.xml",
+ "Element 'stochasten' cannot appear more than once if content model type is \"all\".")
+ .SetName("invalidCalculationMultipleStochasts");
+ yield return new TestCaseData("invalidConfigurationCalculationContainingEmptyHydraulicBoundaryLocation.xml",
+ "The 'hrlocatie' element is invalid - The value '' is invalid according to its datatype 'String' - The actual length is less than the MinLength value.")
+ .SetName("invalidConfigurationCalculationContainingEmptyHydraulicBoundaryLocation");
+ yield return new TestCaseData("invalidConfigurationCalculationContainingEmptySurfaceLine.xml",
+ "The 'profielschematisatie' element is invalid - The value '' is invalid according to its datatype 'String' - The actual length is less than the MinLength value.")
+ .SetName("invalidConfigurationCalculationContainingEmptySurfaceLine");
+ yield return new TestCaseData("invalidConfigurationCalculationContainingEmptySoilModel.xml",
+ "The 'ondergrondmodel' element is invalid - The value '' is invalid according to its datatype 'String' - The actual length is less than the MinLength value.")
+ .SetName("invalidConfigurationCalculationContainingEmptySoilModel");
+ yield return new TestCaseData("invalidConfigurationCalculationContainingEmptySoilProfile.xml",
+ "The 'ondergrondschematisatie' element is invalid - The value '' is invalid according to its datatype 'String' - The actual length is less than the MinLength value.")
+ .SetName("invalidConfigurationCalculationContainingEmptySoilProfile");
+ }
+ }
+
+ [Test]
+ [TestCaseSource(nameof(InvalidConfigurations))]
+ public void Constructor_FileInvalidBasedOnSchemaDefinition_ThrowCriticalFileReadException(string fileName, string expectedParsingMessage)
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, fileName);
+
+ // Call
+ TestDelegate call = () => new PipingCalculationConfigurationReader(filePath);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.IsInstanceOf(exception.InnerException);
+ StringAssert.Contains(expectedParsingMessage, exception.InnerException?.Message);
+ }
+
+ [Test]
+ public void Constructor_ValidConfiguration_ExpectedValues()
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, "validConfigurationEmptyCalculation.xml");
+
+ // Call
+ var reader = new PipingCalculationConfigurationReader(filePath);
+
+ // Assert
+ Assert.IsInstanceOf>(reader);
+ }
+
+ [Test]
+ public void Read_ValidConfigurationWithEmptyCalculation_ReturnExpectedReadPipingCalculation()
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, "validConfigurationEmptyCalculation.xml");
+ var reader = new PipingCalculationConfigurationReader(filePath);
+
+ // Call
+ IList readConfigurationItems = reader.Read().ToList();
+
+ // Assert
+ Assert.AreEqual(1, readConfigurationItems.Count);
+
+ var calculation = (PipingCalculationConfiguration) readConfigurationItems[0];
+ Assert.AreEqual("Calculation", calculation.Name);
+ Assert.IsNull(calculation.AssessmentLevel);
+ Assert.IsNull(calculation.HydraulicBoundaryLocation);
+ Assert.IsNull(calculation.SurfaceLine);
+ Assert.IsNull(calculation.EntryPointL);
+ Assert.IsNull(calculation.ExitPointL);
+ Assert.IsNull(calculation.StochasticSoilModel);
+ Assert.IsNull(calculation.StochasticSoilProfile);
+ Assert.IsNull(calculation.PhreaticLevelExitMean);
+ Assert.IsNull(calculation.PhreaticLevelExitStandardDeviation);
+ Assert.IsNull(calculation.DampingFactorExitMean);
+ Assert.IsNull(calculation.DampingFactorExitStandardDeviation);
+ }
+
+ [Test]
+ public void Read_ValidConfigurationWithCalculationContainingEmptyStochasts_ReturnExpectedReadPipingCalculation()
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, "validConfigurationCalculationContainingEmptyStochasts.xml");
+ var reader = new PipingCalculationConfigurationReader(filePath);
+
+ // Call
+ IList readConfigurationItems = reader.Read().ToList();
+
+ // Assert
+ Assert.AreEqual(1, readConfigurationItems.Count);
+
+ var calculation = (PipingCalculationConfiguration) readConfigurationItems[0];
+ Assert.IsNull(calculation.PhreaticLevelExitMean);
+ Assert.IsNull(calculation.PhreaticLevelExitStandardDeviation);
+ Assert.IsNull(calculation.DampingFactorExitMean);
+ Assert.IsNull(calculation.DampingFactorExitStandardDeviation);
+ }
+
+ [Test]
+ public void Read_ValidConfigurationWithCalculationContainingNaNs_ReturnExpectedReadPipingCalculation()
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, "validConfigurationCalculationContainingNaNs.xml");
+ var reader = new PipingCalculationConfigurationReader(filePath);
+
+ // Call
+ IList readConfigurationItems = reader.Read().ToList();
+
+ // Assert
+ Assert.AreEqual(1, readConfigurationItems.Count);
+
+ var calculation = (PipingCalculationConfiguration) readConfigurationItems[0];
+ Assert.IsNaN(calculation.AssessmentLevel);
+ Assert.IsNaN(calculation.EntryPointL);
+ Assert.IsNaN(calculation.ExitPointL);
+ Assert.IsNaN(calculation.PhreaticLevelExitMean);
+ Assert.IsNaN(calculation.PhreaticLevelExitStandardDeviation);
+ Assert.IsNaN(calculation.DampingFactorExitMean);
+ Assert.IsNaN(calculation.DampingFactorExitStandardDeviation);
+ }
+
+ [Test]
+ public void Read_ValidConfigurationWithCalculationContainingInfinities_ReturnExpectedReadPipingCalculation()
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, "validConfigurationCalculationContainingInfinities.xml");
+ var reader = new PipingCalculationConfigurationReader(filePath);
+
+ // Call
+ IList readConfigurationItems = reader.Read().ToList();
+
+ // Assert
+ Assert.AreEqual(1, readConfigurationItems.Count);
+
+ var calculation = (PipingCalculationConfiguration) readConfigurationItems[0];
+
+ Assert.IsNotNull(calculation.AssessmentLevel);
+ Assert.IsNotNull(calculation.EntryPointL);
+ Assert.IsNotNull(calculation.ExitPointL);
+ Assert.IsNotNull(calculation.PhreaticLevelExitMean);
+ Assert.IsNotNull(calculation.PhreaticLevelExitStandardDeviation);
+ Assert.IsNotNull(calculation.DampingFactorExitMean);
+ Assert.IsNotNull(calculation.DampingFactorExitStandardDeviation);
+
+ Assert.IsTrue(double.IsNegativeInfinity(calculation.AssessmentLevel.Value));
+ Assert.IsTrue(double.IsNegativeInfinity(calculation.EntryPointL.Value));
+ Assert.IsTrue(double.IsPositiveInfinity(calculation.ExitPointL.Value));
+ Assert.IsTrue(double.IsNegativeInfinity(calculation.PhreaticLevelExitMean.Value));
+ Assert.IsTrue(double.IsPositiveInfinity(calculation.PhreaticLevelExitStandardDeviation.Value));
+ Assert.IsTrue(double.IsPositiveInfinity(calculation.DampingFactorExitMean.Value));
+ Assert.IsTrue(double.IsPositiveInfinity(calculation.DampingFactorExitStandardDeviation.Value));
+ }
+
+ [Test]
+ [TestCase("validConfigurationFullCalculationContainingHydraulicBoundaryLocation.xml",
+ TestName = "Read_ValidConfigurationWithFullCalculationContainingHydraulicBoundaryLocation_ReturnPipingCalculation(HydraulicBoundaryLocation)")]
+ [TestCase("validConfigurationFullCalculationContainingHydraulicBoundaryLocation_differentOrder.xml",
+ TestName = "Read_ValidConfigurationWithFullCalculationContainingHydraulicBoundaryLocation_ReturnPipingCalculation(HydraulicBoundaryLocation_differentOrder)")]
+ public void Read_ValidConfigurationWithFullCalculationContainingHydraulicBoundaryLocation_ReturnExpectedReadPipingCalculation(string fileName)
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, fileName);
+ var reader = new PipingCalculationConfigurationReader(filePath);
+
+ // Call
+ IList readConfigurationItems = reader.Read().ToList();
+
+ // Assert
+ Assert.AreEqual(1, readConfigurationItems.Count);
+
+ var calculation = (PipingCalculationConfiguration) readConfigurationItems[0];
+ Assert.AreEqual("Calculation", calculation.Name);
+ Assert.IsNull(calculation.AssessmentLevel);
+ Assert.AreEqual("HRlocatie", calculation.HydraulicBoundaryLocation);
+ Assert.AreEqual("Profielschematisatie", calculation.SurfaceLine);
+ Assert.AreEqual(2.2, calculation.EntryPointL);
+ Assert.AreEqual(3.3, calculation.ExitPointL);
+ Assert.AreEqual("Ondergrondmodel", calculation.StochasticSoilModel);
+ Assert.AreEqual("Ondergrondschematisatie", calculation.StochasticSoilProfile);
+ Assert.AreEqual(4.4, calculation.PhreaticLevelExitMean);
+ Assert.AreEqual(5.5, calculation.PhreaticLevelExitStandardDeviation);
+ Assert.AreEqual(6.6, calculation.DampingFactorExitMean);
+ Assert.AreEqual(7.7, calculation.DampingFactorExitStandardDeviation);
+ }
+
+ [Test]
+ [TestCase("validConfigurationFullCalculationContainingAssessmentLevel.xml",
+ TestName = "Read_ValidConfigurationWithFullCalculationContainingAssessmentLevel_ReturnPipingCalculation(AssessmentLevel)")]
+ [TestCase("validConfigurationFullCalculationContainingAssessmentLevel_differentOrder.xml",
+ TestName = "Read_ValidConfigurationWithFullCalculationContainingAssessmentLevel_ReturnPipingCalculation(AssessmentLevel_differentOrder)")]
+ public void Read_ValidConfigurationWithFullCalculationContainingAssessmentLevel_ReturnExpectedReadPipingCalculation(string fileName)
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, fileName);
+ var reader = new PipingCalculationConfigurationReader(filePath);
+
+ // Call
+ IList readConfigurationItems = reader.Read().ToList();
+
+ // Assert
+ Assert.AreEqual(1, readConfigurationItems.Count);
+
+ var calculation = (PipingCalculationConfiguration) readConfigurationItems[0];
+ Assert.AreEqual("Calculation", calculation.Name);
+ Assert.AreEqual(1.1, calculation.AssessmentLevel);
+ Assert.IsNull(calculation.HydraulicBoundaryLocation);
+ Assert.AreEqual("Profielschematisatie", calculation.SurfaceLine);
+ Assert.AreEqual(2.2, calculation.EntryPointL);
+ Assert.AreEqual(3.3, calculation.ExitPointL);
+ Assert.AreEqual("Ondergrondmodel", calculation.StochasticSoilModel);
+ Assert.AreEqual("Ondergrondschematisatie", calculation.StochasticSoilProfile);
+ Assert.AreEqual(4.4, calculation.PhreaticLevelExitMean);
+ Assert.AreEqual(5.5, calculation.PhreaticLevelExitStandardDeviation);
+ Assert.AreEqual(6.6, calculation.DampingFactorExitMean);
+ Assert.AreEqual(7.7, calculation.DampingFactorExitStandardDeviation);
+ }
+
+ [Test]
+ public void Read_ValidConfigurationWithPartialCalculation_ReturnExpectedReadPipingCalculation()
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, "validConfigurationPartialCalculation.xml");
+ var reader = new PipingCalculationConfigurationReader(filePath);
+
+ // Call
+ IList readConfigurationItems = reader.Read().ToList();
+
+ // Assert
+ Assert.AreEqual(1, readConfigurationItems.Count);
+
+ var calculation = (PipingCalculationConfiguration) readConfigurationItems[0];
+ Assert.AreEqual("Calculation", calculation.Name);
+ Assert.AreEqual(1.1, calculation.AssessmentLevel);
+ Assert.IsNull(calculation.HydraulicBoundaryLocation);
+ Assert.IsNull(calculation.SurfaceLine);
+ Assert.IsNull(calculation.EntryPointL);
+ Assert.AreEqual(2.2, calculation.ExitPointL);
+ Assert.IsNull(calculation.StochasticSoilModel);
+ Assert.AreEqual("Ondergrondschematisatie", calculation.StochasticSoilProfile);
+ Assert.AreEqual(3.3, calculation.PhreaticLevelExitMean);
+ Assert.AreEqual(4.4, calculation.PhreaticLevelExitStandardDeviation);
+ Assert.IsNull(calculation.DampingFactorExitMean);
+ Assert.IsNull(calculation.DampingFactorExitStandardDeviation);
+ }
+
+ [Test]
+ public void Read_ValidConfigurationWithMissingStochastMean_ExpectedValues()
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, "validConfigurationStochastsNoMean.xml");
+ var reader = new PipingCalculationConfigurationReader(filePath);
+
+ // Call
+ IList readConfigurationItems = reader.Read().ToList();
+
+ // Assert
+ Assert.AreEqual(1, readConfigurationItems.Count);
+
+ var calculation = (PipingCalculationConfiguration) readConfigurationItems[0];
+ Assert.IsNull(calculation.PhreaticLevelExitMean);
+ Assert.AreEqual(0.1, calculation.PhreaticLevelExitStandardDeviation);
+ Assert.IsNull(calculation.DampingFactorExitMean);
+ Assert.AreEqual(7.7, calculation.DampingFactorExitStandardDeviation);
+ }
+
+ [Test]
+ public void Read_ValidConfigurationWithMissingStochastStandardDeviation_ExpectedValues()
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, "validConfigurationStochastsNoStandardDeviation.xml");
+ var reader = new PipingCalculationConfigurationReader(filePath);
+
+ // Call
+ IList readConfigurationItems = reader.Read().ToList();
+
+ // Assert
+ Assert.AreEqual(1, readConfigurationItems.Count);
+
+ var calculation = (PipingCalculationConfiguration) readConfigurationItems[0];
+ Assert.AreEqual(0.0, calculation.PhreaticLevelExitMean);
+ Assert.IsNull(calculation.PhreaticLevelExitStandardDeviation);
+ Assert.AreEqual(6.6, calculation.DampingFactorExitMean);
+ Assert.IsNull(calculation.DampingFactorExitStandardDeviation);
+ }
+
+ [Test]
+ public void Read_ValidConfigurationWithEmptyStochast_ExpectedValues()
+ {
+ // Setup
+ string filePath = Path.Combine(testDirectoryPath, "validConfigurationEmptyStochasts.xml");
+ var reader = new PipingCalculationConfigurationReader(filePath);
+
+ // Call
+ IList readConfigurationItems = reader.Read().ToList();
+
+ // Assert
+ Assert.AreEqual(1, readConfigurationItems.Count);
+
+ var calculation = (PipingCalculationConfiguration) readConfigurationItems[0];
+ Assert.IsNull(calculation.PhreaticLevelExitMean);
+ Assert.IsNull(calculation.PhreaticLevelExitStandardDeviation);
+ Assert.IsNull(calculation.DampingFactorExitMean);
+ Assert.IsNull(calculation.DampingFactorExitStandardDeviation);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationSchemaIdentifiersTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationSchemaIdentifiersTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationSchemaIdentifiersTest.cs (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -0,0 +1,43 @@
+// Copyright (C) Stichting Deltares 2017. 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 NUnit.Framework;
+using Ringtoets.Piping.IO.Configurations;
+
+namespace Ringtoets.Piping.IO.Test.Configurations
+{
+ [TestFixture]
+ public class PipingCalculationConfigurationSchemaIdentifiersTest
+ {
+ [Test]
+ public void PipingCalculationConfigurationSchemaIdentifiers_ExpectedValues()
+ {
+ Assert.AreEqual("toetspeil", PipingCalculationConfigurationSchemaIdentifiers.AssessmentLevelElement);
+ Assert.AreEqual("profielschematisatie", PipingCalculationConfigurationSchemaIdentifiers.SurfaceLineElement);
+ Assert.AreEqual("intredepunt", PipingCalculationConfigurationSchemaIdentifiers.EntryPointLElement);
+ Assert.AreEqual("uittredepunt", PipingCalculationConfigurationSchemaIdentifiers.ExitPointLElement);
+ Assert.AreEqual("ondergrondmodel", PipingCalculationConfigurationSchemaIdentifiers.StochasticSoilModelElement);
+ Assert.AreEqual("ondergrondschematisatie", PipingCalculationConfigurationSchemaIdentifiers.StochasticSoilProfileElement);
+ Assert.AreEqual("polderpeil", PipingCalculationConfigurationSchemaIdentifiers.PhreaticLevelExitStochastName);
+ Assert.AreEqual("dempingsfactor", PipingCalculationConfigurationSchemaIdentifiers.DampingFactorExitStochastName);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationTest.cs (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -0,0 +1,115 @@
+// Copyright (C) Stichting Deltares 2017. 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 NUnit.Framework;
+using Ringtoets.Common.IO.Configurations;
+using Ringtoets.Piping.IO.Configurations;
+
+namespace Ringtoets.Piping.IO.Test.Configurations
+{
+ [TestFixture]
+ public class PipingCalculationConfigurationTest
+ {
+ [Test]
+ public void Constructor_WithoutConstructionProperties_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new PipingCalculationConfiguration(null);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Constructor_ConstructionPropertiesWithoutValues_PropertiesAreDefault()
+ {
+ // Setup
+ var name = "some name";
+
+ // Call
+ var readPipingCalculation = new PipingCalculationConfiguration(name);
+
+ // Assert
+ Assert.IsInstanceOf(readPipingCalculation);
+ Assert.AreEqual(name, readPipingCalculation.Name);
+ Assert.IsNull(readPipingCalculation.AssessmentLevel);
+ Assert.IsNull(readPipingCalculation.HydraulicBoundaryLocation);
+ Assert.IsNull(readPipingCalculation.SurfaceLine);
+ Assert.IsNull(readPipingCalculation.EntryPointL);
+ Assert.IsNull(readPipingCalculation.ExitPointL);
+ Assert.IsNull(readPipingCalculation.StochasticSoilModel);
+ Assert.IsNull(readPipingCalculation.StochasticSoilProfile);
+ Assert.IsNull(readPipingCalculation.PhreaticLevelExitMean);
+ Assert.IsNull(readPipingCalculation.PhreaticLevelExitStandardDeviation);
+ Assert.IsNull(readPipingCalculation.DampingFactorExitMean);
+ Assert.IsNull(readPipingCalculation.DampingFactorExitStandardDeviation);
+ }
+
+ [Test]
+ public void Constructor_ConstructionPropertiesWithValuesSet_PropertiesAsExpected()
+ {
+ // Setup
+ const string calculationName = "Name of the calculation";
+ const double assessmentLevel = 1.1;
+ const string hydraulicBoundaryLocation = "Name of the hydraulic boundary location";
+ const string surfaceLine = "Name of the surface line";
+ const double entryPointL = 2.2;
+ const double exitPointL = 3.3;
+ const string stochasticSoilModel = "Name of the stochastic soil model";
+ const string stochasticSoilProfile = "Name of the stochastic soil profile";
+ const double phreaticLevelExitMean = 4.4;
+ const double phreaticLevelExitStandardDeviation = 5.5;
+ const double dampingFactorExitMean = 6.6;
+ const double dampingFactorExitStandardDeviation = 7.7;
+
+ // Call
+ var readPipingCalculation = new PipingCalculationConfiguration(calculationName)
+ {
+ AssessmentLevel = assessmentLevel,
+ HydraulicBoundaryLocation = hydraulicBoundaryLocation,
+ SurfaceLine = surfaceLine,
+ EntryPointL = entryPointL,
+ ExitPointL = exitPointL,
+ StochasticSoilModel = stochasticSoilModel,
+ StochasticSoilProfile = stochasticSoilProfile,
+ PhreaticLevelExitMean = phreaticLevelExitMean,
+ PhreaticLevelExitStandardDeviation = phreaticLevelExitStandardDeviation,
+ DampingFactorExitMean = dampingFactorExitMean,
+ DampingFactorExitStandardDeviation = dampingFactorExitStandardDeviation
+ };
+
+ // Assert
+ Assert.AreEqual(calculationName, readPipingCalculation.Name);
+ Assert.AreEqual(assessmentLevel, readPipingCalculation.AssessmentLevel);
+ Assert.AreEqual(hydraulicBoundaryLocation, readPipingCalculation.HydraulicBoundaryLocation);
+ Assert.AreEqual(surfaceLine, readPipingCalculation.SurfaceLine);
+ Assert.AreEqual(entryPointL, readPipingCalculation.EntryPointL);
+ Assert.AreEqual(exitPointL, readPipingCalculation.ExitPointL);
+ Assert.AreEqual(stochasticSoilModel, readPipingCalculation.StochasticSoilModel);
+ Assert.AreEqual(stochasticSoilProfile, readPipingCalculation.StochasticSoilProfile);
+ Assert.AreEqual(phreaticLevelExitMean, readPipingCalculation.PhreaticLevelExitMean);
+ Assert.AreEqual(phreaticLevelExitStandardDeviation, readPipingCalculation.PhreaticLevelExitStandardDeviation);
+ Assert.AreEqual(dampingFactorExitMean, readPipingCalculation.DampingFactorExitMean);
+ Assert.AreEqual(dampingFactorExitStandardDeviation, readPipingCalculation.DampingFactorExitStandardDeviation);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationWriterTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationWriterTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Configurations/PipingCalculationConfigurationWriterTest.cs (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -0,0 +1,168 @@
+// Copyright (C) Stichting Deltares 2017. 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.Collections.Generic;
+using System.IO;
+using Core.Common.Base.Data;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.IO.TestUtil;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Integration.TestUtils;
+using Ringtoets.Piping.IO.Configurations;
+using Ringtoets.Piping.Primitives;
+
+namespace Ringtoets.Piping.IO.Test.Configurations
+{
+ [TestFixture]
+ public class PipingCalculationConfigurationWriterTest
+ : CustomCalculationConfigurationWriterDesignGuidelinesTestFixture<
+ PipingCalculationConfigurationWriter,
+ PipingCalculation>
+ {
+ private static IEnumerable Calculations
+ {
+ get
+ {
+ yield return new TestCaseData("calculationWithoutHydraulicLocation",
+ PipingTestDataGenerator.GetPipingCalculationWithoutHydraulicLocationAndAssessmentLevel())
+ .SetName("calculationWithoutHydraulicLocation");
+ yield return new TestCaseData("calculationWithAssessmentLevel",
+ PipingTestDataGenerator.GetPipingCalculationWithAssessmentLevel())
+ .SetName("calculationWithAssessmentLevel");
+ yield return new TestCaseData("calculationWithoutSurfaceLine",
+ PipingTestDataGenerator.GetPipingCalculationWithoutSurfaceLine())
+ .SetName("calculationWithoutSurfaceLine");
+ yield return new TestCaseData("calculationWithoutSoilModel",
+ PipingTestDataGenerator.GetPipingCalculationWithoutSoilModel())
+ .SetName("calculationWithoutSoilModel");
+ yield return new TestCaseData("calculationWithoutSoilProfile",
+ PipingTestDataGenerator.GetPipingCalculationWithoutSoilProfile())
+ .SetName("calculationWithoutSoilProfile");
+ yield return new TestCaseData("calculationWithNaNs",
+ PipingTestDataGenerator.GetPipingCalculationWithNaNs())
+ .SetName("calculationWithNaNs");
+ yield return new TestCaseData("calculationWithInfinities",
+ PipingTestDataGenerator.GetPipingCalculationWithInfinities())
+ .SetName("calculationWithInfinities");
+ }
+ }
+
+ [Test]
+ public void Write_CalculationGroupsAndCalculation_ValidFile()
+ {
+ // Setup
+ string filePath = TestHelper.GetScratchPadPath("test.xml");
+
+ PipingCalculation calculation = PipingTestDataGenerator.GetPipingCalculation();
+ calculation.InputParameters.EntryPointL = (RoundedDouble) 0.1;
+ calculation.InputParameters.ExitPointL = (RoundedDouble) 0.2;
+
+ PipingCalculation calculation2 = PipingTestDataGenerator.GetPipingCalculation();
+ calculation2.Name = "PK001_0002 W1-6_4_1D1";
+ calculation2.InputParameters.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "PUNT_SCH_17", 0, 0);
+ calculation2.InputParameters.SurfaceLine.Name = "PK001_0002";
+ calculation2.InputParameters.EntryPointL = (RoundedDouble) 0.3;
+ calculation2.InputParameters.ExitPointL = (RoundedDouble) 0.4;
+ calculation2.InputParameters.StochasticSoilModel = new StochasticSoilModel(1, "PK001_0002_Piping", string.Empty);
+ calculation2.InputParameters.StochasticSoilProfile = new StochasticSoilProfile(0, SoilProfileType.SoilProfile1D, 0)
+ {
+ SoilProfile = new PipingSoilProfile("W1-6_4_1D1", 0, new[]
+ {
+ new PipingSoilLayer(0)
+ }, SoilProfileType.SoilProfile1D, 0)
+ };
+
+ var calculationGroup2 = new CalculationGroup("PK001_0002", false)
+ {
+ Children =
+ {
+ calculation2
+ }
+ };
+
+ var calculationGroup = new CalculationGroup("PK001_0001", false)
+ {
+ Children =
+ {
+ calculation,
+ calculationGroup2
+ }
+ };
+
+ try
+ {
+ // Call
+ new PipingCalculationConfigurationWriter().Write(new[]
+ {
+ calculationGroup
+ }, filePath);
+
+ // Assert
+ Assert.IsTrue(File.Exists(filePath));
+
+ string actualXml = File.ReadAllText(filePath);
+ string expectedXmlFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO,
+ Path.Combine("PipingCalculationConfigurationWriter",
+ "folderWithSubfolderAndCalculation.xml"));
+ string expectedXml = File.ReadAllText(expectedXmlFilePath);
+
+ Assert.AreEqual(expectedXml, actualXml);
+ }
+ finally
+ {
+ File.Delete(filePath);
+ }
+ }
+
+ [Test]
+ [TestCaseSource(nameof(Calculations))]
+ public void Write_ValidCalculation_ValidFile(string expectedFileName, PipingCalculation calculation)
+ {
+ // Setup
+ string filePath = TestHelper.GetScratchPadPath("test.xml");
+
+ try
+ {
+ // Call
+ new PipingCalculationConfigurationWriter().Write(new[]
+ {
+ calculation
+ }, filePath);
+
+ // Assert
+ Assert.IsTrue(File.Exists(filePath));
+
+ string actualXml = File.ReadAllText(filePath);
+ string expectedXmlFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, Path.Combine("PipingCalculationConfigurationWriter", $"{expectedFileName}.xml"));
+ string expectedXml = File.ReadAllText(expectedXmlFilePath);
+
+ Assert.AreEqual(expectedXml, actualXml);
+ }
+ finally
+ {
+ File.Delete(filePath);
+ }
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 6df044b18d205d87d4f38a623cc6e29146d4e95e refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Exporters/PipingCalculationConfigurationExporterTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 6df044b18d205d87d4f38a623cc6e29146d4e95e refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Exporters/PipingCalculationConfigurationWriterTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 6df044b18d205d87d4f38a623cc6e29146d4e95e refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingCalculationConfigurationImporterTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 6df044b18d205d87d4f38a623cc6e29146d4e95e refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Readers/PipingCalculationConfigurationReaderTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 6df044b18d205d87d4f38a623cc6e29146d4e95e refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Readers/ReadPipingCalculationTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj
===================================================================
diff -u -r50597fbeb76b752bc250107dfa91b696bb6c4995 -r6df044b18d205d87d4f38a623cc6e29146d4e95e
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 50597fbeb76b752bc250107dfa91b696bb6c4995)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -72,12 +72,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
Fisheye: Tag 6df044b18d205d87d4f38a623cc6e29146d4e95e refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Schema/PipingCalculationConfigurationSchemaIdentifiersTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationContextExportInfoTest.cs
===================================================================
diff -u -rc4e2a1db42a818567d116298b5c163b56b69ce0e -r6df044b18d205d87d4f38a623cc6e29146d4e95e
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationContextExportInfoTest.cs (.../PipingCalculationContextExportInfoTest.cs) (revision c4e2a1db42a818567d116298b5c163b56b69ce0e)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationContextExportInfoTest.cs (.../PipingCalculationContextExportInfoTest.cs) (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -29,7 +29,7 @@
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.Forms.PresentationObjects;
-using Ringtoets.Piping.IO.Exporters;
+using Ringtoets.Piping.IO.Configurations;
using Ringtoets.Piping.Primitives;
using CoreCommonGuiResources = Core.Common.Gui.Properties.Resources;
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationGroupContextExportInfoTest.cs
===================================================================
diff -u -rc4e2a1db42a818567d116298b5c163b56b69ce0e -r6df044b18d205d87d4f38a623cc6e29146d4e95e
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationGroupContextExportInfoTest.cs (.../PipingCalculationGroupContextExportInfoTest.cs) (revision c4e2a1db42a818567d116298b5c163b56b69ce0e)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationGroupContextExportInfoTest.cs (.../PipingCalculationGroupContextExportInfoTest.cs) (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -30,7 +30,7 @@
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.Forms.PresentationObjects;
-using Ringtoets.Piping.IO.Exporters;
+using Ringtoets.Piping.IO.Configurations;
using Ringtoets.Piping.Primitives;
using CoreCommonGuiResources = Core.Common.Gui.Properties.Resources;
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/PipingCalculationGroupContextImportInfoTest.cs
===================================================================
diff -u -rc4e2a1db42a818567d116298b5c163b56b69ce0e -r6df044b18d205d87d4f38a623cc6e29146d4e95e
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/PipingCalculationGroupContextImportInfoTest.cs (.../PipingCalculationGroupContextImportInfoTest.cs) (revision c4e2a1db42a818567d116298b5c163b56b69ce0e)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/PipingCalculationGroupContextImportInfoTest.cs (.../PipingCalculationGroupContextImportInfoTest.cs) (revision 6df044b18d205d87d4f38a623cc6e29146d4e95e)
@@ -32,6 +32,7 @@
using Ringtoets.Common.Data.TestUtil;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.Forms.PresentationObjects;
+using Ringtoets.Piping.IO.Configurations;
using Ringtoets.Piping.IO.Importers;
using Ringtoets.Piping.Primitives;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;