Index: Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/CalculationConfigurationGroup.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/CalculationConfigurationGroup.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/CalculationConfigurationGroup.cs (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -0,0 +1,50 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Collections.Generic; +using Ringtoets.Common.IO.Readers; + +namespace Ringtoets.Common.IO.Configurations +{ + /// + /// Class that represents a calculation group that is read via . + /// + public class CalculationConfigurationGroup : IConfigurationItem + { + /// + /// Creates a new instance of . + /// + /// The name of the calculation group. + /// The collection of nested . + public CalculationConfigurationGroup(string name, IEnumerable items) + { + Name = name; + Items = items; + } + + /// + /// Gets the collection of nested . + /// + public IEnumerable Items { get; private set; } + + public string Name { get; } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/IConfigurationItem.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/IConfigurationItem.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/IConfigurationItem.cs (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -0,0 +1,34 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.Common.IO.Configurations +{ + /// + /// Interface for configuration items that are read or written. + /// + public interface IConfigurationItem + { + /// + /// Gets the name of the read configuration item. + /// + string Name { get; } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/StructureCalculationConfiguration.cs =================================================================== diff -u -r2e8cb240a4a86135989a372887d8b9b1043bfb2d -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/StructureCalculationConfiguration.cs (.../StructureCalculationConfiguration.cs) (revision 2e8cb240a4a86135989a372887d8b9b1043bfb2d) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/StructureCalculationConfiguration.cs (.../StructureCalculationConfiguration.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -20,13 +20,14 @@ // All rights reserved. using System; +using Ringtoets.Common.IO.Readers; namespace Ringtoets.Common.IO.Configurations { /// /// Configuration of a structure calculation. /// - public abstract class StructureCalculationConfiguration + public abstract class StructureCalculationConfiguration : IConfigurationItem { private string name; Index: Ringtoets/Common/src/Ringtoets.Common.IO/Exporters/SchemaCalculationConfigurationExporter.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/Exporters/SchemaCalculationConfigurationExporter.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Exporters/SchemaCalculationConfigurationExporter.cs (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -0,0 +1,120 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Core.Common.Base.IO; +using Core.Common.IO.Exceptions; +using log4net; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.IO.Configurations; +using Ringtoets.Common.IO.Properties; +using Ringtoets.Common.IO.Readers; +using Ringtoets.Common.IO.Writers; + +namespace Ringtoets.Common.IO.Exporters +{ + /// + /// Base class for exporting a calculation configuration and storing it as an XML file. + /// + /// The + /// to use for exporting . + /// The type to export. + /// The type of the calculations after conversion for writing. + public abstract class SchemaCalculationConfigurationExporter : IFileExporter + where TWriter : SchemaCalculationConfigurationWriter + where TCalculation : class, ICalculation + where TConfiguration : class, IConfigurationItem + { + private static readonly ILog log = LogManager.GetLogger(typeof(SchemaCalculationConfigurationExporter)); + private readonly IEnumerable configuration; + private readonly TWriter writer; + + /// + /// 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. + protected SchemaCalculationConfigurationExporter(IEnumerable calculations, string filePath) + { + if (calculations == null) + { + throw new ArgumentNullException(nameof(calculations)); + } + + writer = (TWriter) Activator.CreateInstance(typeof(TWriter), filePath); + configuration = ToConfiguration(calculations); + } + + public bool Export() + { + try + { + writer.Write(configuration); + } + catch (CriticalFileWriteException e) + { + log.ErrorFormat(Resources.CalculationConfigurationExporter_Export_Exception_0_no_configuration_exported, e.Message); + return false; + } + + return true; + } + + /// + /// Converts the to a . + /// + /// The to convert. + /// A new instance of with values set equal + /// to properties of . + protected abstract TConfiguration ToConfiguration(TCalculation calculation); + + private IEnumerable ToConfiguration(IEnumerable calculations) + { + foreach (ICalculationBase child in calculations) + { + var innerGroup = child as CalculationGroup; + if (innerGroup != null) + { + yield return ToConfiguration(innerGroup); + } + + var calculation = child as TCalculation; + if (calculation != null) + { + yield return ToConfiguration(calculation); + } + + if (innerGroup == null && calculation == null) + { + throw new ArgumentException($"Cannot export calculation of type '{child.GetType()}' using this exporter."); + } + } + } + + private CalculationConfigurationGroup ToConfiguration(CalculationGroup group) + { + return new CalculationConfigurationGroup(group.Name, ToConfiguration(group.Children)); + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/CalculationConfigurationImporter.cs =================================================================== diff -u -rd347acb3d57c61fd3baa1e883551807417db6698 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/CalculationConfigurationImporter.cs (.../CalculationConfigurationImporter.cs) (revision d347acb3d57c61fd3baa1e883551807417db6698) +++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/CalculationConfigurationImporter.cs (.../CalculationConfigurationImporter.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -26,6 +26,7 @@ using Core.Common.IO.Readers; using log4net; using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Properties; using Ringtoets.Common.IO.Readers; @@ -39,7 +40,7 @@ public abstract class CalculationConfigurationImporter : FileImporterBase where TCalculationConfigurationReader : CalculationConfigurationReader - where TReadCalculation : class, IReadConfigurationItem + where TReadCalculation : class, IConfigurationItem { private static readonly ILog log = LogManager.GetLogger(typeof(CalculationConfigurationImporter)); @@ -61,7 +62,7 @@ { NotifyProgress(Resources.CalculationConfigurationImporter_ProgressText_Reading_configuration, 1, 3); - ReadResult readResult = ReadConfiguration(); + ReadResult readResult = ReadConfiguration(); if (readResult.CriticalErrorOccurred || Canceled) { return false; @@ -71,7 +72,7 @@ var parsedCalculationItems = new List(); - foreach (IReadConfigurationItem readItem in readResult.Items) + foreach (IConfigurationItem readItem in readResult.Items) { if (Canceled) { @@ -126,11 +127,11 @@ message, calculationName); } - private ReadResult ReadConfiguration() + private ReadResult ReadConfiguration() { try { - return new ReadResult(false) + return new ReadResult(false) { Items = CreateCalculationConfigurationReader(FilePath).Read().ToList() }; @@ -141,7 +142,7 @@ string errorMessage = string.Format(Resources.CalculationConfigurationImporter_HandleCriticalFileReadError_Error_0_no_configuration_imported, exception.Message); log.Error(errorMessage, exception); - return new ReadResult(true); + return new ReadResult(true); } } @@ -151,9 +152,9 @@ /// The read item to parse. /// A parsed calculation item. /// Thrown when the item to parse is not valid. - private ICalculationBase ParseReadConfigurationItem(IReadConfigurationItem readConfigurationItem) + private ICalculationBase ParseReadConfigurationItem(IConfigurationItem readConfigurationItem) { - var readCalculationGroup = readConfigurationItem as ReadCalculationGroup; + var readCalculationGroup = readConfigurationItem as CalculationConfigurationGroup; if (readCalculationGroup != null) { return ParseReadCalculationGroup(readCalculationGroup); @@ -175,11 +176,11 @@ /// A parsed calculation group. /// Thrown when the one of the children /// to parse is not valid. - private CalculationGroup ParseReadCalculationGroup(ReadCalculationGroup readCalculationGroup) + private CalculationGroup ParseReadCalculationGroup(CalculationConfigurationGroup readCalculationGroup) { var calculationGroup = new CalculationGroup(readCalculationGroup.Name, true); - foreach (IReadConfigurationItem item in readCalculationGroup.Items) + foreach (IConfigurationItem item in readCalculationGroup.Items) { ICalculationBase parsedItem = ParseReadConfigurationItem(item); if (parsedItem != null) Index: Ringtoets/Common/src/Ringtoets.Common.IO/Readers/CalculationConfigurationReader.cs =================================================================== diff -u -r7abe7a22648e3af0a350e60b21e3c61bb5fb6124 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Common/src/Ringtoets.Common.IO/Readers/CalculationConfigurationReader.cs (.../CalculationConfigurationReader.cs) (revision 7abe7a22648e3af0a350e60b21e3c61bb5fb6124) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Readers/CalculationConfigurationReader.cs (.../CalculationConfigurationReader.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -29,6 +29,7 @@ using Core.Common.Base.IO; using Core.Common.Utils; using Core.Common.Utils.Builders; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Properties; using Ringtoets.Common.IO.Schema; using CoreCommonUtilsResources = Core.Common.Utils.Properties.Resources; @@ -37,11 +38,11 @@ { /// /// Base class for reading a calculation configuration from XML and creating a collection of corresponding - /// , typically containing one or more . + /// , typically containing one or more . /// /// The type of calculation items read from XML. public abstract class CalculationConfigurationReader - where TReadCalculation : IReadConfigurationItem + where TReadCalculation : IConfigurationItem { private const string defaultSchemaName = "ConfiguratieSchema.xsd"; @@ -93,10 +94,10 @@ } /// - /// Reads the calculation configuration from the XML and creates a collection of corresponding . + /// Reads the calculation configuration from the XML and creates a collection of corresponding . /// - /// A collection of read . - public IEnumerable Read() + /// A collection of read . + public IEnumerable Read() { return ParseElements(xmlDocument.Root?.Elements()); } @@ -211,7 +212,7 @@ } } - private IEnumerable ParseElements(IEnumerable elements) + private IEnumerable ParseElements(IEnumerable elements) { foreach (XElement element in elements) { @@ -227,9 +228,9 @@ } } - private ReadCalculationGroup ParseFolderElement(XElement folderElement) + private CalculationConfigurationGroup ParseFolderElement(XElement folderElement) { - return new ReadCalculationGroup(folderElement.Attribute(ConfigurationSchemaIdentifiers.NameAttribute)?.Value, + return new CalculationConfigurationGroup(folderElement.Attribute(ConfigurationSchemaIdentifiers.NameAttribute)?.Value, ParseElements(folderElement.Elements())); } } Fisheye: Tag cc1268d7cb906524d4cabcd4cbd9ae16676cf059 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.IO/Readers/IReadConfigurationItem.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag cc1268d7cb906524d4cabcd4cbd9ae16676cf059 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.IO/Readers/ReadCalculationGroup.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj =================================================================== diff -u -r3c686d6ea57d86134a4338e75d3c7663f379716e -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 3c686d6ea57d86134a4338e75d3c7663f379716e) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -54,6 +54,7 @@ + @@ -89,8 +90,7 @@ - - + @@ -106,6 +106,7 @@ + @@ -116,8 +117,9 @@ + - + Index: Ringtoets/Common/src/Ringtoets.Common.IO/Writers/SchemaCalculationConfigurationWriter.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/Writers/SchemaCalculationConfigurationWriter.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Writers/SchemaCalculationConfigurationWriter.cs (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -0,0 +1,146 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.Xml; +using Core.Common.IO.Exceptions; +using Core.Common.Utils; +using Core.Common.Utils.Properties; +using Ringtoets.Common.IO.Configurations; +using Ringtoets.Common.IO.Readers; +using Ringtoets.Common.IO.Schema; + +namespace Ringtoets.Common.IO.Writers +{ + /// + /// Base implementation of writing calculation configurations to XML. + /// + /// The type of calculations which are written to file. + public abstract class SchemaCalculationConfigurationWriter where T : class, IConfigurationItem + { + private readonly string filePath; + + /// + /// Creates a new instance of . + /// + /// The path of the file to write to. + /// Thrown when is invalid. + /// A valid path: + /// + /// is not empty or null, + /// does not consist out of only whitespace characters, + /// does not contain an invalid character, + /// does not end with a directory or path separator (empty file name). + /// + protected SchemaCalculationConfigurationWriter(string filePath) + { + this.filePath = filePath; + IOUtils.ValidateFilePath(filePath); + } + + /// + /// Writes a calculation configuration to an XML file. + /// + /// The calculation configuration to write. + /// Thrown when any parameter is null. + /// Thrown when unable to write the file to the file path provided to + /// the . + public void Write(IEnumerable configuration) + { + if (configuration == null) + { + throw new ArgumentNullException(nameof(configuration)); + } + + try + { + var settings = new XmlWriterSettings + { + Indent = true + }; + + using (XmlWriter writer = XmlWriter.Create(filePath, settings)) + { + writer.WriteStartDocument(); + writer.WriteStartElement(ConfigurationSchemaIdentifiers.ConfigurationElement); + + WriteConfiguration(configuration, writer); + + writer.WriteEndElement(); + writer.WriteEndDocument(); + } + } + catch (SystemException e) + { + throw new CriticalFileWriteException(string.Format(Resources.Error_General_output_error_0, filePath), e); + } + } + + /// + /// Writes a single in XML format to file. + /// + /// The calculation to write. + /// The writer to use for writing. + /// Thrown when the is closed. + protected abstract void WriteCalculation(T calculation, XmlWriter writer); + + /// + /// Writes the in XML format to file. + /// + /// The calculation group(s) and/or calculation(s) to write. + /// The writer to use for writing. + /// Thrown when + /// contains a value that is neither nor . + private void WriteConfiguration(IEnumerable configuration, XmlWriter writer) + { + foreach (IConfigurationItem child in configuration) + { + var innerGroup = child as CalculationConfigurationGroup; + if (innerGroup != null) + { + WriteCalculationGroup(innerGroup, writer); + } + + var calculation = child as T; + if (calculation != null) + { + WriteCalculation(calculation, writer); + } + + if (innerGroup == null && calculation == null) + { + throw new ArgumentException($"Cannot write calculation of type '{child.GetType()}' using this writer."); + } + } + } + + private void WriteCalculationGroup(CalculationConfigurationGroup group, XmlWriter writer) + { + writer.WriteStartElement(ConfigurationSchemaIdentifiers.FolderElement); + writer.WriteAttributeString(ConfigurationSchemaIdentifiers.NameAttribute, group.Name); + + WriteConfiguration(group.Items, writer); + + writer.WriteEndElement(); + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/Writers/StructureCalculationConfigurationWriter.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/Writers/StructureCalculationConfigurationWriter.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Writers/StructureCalculationConfigurationWriter.cs (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -0,0 +1,150 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Xml; +using Ringtoets.Common.IO.Configurations; +using Ringtoets.Common.IO.Schema; + +namespace Ringtoets.Common.IO.Writers +{ + /// + /// Writer for writing in XML format to file. + /// + public abstract class StructureCalculationConfigurationWriter : SchemaCalculationConfigurationWriter + where T : StructureCalculationConfiguration + { + /// + /// Creates a new instance of . + /// + /// The path of the file to write to. + /// Thrown when is invalid. + /// A valid path: + /// + /// is not empty or null, + /// does not consist out of only whitespace characters, + /// does not contain an invalid character, + /// does not end with a directory or path separator (empty file name). + /// + protected StructureCalculationConfigurationWriter(string filePath) : base(filePath) {} + + protected override void WriteCalculation(T configuration, XmlWriter writer) + { + writer.WriteStartElement(ConfigurationSchemaIdentifiers.CalculationElement); + writer.WriteAttributeString(ConfigurationSchemaIdentifiers.NameAttribute, configuration.Name); + + if (configuration.HydraulicBoundaryLocationName != null) + { + writer.WriteElementString( + ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement, + configuration.HydraulicBoundaryLocationName); + } + + if (configuration.StructureName != null) + { + writer.WriteElementString( + ConfigurationSchemaIdentifiers.StructureElement, + configuration.StructureName); + } + + if (configuration.StructureNormalOrientation.HasValue) + { + writer.WriteElementString( + ConfigurationSchemaIdentifiers.Orientation, + XmlConvert.ToString(configuration.StructureNormalOrientation.Value)); + } + + if (configuration.FailureProbabilityStructureWithErosion.HasValue) + { + writer.WriteElementString( + ConfigurationSchemaIdentifiers.FailureProbabilityStructureWithErosionElement, + XmlConvert.ToString(configuration.FailureProbabilityStructureWithErosion.Value)); + } + + if (configuration.ForeshoreProfileName != null) + { + writer.WriteElementString( + ConfigurationSchemaIdentifiers.ForeshoreProfileNameElement, + configuration.ForeshoreProfileName); + } + + if (configuration.WaveReduction != null) + { + writer.WriteWaveReduction(configuration.WaveReduction); + } + + WriteSpecificStructureParameters(configuration, writer); + + writer.WriteStartElement(ConfigurationSchemaIdentifiers.StochastsElement); + + if (configuration.FlowWidthAtBottomProtection != null) + { + writer.WriteDistribution(ConfigurationSchemaIdentifiers.FlowWidthAtBottomProtectionStochastName, configuration.FlowWidthAtBottomProtection); + } + if (configuration.WidthFlowApertures != null) + { + writer.WriteDistribution(ConfigurationSchemaIdentifiers.WidthFlowAperturesStochastName, configuration.WidthFlowApertures); + } + if (configuration.StorageStructureArea != null) + { + writer.WriteDistribution(ConfigurationSchemaIdentifiers.StorageStructureAreaStochastName, configuration.StorageStructureArea); + } + if (configuration.CriticalOvertoppingDischarge != null) + { + writer.WriteDistribution(ConfigurationSchemaIdentifiers.CriticalOvertoppingDischargeStochastName, configuration.CriticalOvertoppingDischarge); + } + if (configuration.ModelFactorSuperCriticalFlow != null) + { + writer.WriteDistribution(ConfigurationSchemaIdentifiers.ModelFactorSuperCriticalFlowStochastName, configuration.ModelFactorSuperCriticalFlow); + } + if (configuration.AllowedLevelIncreaseStorage != null) + { + writer.WriteDistribution(ConfigurationSchemaIdentifiers.AllowedLevelIncreaseStorageStochastName, configuration.AllowedLevelIncreaseStorage); + } + if (configuration.StormDuration != null) + { + writer.WriteDistribution(ConfigurationSchemaIdentifiers.StormDurationStochastName, configuration.StormDuration); + } + + WriteSpecificStochasts(configuration, writer); + + writer.WriteEndElement(); + + writer.WriteEndElement(); + } + + /// + /// Writes properties specific for a structure of type . + /// + /// The instance of type for which + /// to write the input. + /// The writer that should be used to write the parameters. + protected abstract void WriteSpecificStructureParameters(T configuration, XmlWriter writer); + + /// + /// Writes stochats definitions specific for a structure of type . + /// + /// The instance of type for which + /// to write the stochasts. + /// The writer that should be used to write the parameters. + protected abstract void WriteSpecificStochasts(T configuration, XmlWriter writer); + } +} \ No newline at end of file Fisheye: Tag cc1268d7cb906524d4cabcd4cbd9ae16676cf059 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.IO/Writers/StructureCalculationConfigurationXmlWriterExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/StructureCalculationConfigurationTest.cs =================================================================== diff -u -r4011a127978bb211ddb1101a2c608ed9c991d06d -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/StructureCalculationConfigurationTest.cs (.../StructureCalculationConfigurationTest.cs) (revision 4011a127978bb211ddb1101a2c608ed9c991d06d) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Configurations/StructureCalculationConfigurationTest.cs (.../StructureCalculationConfigurationTest.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -48,6 +48,7 @@ var configuration = new SimpleStructureCalculationConfiguration(name); // Assert + Assert.IsInstanceOf(configuration); Assert.AreEqual(name, configuration.Name); Assert.IsNull(configuration.ModelFactorSuperCriticalFlow); Assert.IsNull(configuration.StructureName); Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/CalculationConfigurationImporterTest.cs =================================================================== diff -u -r3f8a98df037e5ab1623b4d786a37bf3797b85f78 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/CalculationConfigurationImporterTest.cs (.../CalculationConfigurationImporterTest.cs) (revision 3f8a98df037e5ab1623b4d786a37bf3797b85f78) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/CalculationConfigurationImporterTest.cs (.../CalculationConfigurationImporterTest.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -30,6 +30,7 @@ using NUnit.Framework; using Ringtoets.Common.Data; using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.FileImporters; using Ringtoets.Common.IO.Readers; using Ringtoets.Common.IO.Schema; @@ -240,7 +241,7 @@ } } - private class ReadCalculation : IReadConfigurationItem + private class ReadCalculation : IConfigurationItem { public ReadCalculation(string name) { Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/CalculationConfigurationReaderTest.cs =================================================================== diff -u -r7abe7a22648e3af0a350e60b21e3c61bb5fb6124 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/CalculationConfigurationReaderTest.cs (.../CalculationConfigurationReaderTest.cs) (revision 7abe7a22648e3af0a350e60b21e3c61bb5fb6124) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/CalculationConfigurationReaderTest.cs (.../CalculationConfigurationReaderTest.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -29,6 +29,7 @@ using Core.Common.Base.IO; using Core.Common.TestUtil; using NUnit.Framework; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Readers; using Ringtoets.Common.IO.Schema; @@ -265,12 +266,12 @@ var calculationConfigurationReader = new CalculationConfigurationReader(filePath, validMainSchemaDefinition, new Dictionary()); // Call - IList readConfigurationItems = calculationConfigurationReader.Read().ToList(); + IList readConfigurationItems = calculationConfigurationReader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); - var group = readConfigurationItems[0] as ReadCalculationGroup; + var group = readConfigurationItems[0] as CalculationConfigurationGroup; Assert.IsNotNull(group); Assert.AreEqual("Calculation group", group.Name); CollectionAssert.IsEmpty(group.Items); @@ -284,53 +285,53 @@ var calculationConfigurationReader = new CalculationConfigurationReader(filePath, validMainSchemaDefinition, new Dictionary()); // Call - IList readConfigurationItems = calculationConfigurationReader.Read().ToList(); + IList readConfigurationItems = calculationConfigurationReader.Read().ToList(); // Assert Assert.AreEqual(5, readConfigurationItems.Count); - var group1 = readConfigurationItems[0] as ReadCalculationGroup; + var group1 = readConfigurationItems[0] as CalculationConfigurationGroup; Assert.IsNotNull(group1); Assert.AreEqual("Group 1", group1.Name); var calculation1 = readConfigurationItems[1] as ReadCalculation; Assert.IsNotNull(calculation1); Assert.AreEqual("Calculation 1", calculation1.Name); - var group2 = readConfigurationItems[2] as ReadCalculationGroup; + var group2 = readConfigurationItems[2] as CalculationConfigurationGroup; Assert.IsNotNull(group2); Assert.AreEqual("Group 2", group2.Name); var calculation2 = readConfigurationItems[3] as ReadCalculation; Assert.IsNotNull(calculation2); Assert.AreEqual("Calculation 2", calculation2.Name); - var group3 = readConfigurationItems[4] as ReadCalculationGroup; + var group3 = readConfigurationItems[4] as CalculationConfigurationGroup; Assert.IsNotNull(group3); Assert.AreEqual("Group 3", group3.Name); - List group1Items = group1.Items.ToList(); + List group1Items = group1.Items.ToList(); Assert.AreEqual(1, group1Items.Count); var calculation3 = group1Items[0] as ReadCalculation; Assert.IsNotNull(calculation3); Assert.AreEqual("Calculation 3", calculation3.Name); - List group2Items = group2.Items.ToList(); + List group2Items = group2.Items.ToList(); Assert.AreEqual(2, group2Items.Count); - var group4 = group2Items[0] as ReadCalculationGroup; + var group4 = group2Items[0] as CalculationConfigurationGroup; Assert.IsNotNull(group4); Assert.AreEqual("Group 4", group4.Name); var calculation4 = group2Items[1] as ReadCalculation; Assert.IsNotNull(calculation4); Assert.AreEqual("Calculation 4", calculation4.Name); - List group3Items = group3.Items.ToList(); + List group3Items = group3.Items.ToList(); Assert.AreEqual(0, group3Items.Count); - List group4Items = group4.Items.ToList(); + List group4Items = group4.Items.ToList(); Assert.AreEqual(1, group4Items.Count); var calculation5 = group4Items[0] as ReadCalculation; @@ -356,7 +357,7 @@ } } - private class ReadCalculation : IReadConfigurationItem + private class ReadCalculation : IConfigurationItem { public ReadCalculation(string name) { Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/ReadCalculationGroupTest.cs =================================================================== diff -u -r4136a0156ea9e20e7e1aca569c5e89cbc713fed2 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/ReadCalculationGroupTest.cs (.../ReadCalculationGroupTest.cs) (revision 4136a0156ea9e20e7e1aca569c5e89cbc713fed2) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/ReadCalculationGroupTest.cs (.../ReadCalculationGroupTest.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -22,6 +22,7 @@ using System.Collections.Generic; using System.Linq; using NUnit.Framework; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Readers; namespace Ringtoets.Common.IO.Test.Readers @@ -33,22 +34,22 @@ public void Constructor_ExpectedValues() { // Setup - var nestedItems = new List + var nestedItems = new List { new TestReadConfigurationItem(), - new ReadCalculationGroup("Nested calculation group", Enumerable.Empty()) + new CalculationConfigurationGroup("Nested calculation group", Enumerable.Empty()) }; // Call - var readCalculationGroup = new ReadCalculationGroup("Calculation group", nestedItems); + var readCalculationGroup = new CalculationConfigurationGroup("Calculation group", nestedItems); // Assert - Assert.IsInstanceOf(readCalculationGroup); + Assert.IsInstanceOf(readCalculationGroup); Assert.AreEqual("Calculation group", readCalculationGroup.Name); Assert.AreSame(nestedItems, readCalculationGroup.Items); } - private class TestReadConfigurationItem : IReadConfigurationItem + private class TestReadConfigurationItem : IConfigurationItem { public string Name { Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj =================================================================== diff -u -r3c686d6ea57d86134a4338e75d3c7663f379716e -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 3c686d6ea57d86134a4338e75d3c7663f379716e) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -107,8 +107,9 @@ + - + Fisheye: Tag 5d8bda6e12681d1c019b449b298c464921a06ed7 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/SchemaCalculationConfigurationWriterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/StructureCalculationConfigurationWriterTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/StructureCalculationConfigurationWriterTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/StructureCalculationConfigurationWriterTest.cs (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -0,0 +1,181 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.IO.Configurations; +using Ringtoets.Common.IO.Writers; + +namespace Ringtoets.Common.IO.Test.Writers +{ + [TestFixture] + public class StructureCalculationConfigurationWriterTest + { + private static readonly string testDirectory = TestHelper.GetTestDataPath( + TestDataPath.Ringtoets.Common.IO, + nameof(StructureCalculationConfigurationWriter)); + + public static IEnumerable GetStructureCalculationsWithProperties() + { + yield return new TestCaseData( + new SimpleStructureCalculationConfiguration("some name"), + "structureCalculationWithoutParametersSet.xml") + .SetName("Structure calculation without any of its paramters set."); + + yield return new TestCaseData( + CreateStructureWithAllParametersSet("some other name"), + "structureCalculationWithAllParametersSet.xml") + .SetName("Structure calculation with all of its paramters set."); + } + + [Test] + public void Write_WithoutConfiguration_ThrowsArgumentNullException() + { + // Setup + string filePath = TestHelper.GetScratchPadPath("test.xml"); + + var writer = new SimpleStructureCalculationConfigurationWriter(filePath); + { + // Call + TestDelegate test = () => writer.Write(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("configuration", exception.ParamName); + } + } + + [Test] + [TestCaseSource(nameof(GetStructureCalculationsWithProperties))] + public void Write_WithoutDifferentSetParameters_WritesSetStructureProperties(StructureCalculationConfiguration structureCalculation, string fileName) + { + // Setup + string filePath = TestHelper.GetScratchPadPath(nameof(Write_WithoutDifferentSetParameters_WritesSetStructureProperties)); + try + { + var writer = new SimpleStructureCalculationConfigurationWriter(filePath); + + // Call + writer.Write(new [] { structureCalculation }); + + // Assert + string actualXml = File.ReadAllText(filePath); + string expectedXml = GetTestFileContent(fileName); + Assert.AreEqual(expectedXml, actualXml); + } + finally + { + File.Delete(filePath); + } + } + + private static SimpleStructureCalculationConfiguration CreateStructureWithAllParametersSet(string name) + { + return new SimpleStructureCalculationConfiguration(name) + { + AllowedLevelIncreaseStorage = new MeanStandardDeviationStochastConfiguration + { + Mean = 1.2, + StandardDeviation = 3.4 + }, + CriticalOvertoppingDischarge = new MeanVariationCoefficientStochastConfiguration + { + Mean = 22.2, + VariationCoefficient = 2.1 + }, + FailureProbabilityStructureWithErosion = 2.1, + FlowWidthAtBottomProtection = new MeanStandardDeviationStochastConfiguration + { + Mean = 5.4, + StandardDeviation = 1.1 + }, + ForeshoreProfileName = "Voorland", + HydraulicBoundaryLocationName = "Randvoorwaardelocatie", + ModelFactorSuperCriticalFlow = new MeanStandardDeviationStochastConfiguration + { + Mean = 322.2, + StandardDeviation = 91.2 + }, + StorageStructureArea = new MeanVariationCoefficientStochastConfiguration + { + Mean = 11.122, + VariationCoefficient = 32.111 + }, + StormDuration = new MeanVariationCoefficientStochastConfiguration + { + Mean = 21.22, + VariationCoefficient = 1.2 + }, + StructureNormalOrientation = 5.6, + StructureName = "Kunstwerk", + WaveReduction = new WaveReductionConfiguration + { + BreakWaterType = ReadBreakWaterType.Caisson, + UseBreakWater = false, + BreakWaterHeight = 111111.2, + UseForeshoreProfile = true + }, + WidthFlowApertures = new MeanStandardDeviationStochastConfiguration + { + Mean = 121.3, + StandardDeviation = 222.1 + } + }; + } + + private static XmlWriter CreateXmlWriter(string filePath) + { + return XmlWriter.Create(filePath, new XmlWriterSettings + { + Indent = true, + ConformanceLevel = ConformanceLevel.Fragment + }); + } + + private string GetTestFileContent(string testFile) + { + return File.ReadAllText(Path.Combine(testDirectory, testFile)); + } + + private class SimpleStructureCalculationConfiguration : StructureCalculationConfiguration + { + public SimpleStructureCalculationConfiguration(string name) : base(name) {} + } + private class SimpleStructureCalculationConfigurationWriter : StructureCalculationConfigurationWriter + { + public SimpleStructureCalculationConfigurationWriter(string filePath) : base(filePath) {} + + protected override void WriteSpecificStructureParameters(SimpleStructureCalculationConfiguration configuration, XmlWriter writer) + { + // no specific parameters + } + + protected override void WriteSpecificStochasts(SimpleStructureCalculationConfiguration configuration, XmlWriter writer) + { + // no specific stochasts + } + } + } +} \ No newline at end of file Fisheye: Tag cc1268d7cb906524d4cabcd4cbd9ae16676cf059 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/StructureCalculationConfigurationXmlWriterExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/StructureCalculationConfigurationWriter/structureCalculationWithAllParametersSet.xml =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/StructureCalculationConfigurationWriter/structureCalculationWithAllParametersSet.xml (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/StructureCalculationConfigurationWriter/structureCalculationWithAllParametersSet.xml (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -0,0 +1,46 @@ + + + + Randvoorwaardelocatie + Kunstwerk + 5.6 + 2.1 + Voorland + + false + caisson + 111111.2 + true + + + + 5.4 + 1.1 + + + 121.3 + 222.1 + + + 11.122 + 32.111 + + + 22.2 + 2.1 + + + 322.2 + 91.2 + + + 1.2 + 3.4 + + + 21.22 + 1.2 + + + + \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/StructureCalculationConfigurationWriter/structureCalculationWithoutParametersSet.xml =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/StructureCalculationConfigurationWriter/structureCalculationWithoutParametersSet.xml (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/StructureCalculationConfigurationWriter/structureCalculationWithoutParametersSet.xml (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file Fisheye: Tag cc1268d7cb906524d4cabcd4cbd9ae16676cf059 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/StructureCalculationConfigurationXmlWriterExtensions/structureCalculationWithAllParametersSet.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag cc1268d7cb906524d4cabcd4cbd9ae16676cf059 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/StructureCalculationConfigurationXmlWriterExtensions/structureCalculationWithoutParametersSet.xml'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/CustomSchemaCalculationConfigurationExporterDesignGuidelinesTestFixture.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/CustomSchemaCalculationConfigurationExporterDesignGuidelinesTestFixture.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/CustomSchemaCalculationConfigurationExporterDesignGuidelinesTestFixture.cs (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -0,0 +1,193 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Security.AccessControl; +using System.Text; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.IO.Configurations; +using Ringtoets.Common.IO.Exporters; +using Ringtoets.Common.IO.Readers; +using Ringtoets.Common.IO.Writers; + +namespace Ringtoets.Common.IO.TestUtil +{ + [TestFixture] + public abstract class CustomSchemaCalculationConfigurationExporterDesignGuidelinesTestFixture + where TCalculation : class, ICalculation + where TWriter : SchemaCalculationConfigurationWriter + where TConfiguration : class, IConfigurationItem + where TCalculationConfigurationExporter : SchemaCalculationConfigurationExporter + { + [Test] + public void Constructor_ConfigurationNull_ThrowArgumentNullException() + { + // Call + TestDelegate test = () => CallConfigurationFilePathConstructor(null, "test.xml"); + + // Assert + var exception = Assert.Throws(test); + AssertNullCalculations(exception); + } + + [Test] + [TestCaseSource(typeof(InvalidPathHelper), nameof(InvalidPathHelper.InvalidPaths))] + public void Constructor_FilePathInvalid_ThrowArgumentException(string filePath) + { + // Call + TestDelegate test = () => CallConfigurationFilePathConstructor(Enumerable.Empty(), filePath); + + // Assert + var activatorException = Assert.Throws(test); + var exception = (ArgumentException) activatorException.InnerException; + AssertInvalidFilePath(exception); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Call + TCalculationConfigurationExporter exporter = CallConfigurationFilePathConstructor(Enumerable.Empty(), "test.xml"); + + // Assert + AssertDefaultConstructedInstance(exporter); + } + + [Test] + public void Export_InvalidDirectoryRights_LogErrorAndReturnFalse() + { + // Setup + const string folderName = nameof(Export_InvalidDirectoryRights_LogErrorAndReturnFalse); + string directoryPath = TestHelper.GetScratchPadPath(folderName); + using (var disposeHelper = new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), folderName)) + { + string filePath = Path.Combine(directoryPath, "test.xml"); + + TCalculationConfigurationExporter exporter = CallConfigurationFilePathConstructor(new[] + { + CreateCalculation() + }, filePath); + + disposeHelper.LockDirectory(FileSystemRights.Write); + + // Call + var isExported = true; + Action call = () => isExported = exporter.Export(); + + // Assert + IEnumerable> logMessages = GetExpectedExportFailedLogMessages(filePath); + TestHelper.AssertLogMessagesWithLevelAreGenerated(call, logMessages); + Assert.IsFalse(isExported); + } + } + + [Test] + public void Export_PathTooLong_LogErrorAndReturnFalse() + { + // Setup + var stringBuilder = new StringBuilder(); + stringBuilder.Append(@"C:\"); + for (var i = 0; i < 300; i++) + { + stringBuilder.Append("A"); + } + + string filePath = Path.Combine(stringBuilder.ToString(), "test.xml"); + + TCalculationConfigurationExporter exporter = CallConfigurationFilePathConstructor(new[] + { + CreateCalculation() + }, filePath); + + // Call + var isExported = true; + Action call = () => isExported = exporter.Export(); + + // Assert + IEnumerable> logMessages = GetExpectedExportFailedLogMessages(filePath); + TestHelper.AssertLogMessagesWithLevelAreGenerated(call, logMessages); + Assert.IsFalse(isExported); + } + + protected virtual IEnumerable> GetExpectedExportFailedLogMessages(string filePath) + { + return new[] + { + Tuple.Create( + $"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'. " + + "Er is geen configuratie geëxporteerd.", LogLevelConstant.Error) + }; + } + + protected virtual void AssertNullCalculations(ArgumentNullException exception) + { + Assert.IsNotNull(exception); + Assert.IsInstanceOf(exception); + Assert.AreEqual("calculations", exception.ParamName); + } + + protected virtual void AssertDefaultConstructedInstance(TCalculationConfigurationExporter exporter) + { + Assert.IsInstanceOf>(exporter); + } + + protected virtual void AssertInvalidFilePath(ArgumentException exception) + { + Assert.IsNotNull(exception); + Assert.IsInstanceOf(exception); + } + + protected void WriteAndValidate(IEnumerable configuration, string expectedXmlFilePath) + { + string filePath = TestHelper.GetScratchPadPath($"{nameof(TCalculationConfigurationExporter)}.{nameof(WriteAndValidate)}.xml"); + TCalculationConfigurationExporter exporter = CallConfigurationFilePathConstructor(configuration, filePath); + + try + { + // Call + bool isExported = exporter.Export(); + + // Assert + Assert.IsTrue(isExported); + Assert.IsTrue(File.Exists(filePath)); + + string actualXml = File.ReadAllText(filePath); + string expectedXml = File.ReadAllText(expectedXmlFilePath); + + Assert.AreEqual(expectedXml, actualXml); + } + finally + { + File.Delete(filePath); + } + } + + protected abstract TCalculation CreateCalculation(); + + protected abstract TCalculationConfigurationExporter CallConfigurationFilePathConstructor(IEnumerable calculations, string filePath); + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/CustomSchemaCalculationConfigurationWriterDesignGuidelinesTestFixture.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/CustomSchemaCalculationConfigurationWriterDesignGuidelinesTestFixture.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/CustomSchemaCalculationConfigurationWriterDesignGuidelinesTestFixture.cs (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -0,0 +1,216 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.IO; +using System.Linq; +using System.Security.AccessControl; +using Core.Common.IO.Exceptions; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.IO.Configurations; +using Ringtoets.Common.IO.Readers; +using Ringtoets.Common.IO.Writers; + +namespace Ringtoets.Common.IO.TestUtil +{ + [TestFixture] + public abstract class CustomSchemaCalculationConfigurationWriterDesignGuidelinesTestFixture + where TConfiguration : class, IConfigurationItem + where TWriter : SchemaCalculationConfigurationWriter + { + [Test] + public void Write_CalculationOfTypeOtherThanGiven_ThrowsCriticalFileWriteExceptionWithInnerArgumentException() + { + // Setup + var mocks = new MockRepository(); + var calculation = mocks.Stub(); + mocks.ReplayAll(); + + string filePath = TestHelper.GetScratchPadPath("test.xml"); + + try + { + var writer = CreateWriterInstance(filePath); + + // Call + TestDelegate test = () => writer.Write(new[] + { + calculation + }); + + // Assert + var exception = Assert.Throws(test); + var innerException = exception.InnerException; + Assert.IsNotNull(innerException); + Assert.AreEqual($"Cannot write calculation of type '{calculation.GetType()}' using this writer.", innerException.Message); + } + finally + { + File.Delete(filePath); + } + mocks.VerifyAll(); + } + + [Test] + public void Constructor_WithoutFilePath_ThrowsArgumentException() + { + // Call + TestDelegate call = () => CreateWriterInstance(null); + + // Assert + AssertNullFilePath(Assert.Throws(call)); + } + + [Test] + [TestCaseSource(typeof(InvalidPathHelper), nameof(InvalidPathHelper.InvalidPaths))] + public void Constructor_WithoutValidFilePath_ThrowsArgumentException(string filePath) + { + // Call + TestDelegate call = () => CreateWriterInstance(filePath); + + // Assert + Assert.Throws(call); + } + + [Test] + public void Write_FilePathTooLong_ThrowCriticalFileWriteException() + { + // Setup + var filePath = new string('a', 249); + TWriter writerInstance = CreateWriterInstance(filePath); + + // Call + TestDelegate call = () => + { + writerInstance.Write(Enumerable.Empty()); + }; + + // Assert + var exception = Assert.Throws(call); + AssertTooLongPath(exception, filePath); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Call + TWriter writer = CreateWriterInstance("//validpath"); + + // Assert + AssertDefaultConstructedInstance(writer); + } + + [Test] + public void Write_ConfigurationNull_ThrowArgumentNullException() + { + // Setup + TWriter writer = CreateWriterInstance("//validpath"); + + // Call + TestDelegate test = () => writer.Write(null); + + // Assert + var exception = Assert.Throws(test); + AssertNullConfiguration(exception); + } + + [Test] + public void Write_InvalidDirectoryRights_ThrowCriticalFileWriteException() + { + // Setup + string directoryPath = TestHelper.GetScratchPadPath(nameof(Write_InvalidDirectoryRights_ThrowCriticalFileWriteException)); + using (var disposeHelper = new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(Write_InvalidDirectoryRights_ThrowCriticalFileWriteException))) + { + string filePath = Path.Combine(directoryPath, "test.xml"); + disposeHelper.LockDirectory(FileSystemRights.Write); + var writer = CreateWriterInstance(filePath); + + // Call + TestDelegate call = () => writer.Write(Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + AssertInvalidDirectoryRights(exception, filePath); + } + } + + [Test] + public void Write_FileInUse_ThrowCriticalFileWriteException() + { + // Setup + string path = TestHelper.GetScratchPadPath(nameof(Write_FileInUse_ThrowCriticalFileWriteException)); + + using (var fileDisposeHelper = new FileDisposeHelper(path)) + { + fileDisposeHelper.LockFiles(); + var writer = CreateWriterInstance(path); + + // Call + TestDelegate call = () => writer.Write(Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + AssertFileInUse(exception, path); + } + } + + protected abstract TWriter CreateWriterInstance(string filePath); + + protected virtual void AssertDefaultConstructedInstance(TWriter writer) + { + Assert.IsInstanceOf>(writer); + } + + protected virtual void AssertNullConfiguration(ArgumentNullException exception) + { + Assert.IsNotNull(exception); + Assert.AreEqual("configuration", exception.ParamName); + } + + protected virtual void AssertNullFilePath(ArgumentException exception) + { + Assert.IsNotNull(exception); + } + + protected virtual void AssertTooLongPath(CriticalFileWriteException exception, string filePath) + { + Assert.IsNotNull(exception); + Assert.AreEqual($"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + + protected virtual void AssertInvalidDirectoryRights(CriticalFileWriteException exception, string filePath) + { + Assert.IsNotNull(exception); + Assert.AreEqual($"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + + protected virtual void AssertFileInUse(CriticalFileWriteException exception, string filePath) + { + Assert.IsNotNull(exception); + Assert.AreEqual($"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/Ringtoets.Common.IO.TestUtil.csproj =================================================================== diff -u -rb2288a6eae1568001c17d9ce7aaa5521a44595f2 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/Ringtoets.Common.IO.TestUtil.csproj (.../Ringtoets.Common.IO.TestUtil.csproj) (revision b2288a6eae1568001c17d9ce7aaa5521a44595f2) +++ Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/Ringtoets.Common.IO.TestUtil.csproj (.../Ringtoets.Common.IO.TestUtil.csproj) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -38,14 +38,20 @@ ..\..\..\..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll True + + ..\..\..\..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll + True + Properties\GlobalAssembly.cs + + Index: Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/packages.config =================================================================== diff -u -rb2288a6eae1568001c17d9ce7aaa5521a44595f2 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/packages.config (.../packages.config) (revision b2288a6eae1568001c17d9ce7aaa5521a44595f2) +++ Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/packages.config (.../packages.config) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -23,4 +23,5 @@ --> + \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Readers/GrassCoverErosionInwardsCalculationConfigurationReader.cs =================================================================== diff -u -re786dd8b8c7f833c217fdcddd909a616d590fe15 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Readers/GrassCoverErosionInwardsCalculationConfigurationReader.cs (.../GrassCoverErosionInwardsCalculationConfigurationReader.cs) (revision e786dd8b8c7f833c217fdcddd909a616d590fe15) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Readers/GrassCoverErosionInwardsCalculationConfigurationReader.cs (.../GrassCoverErosionInwardsCalculationConfigurationReader.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -24,6 +24,7 @@ using System.Xml.Linq; using Core.Common.Base.IO; using Ringtoets.Common.IO; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Readers; using Ringtoets.Common.IO.Schema; using Ringtoets.GrassCoverErosionInwards.IO.Properties; @@ -33,7 +34,7 @@ { /// /// This class reads a grass cover erosion inwards configuration from XML and creates - /// a collection of corresponding , typically + /// a collection of corresponding , typically /// containing one or more . /// public class GrassCoverErosionInwardsCalculationConfigurationReader : CalculationConfigurationReader Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Readers/ReadGrassCoverErosionInwardsCalculation.cs =================================================================== diff -u -rd0a54cbc1b0f33a350874859f97f713182a3d478 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Readers/ReadGrassCoverErosionInwardsCalculation.cs (.../ReadGrassCoverErosionInwardsCalculation.cs) (revision d0a54cbc1b0f33a350874859f97f713182a3d478) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Readers/ReadGrassCoverErosionInwardsCalculation.cs (.../ReadGrassCoverErosionInwardsCalculation.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -21,6 +21,7 @@ using System; using Ringtoets.Common.IO; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Readers; namespace Ringtoets.GrassCoverErosionInwards.IO.Readers @@ -29,7 +30,7 @@ /// Class that represents a grass cover erosion inwards calculation that is read via /// . /// - public class ReadGrassCoverErosionInwardsCalculation : IReadConfigurationItem + public class ReadGrassCoverErosionInwardsCalculation : IConfigurationItem { /// /// Creates a new instance of . Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Readers/GrassCoverErosionInwardsCalculationConfigurationReaderTest.cs =================================================================== diff -u -r5d7d6070e020dcc02fefb624d582c958d9bd9890 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Readers/GrassCoverErosionInwardsCalculationConfigurationReaderTest.cs (.../GrassCoverErosionInwardsCalculationConfigurationReaderTest.cs) (revision 5d7d6070e020dcc02fefb624d582c958d9bd9890) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Readers/GrassCoverErosionInwardsCalculationConfigurationReaderTest.cs (.../GrassCoverErosionInwardsCalculationConfigurationReaderTest.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -27,6 +27,7 @@ using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.IO; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Readers; using Ringtoets.GrassCoverErosionInwards.IO.Readers; @@ -214,7 +215,7 @@ var reader = new GrassCoverErosionInwardsCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -243,7 +244,7 @@ var reader = new GrassCoverErosionInwardsCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -262,7 +263,7 @@ var reader = new GrassCoverErosionInwardsCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -284,7 +285,7 @@ var reader = new GrassCoverErosionInwardsCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -313,7 +314,7 @@ var reader = new GrassCoverErosionInwardsCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -342,7 +343,7 @@ var reader = new GrassCoverErosionInwardsCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -371,7 +372,7 @@ var reader = new GrassCoverErosionInwardsCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -390,7 +391,7 @@ var reader = new GrassCoverErosionInwardsCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -409,7 +410,7 @@ var reader = new GrassCoverErosionInwardsCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Readers/ReadGrassCoverErosionInwardsCalculationTest.cs =================================================================== diff -u -rd0a54cbc1b0f33a350874859f97f713182a3d478 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Readers/ReadGrassCoverErosionInwardsCalculationTest.cs (.../ReadGrassCoverErosionInwardsCalculationTest.cs) (revision d0a54cbc1b0f33a350874859f97f713182a3d478) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Readers/ReadGrassCoverErosionInwardsCalculationTest.cs (.../ReadGrassCoverErosionInwardsCalculationTest.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -22,6 +22,7 @@ using System; using NUnit.Framework; using Ringtoets.Common.IO; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Readers; using Ringtoets.GrassCoverErosionInwards.IO.Readers; @@ -49,7 +50,7 @@ var readCalculation = new ReadGrassCoverErosionInwardsCalculation(constructionProperties); // Assert - Assert.IsInstanceOf(readCalculation); + Assert.IsInstanceOf(readCalculation); Assert.IsNull(readCalculation.Name); Assert.IsNull(readCalculation.HydraulicBoundaryLocation); Assert.IsNull(readCalculation.DikeProfile); Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationExporter.cs =================================================================== diff -u --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationExporter.cs (revision 0) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationExporter.cs (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -0,0 +1,123 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.Structures; +using Ringtoets.Common.IO; +using Ringtoets.Common.IO.Configurations; +using Ringtoets.Common.IO.Exporters; +using Ringtoets.HeightStructures.Data; + +namespace Ringtoets.HeightStructures.IO +{ + /// + /// Exports a height structures calculation configuration and stores it as an XML file. + /// + public class HeightStructuresCalculationConfigurationExporter : SchemaCalculationConfigurationExporter< + HeightStructuresCalculationConfigurationWriter, + StructuresCalculation, + HeightStructureCalculationConfiguration + > + { + /// + /// 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 HeightStructuresCalculationConfigurationExporter(IEnumerable calculations, string filePath) : base(calculations, filePath) + {} + + protected override HeightStructureCalculationConfiguration ToConfiguration(StructuresCalculation calculation) + { + HeightStructuresInput input = calculation.InputParameters; + var calculationConfiguration = new HeightStructureCalculationConfiguration(calculation.Name); + + calculationConfiguration.HydraulicBoundaryLocationName = input.HydraulicBoundaryLocation?.Name; + + if (input.Structure != null) + { + calculationConfiguration.StructureName = input.Structure.Name; + calculationConfiguration.StructureNormalOrientation = input.StructureNormalOrientation; + calculationConfiguration.FailureProbabilityStructureWithErosion = input.FailureProbabilityStructureWithErosion; + + calculationConfiguration.FlowWidthAtBottomProtection = new MeanStandardDeviationStochastConfiguration + { + Mean = input.FlowWidthAtBottomProtection.Mean, + StandardDeviation = input.FlowWidthAtBottomProtection.StandardDeviation + }; + calculationConfiguration.WidthFlowApertures = new MeanStandardDeviationStochastConfiguration + { + Mean = input.WidthFlowApertures.Mean, + StandardDeviation = input.WidthFlowApertures.StandardDeviation + }; + calculationConfiguration.StorageStructureArea = new MeanVariationCoefficientStochastConfiguration + { + Mean = input.StorageStructureArea.Mean, + VariationCoefficient = input.StorageStructureArea.CoefficientOfVariation + }; + calculationConfiguration.AllowedLevelIncreaseStorage = new MeanStandardDeviationStochastConfiguration + { + Mean = input.AllowedLevelIncreaseStorage.Mean, + StandardDeviation = input.AllowedLevelIncreaseStorage.StandardDeviation + }; + calculationConfiguration.LevelCrestStructure = new MeanStandardDeviationStochastConfiguration + { + Mean = input.LevelCrestStructure.Mean, + StandardDeviation = input.LevelCrestStructure.StandardDeviation + }; + calculationConfiguration.CriticalOvertoppingDischarge = new MeanVariationCoefficientStochastConfiguration + { + Mean = input.CriticalOvertoppingDischarge.Mean, + VariationCoefficient = input.CriticalOvertoppingDischarge.CoefficientOfVariation + }; + } + + calculationConfiguration.WaveReduction = new WaveReductionConfiguration(); + + if (input.UseBreakWater) + { + calculationConfiguration.WaveReduction.UseBreakWater = true; + calculationConfiguration.WaveReduction.BreakWaterType = (ReadBreakWaterType) input.BreakWater.Type; + calculationConfiguration.WaveReduction.BreakWaterHeight = input.BreakWater.Height; + } + if (input.ForeshoreProfile != null) + { + calculationConfiguration.ForeshoreProfileName = input.ForeshoreProfile?.Name; + calculationConfiguration.WaveReduction.UseForeshoreProfile = input.UseForeshore; + + } + calculationConfiguration.StormDuration = new MeanVariationCoefficientStochastConfiguration + { + Mean = input.StormDuration.Mean + }; + calculationConfiguration.ModelFactorSuperCriticalFlow = new MeanStandardDeviationStochastConfiguration + { + Mean = input.ModelFactorSuperCriticalFlow.Mean + }; + + return calculationConfiguration; + } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationWriter.cs =================================================================== diff -u -r7bd351546131ba071f60e1c6266a93c2e8e53980 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationWriter.cs (.../HeightStructuresCalculationConfigurationWriter.cs) (revision 7bd351546131ba071f60e1c6266a93c2e8e53980) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationWriter.cs (.../HeightStructuresCalculationConfigurationWriter.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -26,29 +26,34 @@ namespace Ringtoets.HeightStructures.IO { /// - /// Extension methods for an , for writing - /// in XML format to file. + /// Writer for writing in XML format to file. /// - public static class HeightStructuresCalculationConfigurationXmlWriterExtensions + public class HeightStructuresCalculationConfigurationWriter : StructureCalculationConfigurationWriter { /// - /// Writes the in XML format to file. + /// Creates a new instance of . /// - /// The writer to use for writing. - /// The dictionary of distributions, keyed on name, to write. - public static void WriteHeightStructure(this XmlWriter writer, HeightStructureCalculationConfiguration configuration) + /// The path of the file to write to. + /// Thrown when is invalid. + /// A valid path: + /// + /// is not empty or null, + /// does not consist out of only whitespace characters, + /// does not contain an invalid character, + /// does not end with a directory or path separator (empty file name). + /// + public HeightStructuresCalculationConfigurationWriter(string filePath) : base(filePath) {} + + protected override void WriteSpecificStructureParameters(HeightStructureCalculationConfiguration configuration, XmlWriter writer) { - writer.WriteStructure(configuration, WriteProperties, WriteStochasts); } - private static void WriteStochasts(HeightStructureCalculationConfiguration configuration, XmlWriter writer) + protected override void WriteSpecificStochasts(HeightStructureCalculationConfiguration configuration, XmlWriter writer) { if (configuration.LevelCrestStructure != null) { writer.WriteDistribution(HeightStructuresConfigurationSchemaIdentifiers.LevelCrestStructureStochastName, configuration.LevelCrestStructure); } } - - private static void WriteProperties(HeightStructureCalculationConfiguration configuration, XmlWriter writer) {} } } \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Ringtoets.HeightStructures.IO.csproj =================================================================== diff -u -rbf9155b1a1289a959fadbcd3f1412c809e40d041 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Ringtoets.HeightStructures.IO.csproj (.../Ringtoets.HeightStructures.IO.csproj) (revision bf9155b1a1289a959fadbcd3f1412c809e40d041) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Ringtoets.HeightStructures.IO.csproj (.../Ringtoets.HeightStructures.IO.csproj) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -44,6 +44,7 @@ Properties\GlobalAssembly.cs + @@ -70,6 +71,16 @@ Core.Common.Base False + + {E344867E-9AC9-44C8-88A5-8185681679A9} + Core.Common.IO + False + + + {f49bd8b2-332a-4c91-a196-8cce0a2c7d98} + Core.Common.Utils + False + {D4200F43-3F72-4F42-AF0A-8CED416A38EC} Ringtoets.Common.Data Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/HeightStructuresCalculationConfigurationExporterTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/HeightStructuresCalculationConfigurationExporterTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/HeightStructuresCalculationConfigurationExporterTest.cs (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -0,0 +1,155 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.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.DikeProfiles; +using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Common.Data.Structures; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.IO.TestUtil; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Data.TestUtil; + +namespace Ringtoets.HeightStructures.IO.Test +{ + [TestFixture] + public class HeightStructuresCalculationConfigurationExporterTest + : CustomSchemaCalculationConfigurationExporterDesignGuidelinesTestFixture< + HeightStructuresCalculationConfigurationExporter, + HeightStructuresCalculationConfigurationWriter, + StructuresCalculation, + HeightStructureCalculationConfiguration> + { + [Test] + public void Export_ValidData_ReturnTrueAndWritesFile() + { + // Setup + StructuresCalculation calculation = CreateFullCalculation(); + StructuresCalculation calculation2 = new StructuresCalculation + { + Name = "Berekening 2" + }; + + CalculationGroup calculationGroup2 = new CalculationGroup("Nested", false) + { + Children = + { + calculation2 + } + }; + + CalculationGroup calculationGroup = new CalculationGroup("Testmap", false) + { + Children = + { + calculation, + calculationGroup2 + } + }; + + string expectedXmlFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HeightStructures.IO, + Path.Combine(nameof(HeightStructuresCalculationConfigurationWriter), + "folderWithSubfolderAndCalculation.xml")); + + // Call and Assert + WriteAndValidate(new[] + { + calculationGroup + }, expectedXmlFilePath); + } + + private static StructuresCalculation CreateFullCalculation() + { + return new TestHeightStructuresCalculation + { + Name = "Berekening 1", + InputParameters = + { + HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("Locatie1"), + Structure = new TestHeightStructure("kunstwerk1"), + ForeshoreProfile = new TestForeshoreProfile("profiel1"), + FailureProbabilityStructureWithErosion = 1e-6, + StructureNormalOrientation = (RoundedDouble) 67.1, + UseBreakWater = true, + UseForeshore = true, + BreakWater = + { + Type = BreakWaterType.Dam, + Height = (RoundedDouble) 1.234 + }, + StormDuration = new VariationCoefficientLogNormalDistribution() + { + Mean = (RoundedDouble) 6.0 + }, + ModelFactorSuperCriticalFlow = new NormalDistribution() + { + Mean = (RoundedDouble) 1.10 + }, + FlowWidthAtBottomProtection = new LogNormalDistribution() + { + Mean = (RoundedDouble) 15.2, + StandardDeviation = (RoundedDouble) 0.1 + }, + WidthFlowApertures = new NormalDistribution() + { + Mean = (RoundedDouble) 13.2, + StandardDeviation = (RoundedDouble) 0.3 + }, + StorageStructureArea = new VariationCoefficientLogNormalDistribution() + { + Mean = (RoundedDouble) 15000, + CoefficientOfVariation = (RoundedDouble) 0.01 + }, + AllowedLevelIncreaseStorage = new LogNormalDistribution() + { + Mean = (RoundedDouble) 0.2, + StandardDeviation = (RoundedDouble) 0.01 + }, + LevelCrestStructure = new NormalDistribution() + { + Mean = (RoundedDouble) 4.3, + StandardDeviation = (RoundedDouble) 0.2 + }, + CriticalOvertoppingDischarge = new VariationCoefficientLogNormalDistribution() + { + Mean = (RoundedDouble) 2, + CoefficientOfVariation = (RoundedDouble) 0.1 + } + } + }; + } + + protected override StructuresCalculation CreateCalculation() + { + return new TestHeightStructuresCalculation(); + } + + protected override HeightStructuresCalculationConfigurationExporter CallConfigurationFilePathConstructor(IEnumerable calculations, string filePath) + { + return new HeightStructuresCalculationConfigurationExporter(calculations, filePath); + } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/HeightStructuresCalculationConfigurationWriterTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/HeightStructuresCalculationConfigurationWriterTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/HeightStructuresCalculationConfigurationWriterTest.cs (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -0,0 +1,169 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Collections.Generic; +using System.IO; +using Core.Common.Base.Data; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.IO; +using Ringtoets.Common.IO.Configurations; +using Ringtoets.Common.IO.TestUtil; +using Ringtoets.Common.IO.Writers; + +namespace Ringtoets.HeightStructures.IO.Test +{ + [TestFixture] + public class HeightStructuresCalculationConfigurationWriterTest + : CustomSchemaCalculationConfigurationWriterDesignGuidelinesTestFixture< + HeightStructuresCalculationConfigurationWriter, + HeightStructureCalculationConfiguration> + { + private readonly string testDataPath = TestHelper.GetTestDataPath( + TestDataPath.Ringtoets.HeightStructures.IO, + nameof(HeightStructuresCalculationConfigurationWriter)); + + private static IEnumerable Calculations + { + get + { + yield return new TestCaseData("completeConfiguration", new[] + { + CreateFullCalculation() + }) + .SetName("Calculation configuration with all parameters set"); + yield return new TestCaseData("sparseConfiguration", new[] + { + new HeightStructureCalculationConfiguration("sparse config") + }) + .SetName("Calculation configuration with none of its parameters set"); + yield return new TestCaseData("folderWithSubfolderAndCalculation", new IConfigurationItem[] + { + new CalculationConfigurationGroup("Testmap", new IConfigurationItem[] + { + new HeightStructureCalculationConfiguration("sparse config"), + new CalculationConfigurationGroup("Nested", new IConfigurationItem[] + { + CreateFullCalculation() + }) + }) + }) + .SetName("Calculation configuration with none of its parameters set"); + } + } + + protected override void AssertDefaultConstructedInstance(HeightStructuresCalculationConfigurationWriter writer) + { + Assert.IsInstanceOf>(writer); + } + + [Test] + [TestCaseSource(nameof(Calculations))] + public void Write_ValidCalculationCalculation_ValidFile(string expectedFileName, HeightStructureCalculationConfiguration[] configuration) + { + // Setup + string filePath = TestHelper.GetScratchPadPath("test.xml"); + + try + { + var writer = new HeightStructuresCalculationConfigurationWriter(filePath); + + // Call + writer.Write(configuration); + + // Assert + Assert.IsTrue(File.Exists(filePath)); + + string actualXml = File.ReadAllText(filePath); + string expectedXmlFilePath = Path.Combine(testDataPath, $"{expectedFileName}.xml"); + string expectedXml = File.ReadAllText(expectedXmlFilePath); + + Assert.AreEqual(expectedXml, actualXml); + } + finally + { + File.Delete(filePath); + } + } + + private static HeightStructureCalculationConfiguration CreateFullCalculation() + { + return new HeightStructureCalculationConfiguration("Berekening 1") + { + HydraulicBoundaryLocationName = "Locatie1", + StructureName = "kunstwerk1", + ForeshoreProfileName = "profiel1", + FailureProbabilityStructureWithErosion = 1e-6, + StructureNormalOrientation = 67.1, + WaveReduction = new WaveReductionConfiguration + { + UseBreakWater = true, + BreakWaterType = ReadBreakWaterType.Dam, + BreakWaterHeight = 1.234, + UseForeshoreProfile = true + }, + StormDuration = new MeanVariationCoefficientStochastConfiguration + { + Mean = (RoundedDouble) 6.0 + }, + ModelFactorSuperCriticalFlow = new MeanStandardDeviationStochastConfiguration + { + Mean = (RoundedDouble) 1.10 + }, + FlowWidthAtBottomProtection = new MeanStandardDeviationStochastConfiguration + { + Mean = (RoundedDouble) 15.2, + StandardDeviation = (RoundedDouble) 0.1 + }, + WidthFlowApertures = new MeanStandardDeviationStochastConfiguration + { + Mean = (RoundedDouble) 13.2, + StandardDeviation = (RoundedDouble) 0.3 + }, + StorageStructureArea = new MeanVariationCoefficientStochastConfiguration + { + Mean = (RoundedDouble) 15000, + VariationCoefficient = (RoundedDouble) 0.01 + }, + AllowedLevelIncreaseStorage = new MeanStandardDeviationStochastConfiguration + { + Mean = (RoundedDouble) 0.2, + StandardDeviation = (RoundedDouble) 0.01 + }, + LevelCrestStructure = new MeanStandardDeviationStochastConfiguration + { + Mean = (RoundedDouble) 4.3, + StandardDeviation = (RoundedDouble) 0.2 + }, + CriticalOvertoppingDischarge = new MeanVariationCoefficientStochastConfiguration + { + Mean = (RoundedDouble) 2, + VariationCoefficient = (RoundedDouble) 0.1 + } + }; + } + + protected override HeightStructuresCalculationConfigurationWriter CreateWriterInstance(string filePath) + { + return new HeightStructuresCalculationConfigurationWriter(filePath); + } + } +} \ No newline at end of file Fisheye: Tag cc1268d7cb906524d4cabcd4cbd9ae16676cf059 refers to a dead (removed) revision in file `Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/HeightStructuresCalculationConfigurationXmlWriterExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/Ringtoets.HeightStructures.IO.Test.csproj =================================================================== diff -u -r3c686d6ea57d86134a4338e75d3c7663f379716e -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/Ringtoets.HeightStructures.IO.Test.csproj (.../Ringtoets.HeightStructures.IO.Test.csproj) (revision 3c686d6ea57d86134a4338e75d3c7663f379716e) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/Ringtoets.HeightStructures.IO.Test.csproj (.../Ringtoets.HeightStructures.IO.Test.csproj) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -51,7 +51,8 @@ Properties\GlobalAssembly.cs - + + @@ -66,6 +67,10 @@ {3BBFD65B-B277-4E50-AE6D-BD24C3434609} Core.Common.Base + + {E344867E-9AC9-44C8-88A5-8185681679A9} + Core.Common.IO + {D749EE4C-CE50-4C17-BF01-9A953028C126} Core.Common.TestUtil @@ -78,6 +83,10 @@ {52BA7627-CBAB-4209-BE77-3B5F31378277} Ringtoets.Common.IO + + {4843D6E5-066F-4795-94F5-1D53932DD03C} + Ringtoets.Common.Data.TestUtil + {33508D7C-1602-4C0D-8503-73AAE98C19E5} Ringtoets.Common.IO.TestUtil Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationWriter/completeConfiguration.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationWriter/completeConfiguration.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationWriter/completeConfiguration.xml (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -0,0 +1,48 @@ + + + + Locatie1 + kunstwerk1 + 67.1 + 1E-06 + profiel1 + + true + havendam + 1.234 + true + + + + 15.2 + 0.1 + + + 13.2 + 0.3 + + + 15000 + 0.01 + + + 2 + 0.1 + + + 1.1 + + + 0.2 + 0.01 + + + 6 + + + 4.3 + 0.2 + + + + \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationWriter/folderWithSubfolderAndCalculation.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationWriter/folderWithSubfolderAndCalculation.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationWriter/folderWithSubfolderAndCalculation.xml (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -0,0 +1,63 @@ + + + + + Locatie1 + kunstwerk1 + 67.1 + 1E-06 + profiel1 + + true + havendam + 1.23 + true + + + + 15.2 + 0.1 + + + 13.2 + 0.3 + + + 15000 + 0.01 + + + 2 + 0.1 + + + 1.1 + + + 0.2 + 0.01 + + + 6 + + + 4.3 + 0.2 + + + + + + + + + 1.1 + + + 6 + + + + + + \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationWriter/sparseConfiguration.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationWriter/sparseConfiguration.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationWriter/sparseConfiguration.xml (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file Fisheye: Tag cc1268d7cb906524d4cabcd4cbd9ae16676cf059 refers to a dead (removed) revision in file `Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationXmlWriterExtensions/completeConfiguration.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag cc1268d7cb906524d4cabcd4cbd9ae16676cf059 refers to a dead (removed) revision in file `Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationXmlWriterExtensions/folderWithSubfolderAndCalculation.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag cc1268d7cb906524d4cabcd4cbd9ae16676cf059 refers to a dead (removed) revision in file `Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationXmlWriterExtensions/sparseConfiguration.xml'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingCalculationConfigurationReader.cs =================================================================== diff -u -r5d7d6070e020dcc02fefb624d582c958d9bd9890 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingCalculationConfigurationReader.cs (.../PipingCalculationConfigurationReader.cs) (revision 5d7d6070e020dcc02fefb624d582c958d9bd9890) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingCalculationConfigurationReader.cs (.../PipingCalculationConfigurationReader.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.Xml.Linq; using Core.Common.Base.IO; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Readers; using Ringtoets.Common.IO.Schema; using Ringtoets.Piping.IO.Properties; @@ -33,7 +34,7 @@ { /// /// This class reads a piping calculation configuration from XML and creates a collection of corresponding - /// , typically containing one or more . + /// , typically containing one or more . /// public class PipingCalculationConfigurationReader : CalculationConfigurationReader { Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/ReadPipingCalculation.cs =================================================================== diff -u -r7594d7f46113b5c5f4f41bfbd0183a3789f648b9 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/ReadPipingCalculation.cs (.../ReadPipingCalculation.cs) (revision 7594d7f46113b5c5f4f41bfbd0183a3789f648b9) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/ReadPipingCalculation.cs (.../ReadPipingCalculation.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -20,14 +20,15 @@ // All rights reserved. using System; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Readers; namespace Ringtoets.Piping.IO.Readers { /// /// Class that represents a piping calculation that is read via . /// - public class ReadPipingCalculation : IReadConfigurationItem + public class ReadPipingCalculation : IConfigurationItem { /// /// Creates a new instance of . Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Readers/PipingCalculationConfigurationReaderTest.cs =================================================================== diff -u -rf2a9c4ae5677049bb5d34537984c114965daa251 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Readers/PipingCalculationConfigurationReaderTest.cs (.../PipingCalculationConfigurationReaderTest.cs) (revision f2a9c4ae5677049bb5d34537984c114965daa251) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Readers/PipingCalculationConfigurationReaderTest.cs (.../PipingCalculationConfigurationReaderTest.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -26,6 +26,7 @@ using Core.Common.Base.IO; using Core.Common.TestUtil; using NUnit.Framework; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Readers; using Ringtoets.Piping.IO.Readers; @@ -183,7 +184,7 @@ var reader = new PipingCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -211,7 +212,7 @@ var reader = new PipingCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -231,7 +232,7 @@ var reader = new PipingCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -254,7 +255,7 @@ var reader = new PipingCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -286,7 +287,7 @@ var reader = new PipingCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -314,7 +315,7 @@ var reader = new PipingCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -342,7 +343,7 @@ var reader = new PipingCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -370,7 +371,7 @@ var reader = new PipingCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -390,7 +391,7 @@ var reader = new PipingCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); @@ -410,7 +411,7 @@ var reader = new PipingCalculationConfigurationReader(filePath); // Call - IList readConfigurationItems = reader.Read().ToList(); + IList readConfigurationItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readConfigurationItems.Count); Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Readers/ReadPipingCalculationTest.cs =================================================================== diff -u -rf0bc02e4ddd85caf9c51b909d36c31343398cd71 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Readers/ReadPipingCalculationTest.cs (.../ReadPipingCalculationTest.cs) (revision f0bc02e4ddd85caf9c51b909d36c31343398cd71) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Readers/ReadPipingCalculationTest.cs (.../ReadPipingCalculationTest.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -21,6 +21,7 @@ using System; using NUnit.Framework; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Readers; using Ringtoets.Piping.IO.Readers; @@ -47,7 +48,7 @@ var readPipingCalculation = new ReadPipingCalculation(new ReadPipingCalculation.ConstructionProperties()); // Assert - Assert.IsInstanceOf(readPipingCalculation); + Assert.IsInstanceOf(readPipingCalculation); Assert.IsNull(readPipingCalculation.Name); Assert.IsNull(readPipingCalculation.AssessmentLevel); Assert.IsNull(readPipingCalculation.HydraulicBoundaryLocation); Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/ReadWaveConditionsCalculation.cs =================================================================== diff -u -rd0a54cbc1b0f33a350874859f97f713182a3d478 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/ReadWaveConditionsCalculation.cs (.../ReadWaveConditionsCalculation.cs) (revision d0a54cbc1b0f33a350874859f97f713182a3d478) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/ReadWaveConditionsCalculation.cs (.../ReadWaveConditionsCalculation.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -21,14 +21,15 @@ using System; using Ringtoets.Common.IO; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Readers; namespace Ringtoets.Revetment.IO.Readers { /// /// Class that represents a wave conditions calculation that is read via . /// - public class ReadWaveConditionsCalculation : IReadConfigurationItem + public class ReadWaveConditionsCalculation : IConfigurationItem { /// /// Creates a new instance of . Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/WaveConditionsCalculationConfigurationReader.cs =================================================================== diff -u -re786dd8b8c7f833c217fdcddd909a616d590fe15 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/WaveConditionsCalculationConfigurationReader.cs (.../WaveConditionsCalculationConfigurationReader.cs) (revision e786dd8b8c7f833c217fdcddd909a616d590fe15) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/WaveConditionsCalculationConfigurationReader.cs (.../WaveConditionsCalculationConfigurationReader.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -24,6 +24,7 @@ using System.Xml.Linq; using Core.Common.Base.IO; using Ringtoets.Common.IO; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Readers; using Ringtoets.Common.IO.Schema; using Ringtoets.Revetment.IO.Properties; @@ -33,7 +34,7 @@ { /// /// This class reads a wave conditions calculation configuration from XML and creates a collection of corresponding - /// , typically containing one or more . + /// , typically containing one or more . /// public class WaveConditionsCalculationConfigurationReader : CalculationConfigurationReader { Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Readers/ReadWaveConditionsCalculationTest.cs =================================================================== diff -u -rd0a54cbc1b0f33a350874859f97f713182a3d478 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Readers/ReadWaveConditionsCalculationTest.cs (.../ReadWaveConditionsCalculationTest.cs) (revision d0a54cbc1b0f33a350874859f97f713182a3d478) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Readers/ReadWaveConditionsCalculationTest.cs (.../ReadWaveConditionsCalculationTest.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -22,6 +22,7 @@ using System; using NUnit.Framework; using Ringtoets.Common.IO; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Readers; using Ringtoets.Revetment.IO.Readers; @@ -48,7 +49,7 @@ var readCalculation = new ReadWaveConditionsCalculation(new ReadWaveConditionsCalculation.ConstructionProperties()); // Assert - Assert.IsInstanceOf(readCalculation); + Assert.IsInstanceOf(readCalculation); Assert.IsNull(readCalculation.Name); Assert.IsNull(readCalculation.HydraulicBoundaryLocation); Assert.IsNull(readCalculation.UpperBoundaryRevetment); Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Readers/WaveConditionsCalculationConfigurationReaderTest.cs =================================================================== diff -u -r5d7d6070e020dcc02fefb624d582c958d9bd9890 -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 --- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Readers/WaveConditionsCalculationConfigurationReaderTest.cs (.../WaveConditionsCalculationConfigurationReaderTest.cs) (revision 5d7d6070e020dcc02fefb624d582c958d9bd9890) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Readers/WaveConditionsCalculationConfigurationReaderTest.cs (.../WaveConditionsCalculationConfigurationReaderTest.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) @@ -27,6 +27,7 @@ using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.IO; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Readers; using Ringtoets.Revetment.IO.Readers; @@ -211,7 +212,7 @@ var reader = new WaveConditionsCalculationConfigurationReader(filePath); // Call - List readItems = reader.Read().ToList(); + List readItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readItems.Count); @@ -241,7 +242,7 @@ var reader = new WaveConditionsCalculationConfigurationReader(filePath); // Call - List readItems = reader.Read().ToList(); + List readItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readItems.Count); @@ -262,7 +263,7 @@ var reader = new WaveConditionsCalculationConfigurationReader(filePath); // Call - List readItems = reader.Read().ToList(); + List readItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readItems.Count); @@ -285,7 +286,7 @@ var reader = new WaveConditionsCalculationConfigurationReader(filePath); // Call - List readItems = reader.Read().ToList(); + List readItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readItems.Count); @@ -316,7 +317,7 @@ var reader = new WaveConditionsCalculationConfigurationReader(filePath); // Call - List readItems = reader.Read().ToList(); + List readItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readItems.Count); @@ -346,7 +347,7 @@ var reader = new WaveConditionsCalculationConfigurationReader(filePath); // Call - List readItems = reader.Read().ToList(); + List readItems = reader.Read().ToList(); // Assert Assert.AreEqual(1, readItems.Count);