Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/GrassCoverErosionOutwardsCalculationConfigurationWriter.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/GrassCoverErosionOutwardsCalculationConfigurationWriter.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/GrassCoverErosionOutwardsCalculationConfigurationWriter.cs (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,40 @@ +// 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.Xml; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.GrassCoverErosionOutwards.Data; +using Ringtoets.Revetment.IO; + +namespace Ringtoets.GrassCoverErosionOutwards.IO +{ + /// + /// A writer for writing out configurations of and + /// , to XML format. + /// + public class GrassCoverErosionOutwardsCalculationConfigurationWriter : WaveConditionsCalculationConfigurationWriter + { + protected override void WriteCalculation(GrassCoverErosionOutwardsWaveConditionsCalculation calculation, XmlWriter writer) + { + WriteCalculation(calculation.Name, calculation.InputParameters, writer); + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/GrassCoverErosionOutwardsConfigurationExporter.cs =================================================================== diff -u -r00a4b6318d0d1ae57df5ef362ba1e8908aa330be -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/GrassCoverErosionOutwardsConfigurationExporter.cs (.../GrassCoverErosionOutwardsConfigurationExporter.cs) (revision 00a4b6318d0d1ae57df5ef362ba1e8908aa330be) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/GrassCoverErosionOutwardsConfigurationExporter.cs (.../GrassCoverErosionOutwardsConfigurationExporter.cs) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -31,7 +31,7 @@ /// Exports a grass cover erosion outwards configuration and stores it as an XML file. /// public class GrassCoverErosionOutwardsConfigurationExporter - : ConfigurationExporter + : ConfigurationExporter { /// /// Creates a new instance of . Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/GrassCoverErosionOutwardsConfigurationWriter.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Ringtoets.GrassCoverErosionOutwards.IO.csproj =================================================================== diff -u -r467a5dba1d4b29b2035d6d034a083125854077dc -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Ringtoets.GrassCoverErosionOutwards.IO.csproj (.../Ringtoets.GrassCoverErosionOutwards.IO.csproj) (revision 467a5dba1d4b29b2035d6d034a083125854077dc) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Ringtoets.GrassCoverErosionOutwards.IO.csproj (.../Ringtoets.GrassCoverErosionOutwards.IO.csproj) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -45,7 +45,7 @@ Properties\GlobalAssembly.cs - + Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/GrassCoverErosionOutwardsCalculationConfigurationWriterTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/GrassCoverErosionOutwardsCalculationConfigurationWriterTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/GrassCoverErosionOutwardsCalculationConfigurationWriterTest.cs (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,104 @@ +// 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.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.TestUtil; +using Ringtoets.GrassCoverErosionOutwards.Data; +using Ringtoets.Revetment.Data; +using Ringtoets.Revetment.IO; + +namespace Ringtoets.GrassCoverErosionOutwards.IO.Test +{ + [TestFixture] + public class GrassCoverErosionOutwardsCalculationConfigurationWriterTest + { + [Test] + public void Constructor_Always_CreateWaveConditionsInputWriter() + { + // Call + var writer = new GrassCoverErosionOutwardsCalculationConfigurationWriter(); + + // Assert + Assert.IsInstanceOf>(writer); + } + + [Test] + public void Write_GroupWithCalculationAndOtherGroup_WritesOutCalculationAndGroupToFile() + { + // Setup + string filePath = TestHelper.GetScratchPadPath("Write_GroupWithCalculationAndOtherGroup.xml"); + string expectedXmlFilePath = TestHelper.GetTestDataPath( + TestDataPath.Ringtoets.GrassCoverErosionOutwards.IO, + Path.Combine(nameof(GrassCoverErosionOutwardsCalculationConfigurationWriter), "calculationAndGroupWithNesting.xml")); + + var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation + { + Name = "Berekening 1", + InputParameters = + { + HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("hr_locatie_2"), + UpperBoundaryRevetment = (RoundedDouble) 2.5, + LowerBoundaryRevetment = (RoundedDouble) 1.3, + UpperBoundaryWaterLevels = (RoundedDouble) 2.2, + LowerBoundaryWaterLevels = (RoundedDouble) (-0.2), + StepSize = WaveConditionsInputStepSize.Two, + ForeshoreProfile = new TestForeshoreProfile("profiel2"), + Orientation = (RoundedDouble) 12.3, + UseForeshore = true, + UseBreakWater = true, + BreakWater = + { + Height = (RoundedDouble) 2.11, + Type = BreakWaterType.Wall + } + } + }; + + var calculationGroup = new CalculationGroup("NestedGroup", false); + try + { + var writer = new GrassCoverErosionOutwardsCalculationConfigurationWriter(); + + // Call + writer.Write(new ICalculationBase[] + { + calculation, + calculationGroup + }, filePath); + + // Assert + string actualXml = File.ReadAllText(filePath); + string expectedXml = File.ReadAllText(expectedXmlFilePath); + + Assert.AreEqual(expectedXml, actualXml); + } + finally + { + File.Delete(filePath); + } + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/GrassCoverErosionOutwardsConfigurationExporterTest.cs =================================================================== diff -u -r00a4b6318d0d1ae57df5ef362ba1e8908aa330be -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/GrassCoverErosionOutwardsConfigurationExporterTest.cs (.../GrassCoverErosionOutwardsConfigurationExporterTest.cs) (revision 00a4b6318d0d1ae57df5ef362ba1e8908aa330be) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/GrassCoverErosionOutwardsConfigurationExporterTest.cs (.../GrassCoverErosionOutwardsConfigurationExporterTest.cs) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -43,7 +43,7 @@ // Assert Assert.IsInstanceOf< ConfigurationExporter< - GrassCoverErosionOutwardsConfigurationWriter, + GrassCoverErosionOutwardsCalculationConfigurationWriter, GrassCoverErosionOutwardsWaveConditionsCalculation>>(exporter); } Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/GrassCoverErosionOutwardsConfigurationWriterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Ringtoets.GrassCoverErosionOutwards.IO.Test.csproj =================================================================== diff -u -r90555cd02cecb2d187e60946deb3d5415cbb3b18 -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Ringtoets.GrassCoverErosionOutwards.IO.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.IO.Test.csproj) (revision 90555cd02cecb2d187e60946deb3d5415cbb3b18) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Ringtoets.GrassCoverErosionOutwards.IO.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.IO.Test.csproj) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -51,7 +51,7 @@ Properties\GlobalAssembly.cs - + Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsCalculationConfigurationWriter/calculationAndGroupWithNesting.xml =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsCalculationConfigurationWriter/calculationAndGroupWithNesting.xml (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsCalculationConfigurationWriter/calculationAndGroupWithNesting.xml (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,20 @@ + + + + hr_locatie_2 + 2.5 + 1.3 + 2.2 + -0.2 + 2.0 + profiel2 + 12.3 + + true + verticalewand + 2.11 + true + + + + \ No newline at end of file Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsConfigurationWriter/calculationAndGroupWithNesting.xml'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Exporters/PipingCalculationConfigurationWriter.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Exporters/PipingCalculationConfigurationWriter.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Exporters/PipingCalculationConfigurationWriter.cs (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,97 @@ +// 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.Xml; +using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Common.IO.Schema; +using Ringtoets.Common.IO.Writers; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.IO.Schema; + +namespace Ringtoets.Piping.IO.Exporters +{ + /// + /// Writer for writing a piping configuration to XML. + /// + public class PipingCalculationConfigurationWriter : CalculationConfigurationWriter + { + protected override void WriteCalculation(PipingCalculation calculation, XmlWriter writer) + { + writer.WriteStartElement(ConfigurationSchemaIdentifiers.CalculationElement); + writer.WriteAttributeString(ConfigurationSchemaIdentifiers.NameAttribute, calculation.Name); + + PipingInput calculationInputParameters = calculation.InputParameters; + + if (calculationInputParameters.UseAssessmentLevelManualInput) + { + writer.WriteElementString(PipingConfigurationSchemaIdentifiers.AssessmentLevelElement, + XmlConvert.ToString(calculationInputParameters.AssessmentLevel)); + } + else if (calculationInputParameters.HydraulicBoundaryLocation != null) + { + writer.WriteElementString(ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement, + calculationInputParameters.HydraulicBoundaryLocation.Name); + } + + if (calculationInputParameters.SurfaceLine != null) + { + writer.WriteElementString(PipingConfigurationSchemaIdentifiers.SurfaceLineElement, + calculationInputParameters.SurfaceLine.Name); + writer.WriteElementString(PipingConfigurationSchemaIdentifiers.EntryPointLElement, + XmlConvert.ToString(calculationInputParameters.EntryPointL)); + writer.WriteElementString(PipingConfigurationSchemaIdentifiers.ExitPointLElement, + XmlConvert.ToString(calculationInputParameters.ExitPointL)); + } + + if (calculationInputParameters.StochasticSoilModel != null) + { + writer.WriteElementString(PipingConfigurationSchemaIdentifiers.StochasticSoilModelElement, + calculationInputParameters.StochasticSoilModel.Name); + + if (calculationInputParameters.StochasticSoilProfile?.SoilProfile != null) + { + writer.WriteElementString(PipingConfigurationSchemaIdentifiers.StochasticSoilProfileElement, + calculationInputParameters.StochasticSoilProfile.SoilProfile.Name); + } + } + + WriteDistributions(CreateInputDistributions(calculationInputParameters), writer); + + writer.WriteEndElement(); + } + + private static IDictionary CreateInputDistributions(PipingInput calculationInputParameters) + { + return new Dictionary + { + { + PipingConfigurationSchemaIdentifiers.PhreaticLevelExitStochastName, + calculationInputParameters.PhreaticLevelExit + }, + { + PipingConfigurationSchemaIdentifiers.DampingFactorExitStochastName, + calculationInputParameters.DampingFactorExit + } + }; + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Exporters/PipingConfigurationExporter.cs =================================================================== diff -u -r00a4b6318d0d1ae57df5ef362ba1e8908aa330be -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Exporters/PipingConfigurationExporter.cs (.../PipingConfigurationExporter.cs) (revision 00a4b6318d0d1ae57df5ef362ba1e8908aa330be) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Exporters/PipingConfigurationExporter.cs (.../PipingConfigurationExporter.cs) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -30,7 +30,7 @@ /// /// Exports a piping configuration and stores it as an XML file. /// - public class PipingConfigurationExporter : ConfigurationExporter + public class PipingConfigurationExporter : ConfigurationExporter { /// /// Creates a new instance of . Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Exporters/PipingConfigurationWriter.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj =================================================================== diff -u -r7594d7f46113b5c5f4f41bfbd0183a3789f648b9 -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 7594d7f46113b5c5f4f41bfbd0183a3789f648b9) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -53,7 +53,7 @@ - + Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Exporters/PipingCalculationConfigurationWriterTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Exporters/PipingCalculationConfigurationWriterTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Exporters/PipingCalculationConfigurationWriterTest.cs (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,260 @@ +// 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.Security.AccessControl; +using Core.Common.Base.Data; +using Core.Common.IO.Exceptions; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Integration.TestUtils; +using Ringtoets.Piping.IO.Exporters; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.IO.Test.Exporters +{ + [TestFixture] + public class PipingCalculationConfigurationWriterTest + { + private static IEnumerable Calculations + { + get + { + yield return new TestCaseData("calculationWithoutHydraulicLocation", + PipingTestDataGenerator.GetPipingCalculationWithoutHydraulicLocationAndAssessmentLevel()) + .SetName("calculationWithoutHydraulicLocation"); + yield return new TestCaseData("calculationWithAssessmentLevel", + PipingTestDataGenerator.GetPipingCalculationWithAssessmentLevel()) + .SetName("calculationWithAssessmentLevel"); + yield return new TestCaseData("calculationWithoutSurfaceLine", + PipingTestDataGenerator.GetPipingCalculationWithoutSurfaceLine()) + .SetName("calculationWithoutSurfaceLine"); + yield return new TestCaseData("calculationWithoutSoilModel", + PipingTestDataGenerator.GetPipingCalculationWithoutSoilModel()) + .SetName("calculationWithoutSoilModel"); + yield return new TestCaseData("calculationWithoutSoilProfile", + PipingTestDataGenerator.GetPipingCalculationWithoutSoilProfile()) + .SetName("calculationWithoutSoilProfile"); + yield return new TestCaseData("calculationWithNaNs", + PipingTestDataGenerator.GetPipingCalculationWithNaNs()) + .SetName("calculationWithNaNs"); + yield return new TestCaseData("calculationWithInfinities", + PipingTestDataGenerator.GetPipingCalculationWithInfinities()) + .SetName("calculationWithInfinities"); + } + } + + [Test] + public void Write_ConfigurationNull_ThrowArgumentNullException() + { + // Call + TestDelegate test = () => new PipingCalculationConfigurationWriter().Write(null, string.Empty); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("configuration", exception.ParamName); + } + + [Test] + public void Write_FilePathNull_ThrowArgumentNullException() + { + // Call + TestDelegate test = () => new PipingCalculationConfigurationWriter().Write(Enumerable.Empty(), null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("filePath", exception.ParamName); + } + + [Test] + [TestCase("")] + [TestCase(" ")] + [TestCase("c:\\>")] + public void Write_FilePathInvalid_ThrowCriticalFileWriteException(string filePath) + { + // Call + TestDelegate call = () => new PipingCalculationConfigurationWriter().Write(Enumerable.Empty(), filePath); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual($"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + + [Test] + public void Write_FilePathTooLong_ThrowCriticalFileWriteException() + { + // Setup + var filePath = new string('a', 249); + + // Call + TestDelegate call = () => new PipingCalculationConfigurationWriter().Write(Enumerable.Empty(), filePath); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual($"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + + [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); + + // Call + TestDelegate call = () => new PipingCalculationConfigurationWriter().Write(Enumerable.Empty(), filePath); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual($"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + } + + [Test] + public void Write_FileInUse_ThrowCriticalFileWriteException() + { + // Setup + string path = TestHelper.GetScratchPadPath(nameof(Write_FileInUse_ThrowCriticalFileWriteException)); + + using (var fileDisposeHelper = new FileDisposeHelper(path)) + { + fileDisposeHelper.LockFiles(); + + // Call + TestDelegate call = () => new PipingCalculationConfigurationWriter().Write(Enumerable.Empty(), path); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual($"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{path}'.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + } + + [Test] + public void Write_CalculationGroupsAndCalculation_ValidFile() + { + // Setup + string filePath = TestHelper.GetScratchPadPath("test.xml"); + + PipingCalculation calculation = PipingTestDataGenerator.GetPipingCalculation(); + calculation.InputParameters.EntryPointL = (RoundedDouble) 0.1; + calculation.InputParameters.ExitPointL = (RoundedDouble) 0.2; + + PipingCalculation calculation2 = PipingTestDataGenerator.GetPipingCalculation(); + calculation2.Name = "PK001_0002 W1-6_4_1D1"; + calculation2.InputParameters.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "PUNT_SCH_17", 0, 0); + calculation2.InputParameters.SurfaceLine.Name = "PK001_0002"; + calculation2.InputParameters.EntryPointL = (RoundedDouble) 0.3; + calculation2.InputParameters.ExitPointL = (RoundedDouble) 0.4; + calculation2.InputParameters.StochasticSoilModel = new StochasticSoilModel(1, "PK001_0002_Piping", string.Empty); + calculation2.InputParameters.StochasticSoilProfile = new StochasticSoilProfile(0, SoilProfileType.SoilProfile1D, 0) + { + SoilProfile = new PipingSoilProfile("W1-6_4_1D1", 0, new[] + { + new PipingSoilLayer(0) + }, SoilProfileType.SoilProfile1D, 0) + }; + + var calculationGroup2 = new CalculationGroup("PK001_0002", false) + { + Children = + { + calculation2 + } + }; + + var calculationGroup = new CalculationGroup("PK001_0001", false) + { + Children = + { + calculation, + calculationGroup2 + } + }; + + try + { + // Call + new PipingCalculationConfigurationWriter().Write(new[] + { + calculationGroup + }, filePath); + + // Assert + Assert.IsTrue(File.Exists(filePath)); + + string actualXml = File.ReadAllText(filePath); + string expectedXmlFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, + Path.Combine("PipingCalculationConfigurationWriter", + "folderWithSubfolderAndCalculation.xml")); + string expectedXml = File.ReadAllText(expectedXmlFilePath); + + Assert.AreEqual(expectedXml, actualXml); + } + finally + { + File.Delete(filePath); + } + } + + [Test] + [TestCaseSource(nameof(Calculations))] + public void Write_ValidCalculationCalculation_ValidFile(string expectedFileName, PipingCalculation calculation) + { + // Setup + string filePath = TestHelper.GetScratchPadPath("test.xml"); + + try + { + // Call + new PipingCalculationConfigurationWriter().Write(new[] + { + calculation + }, filePath); + + // Assert + Assert.IsTrue(File.Exists(filePath)); + + string actualXml = File.ReadAllText(filePath); + string expectedXmlFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, Path.Combine("PipingCalculationConfigurationWriter", $"{expectedFileName}.xml")); + string expectedXml = File.ReadAllText(expectedXmlFilePath); + + Assert.AreEqual(expectedXml, actualXml); + } + finally + { + File.Delete(filePath); + } + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Exporters/PipingConfigurationExporterTest.cs =================================================================== diff -u -r00a4b6318d0d1ae57df5ef362ba1e8908aa330be -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Exporters/PipingConfigurationExporterTest.cs (.../PipingConfigurationExporterTest.cs) (revision 00a4b6318d0d1ae57df5ef362ba1e8908aa330be) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Exporters/PipingConfigurationExporterTest.cs (.../PipingConfigurationExporterTest.cs) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -47,7 +47,7 @@ var exporter = new PipingConfigurationExporter(Enumerable.Empty(), "test.xml"); // Assert - Assert.IsInstanceOf>(exporter); + Assert.IsInstanceOf>(exporter); } [Test] @@ -108,7 +108,7 @@ string actualXml = File.ReadAllText(filePath); string expectedXmlFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, - Path.Combine("PipingConfigurationWriter", "folderWithSubfolderAndCalculation.xml")); + Path.Combine("PipingCalculationConfigurationWriter", "folderWithSubfolderAndCalculation.xml")); string expectedXml = File.ReadAllText(expectedXmlFilePath); Assert.AreEqual(expectedXml, actualXml); Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Exporters/PipingConfigurationWriterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj =================================================================== diff -u -r7594d7f46113b5c5f4f41bfbd0183a3789f648b9 -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 7594d7f46113b5c5f4f41bfbd0183a3789f648b9) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -73,7 +73,7 @@ - + Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithAssessmentLevel.xml =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithAssessmentLevel.xml (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithAssessmentLevel.xml (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,21 @@ + + + + 3 + PK001_0001 + 0 + 10 + PK001_0001_Piping + W1-6_0_1D1 + + + 0 + 0.1 + + + 0.7 + 0.1 + + + + \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithInfinities.xml =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithInfinities.xml (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithInfinities.xml (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,21 @@ + + + + -INF + PK001_0001 + -INF + INF + PK001_0001_Piping + W1-6_0_1D1 + + + -INF + INF + + + INF + INF + + + + \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithNaNs.xml =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithNaNs.xml (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithNaNs.xml (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,21 @@ + + + + NaN + PK001_0001 + NaN + NaN + PK001_0001_Piping + W1-6_0_1D1 + + + NaN + NaN + + + NaN + NaN + + + + \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithoutHydraulicLocation.xml =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithoutHydraulicLocation.xml (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithoutHydraulicLocation.xml (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,20 @@ + + + + PK001_0001 + 0 + 10 + PK001_0001_Piping + W1-6_0_1D1 + + + 0 + 0.1 + + + 0.7 + 0.1 + + + + \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithoutSoilProfile.xml =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithoutSoilProfile.xml (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithoutSoilProfile.xml (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,20 @@ + + + + PUNT_KAT_18 + PK001_0001 + 0 + 10 + PK001_0001_Piping + + + 0 + 0.1 + + + 0.7 + 0.1 + + + + \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithoutSoilmodel.xml =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithoutSoilmodel.xml (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithoutSoilmodel.xml (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,19 @@ + + + + PUNT_KAT_18 + PK001_0001 + 0 + 10 + + + 0 + 0.1 + + + 0.7 + 0.1 + + + + \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithoutSurfaceline.xml =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithoutSurfaceline.xml (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/calculationWithoutSurfaceline.xml (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,18 @@ + + + + PUNT_KAT_18 + PK001_0001_Piping + W1-6_0_1D1 + + + 0 + 0.1 + + + 0.7 + 0.1 + + + + \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/folderWithSubfolderAndCalculation.xml =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/folderWithSubfolderAndCalculation.xml (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingCalculationConfigurationWriter/folderWithSubfolderAndCalculation.xml (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,43 @@ + + + + + PUNT_KAT_18 + PK001_0001 + 0.1 + 0.2 + PK001_0001_Piping + W1-6_0_1D1 + + + 0 + 0.1 + + + 0.7 + 0.1 + + + + + + PUNT_SCH_17 + PK001_0002 + 0.3 + 0.4 + PK001_0002_Piping + W1-6_4_1D1 + + + 0 + 0.1 + + + 0.7 + 0.1 + + + + + + \ No newline at end of file Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingConfigurationWriter/calculationWithAssessmentLevel.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingConfigurationWriter/calculationWithInfinities.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingConfigurationWriter/calculationWithNaNs.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingConfigurationWriter/calculationWithoutHydraulicLocation.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingConfigurationWriter/calculationWithoutSoilProfile.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingConfigurationWriter/calculationWithoutSoilmodel.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingConfigurationWriter/calculationWithoutSurfaceline.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingConfigurationWriter/folderWithSubfolderAndCalculation.xml'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/WaveConditionsCalculationConfigurationReader.cs =================================================================== diff -u -r7594d7f46113b5c5f4f41bfbd0183a3789f648b9 -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/WaveConditionsCalculationConfigurationReader.cs (.../WaveConditionsCalculationConfigurationReader.cs) (revision 7594d7f46113b5c5f4f41bfbd0183a3789f648b9) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/WaveConditionsCalculationConfigurationReader.cs (.../WaveConditionsCalculationConfigurationReader.cs) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -82,17 +82,17 @@ HydraulicBoundaryLocation = CalculationConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement, ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement), UpperBoundaryRevetment = CalculationConfigurationReaderHelper.GetDoubleValueFromDescendantElement(calculationElement, - WaveConditionsInputConfigurationSchemaIdentifiers.UpperBoundaryRevetment), + WaveConditionsConfigurationSchemaIdentifiers.UpperBoundaryRevetment), LowerBoundaryRevetment = CalculationConfigurationReaderHelper.GetDoubleValueFromDescendantElement(calculationElement, - WaveConditionsInputConfigurationSchemaIdentifiers.LowerBoundaryRevetment), + WaveConditionsConfigurationSchemaIdentifiers.LowerBoundaryRevetment), UpperBoundaryWaterLevels = CalculationConfigurationReaderHelper.GetDoubleValueFromDescendantElement(calculationElement, - WaveConditionsInputConfigurationSchemaIdentifiers.UpperBoundaryWaterLevels), + WaveConditionsConfigurationSchemaIdentifiers.UpperBoundaryWaterLevels), LowerBoundaryWaterLevels = CalculationConfigurationReaderHelper.GetDoubleValueFromDescendantElement(calculationElement, - WaveConditionsInputConfigurationSchemaIdentifiers.LowerBoundaryWaterLevels), + WaveConditionsConfigurationSchemaIdentifiers.LowerBoundaryWaterLevels), StepSize = CalculationConfigurationReaderHelper.GetDoubleValueFromDescendantElement(calculationElement, - WaveConditionsInputConfigurationSchemaIdentifiers.StepSize), + WaveConditionsConfigurationSchemaIdentifiers.StepSize), ForeshoreProfile = CalculationConfigurationReaderHelper.GetStringValueFromDescendantElement(calculationElement, - WaveConditionsInputConfigurationSchemaIdentifiers.ForeshoreProfile), + WaveConditionsConfigurationSchemaIdentifiers.ForeshoreProfile), Orientation = CalculationConfigurationReaderHelper.GetDoubleValueFromDescendantElement(calculationElement, ConfigurationSchemaIdentifiers.Orientation), UseBreakWater = GetBoolValueFromChildElement(calculationElement, Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Ringtoets.Revetment.IO.csproj =================================================================== diff -u -r7594d7f46113b5c5f4f41bfbd0183a3789f648b9 -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Ringtoets.Revetment.IO.csproj (.../Ringtoets.Revetment.IO.csproj) (revision 7594d7f46113b5c5f4f41bfbd0183a3789f648b9) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Ringtoets.Revetment.IO.csproj (.../Ringtoets.Revetment.IO.csproj) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -57,8 +57,8 @@ - - + + Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditionsCalculationConfigurationWriter.cs =================================================================== diff -u --- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditionsCalculationConfigurationWriter.cs (revision 0) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditionsCalculationConfigurationWriter.cs (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -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.Xml; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.IO.Schema; +using Ringtoets.Common.IO.Writers; +using Ringtoets.Revetment.Data; + +namespace Ringtoets.Revetment.IO +{ + /// + /// Base implementation of a writer for calculations that contain as input, + /// to XML format. + /// + /// The type of calculations that are written to file. + public abstract class WaveConditionsCalculationConfigurationWriter : CalculationConfigurationWriter where T : class, ICalculation + { + private readonly WaveConditionsInputStepSizeTypeConverter waveConditionsInputStepSizeConverter; + + protected WaveConditionsCalculationConfigurationWriter() + { + waveConditionsInputStepSizeConverter = new WaveConditionsInputStepSizeTypeConverter(); + } + + /// + /// Writes a single calculation with its in XML format to file. + /// + /// The name of the calculation to write. + /// The input of the calculation to write. + /// The writer to use for writing. + protected void WriteCalculation(string name, WaveConditionsInput input, XmlWriter writer) + { + writer.WriteStartElement(ConfigurationSchemaIdentifiers.CalculationElement); + writer.WriteAttributeString(ConfigurationSchemaIdentifiers.NameAttribute, name); + + WriteHydraulicBoundaryLocation(input.HydraulicBoundaryLocation, writer); + + writer.WriteElementString( + WaveConditionsConfigurationSchemaIdentifiers.UpperBoundaryRevetment, + XmlConvert.ToString(input.UpperBoundaryRevetment)); + writer.WriteElementString( + WaveConditionsConfigurationSchemaIdentifiers.LowerBoundaryRevetment, + XmlConvert.ToString(input.LowerBoundaryRevetment)); + writer.WriteElementString( + WaveConditionsConfigurationSchemaIdentifiers.UpperBoundaryWaterLevels, + XmlConvert.ToString(input.UpperBoundaryWaterLevels)); + writer.WriteElementString( + WaveConditionsConfigurationSchemaIdentifiers.LowerBoundaryWaterLevels, + XmlConvert.ToString(input.LowerBoundaryWaterLevels)); + writer.WriteElementString( + WaveConditionsConfigurationSchemaIdentifiers.StepSize, + waveConditionsInputStepSizeConverter.ConvertToInvariantString(input.StepSize)); + + WriteForeshoreProfile(input.ForeshoreProfile, writer); + + writer.WriteElementString( + ConfigurationSchemaIdentifiers.Orientation, + XmlConvert.ToString(input.Orientation)); + + WriteWaveReduction(input, writer); + + writer.WriteEndElement(); + } + + private static void WriteHydraulicBoundaryLocation(HydraulicBoundaryLocation hydraulicBoundaryLocation, XmlWriter writer) + { + if (hydraulicBoundaryLocation != null) + { + writer.WriteElementString( + ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElement, + hydraulicBoundaryLocation.Name); + } + } + + private static void WriteForeshoreProfile(ForeshoreProfile foreshoreProfile, XmlWriter writer) + { + if (foreshoreProfile != null) + { + writer.WriteElementString( + WaveConditionsConfigurationSchemaIdentifiers.ForeshoreProfile, + foreshoreProfile.Name); + } + } + + private static void WriteWaveReduction(WaveConditionsInput input, XmlWriter writer) + { + writer.WriteStartElement(ConfigurationSchemaIdentifiers.WaveReduction); + + writer.WriteElementString( + ConfigurationSchemaIdentifiers.UseBreakWater, + XmlConvert.ToString(input.UseBreakWater)); + + WriteBreakWaterProperties(input.BreakWater, writer); + + writer.WriteElementString( + ConfigurationSchemaIdentifiers.UseForeshore, + XmlConvert.ToString(input.UseForeshore)); + + writer.WriteEndElement(); + } + } +} \ No newline at end of file Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditionsConfigurationSchemaIdentifiers.cs =================================================================== diff -u --- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditionsConfigurationSchemaIdentifiers.cs (revision 0) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditionsConfigurationSchemaIdentifiers.cs (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,59 @@ +// 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.Revetment.IO +{ + /// + /// Container of identifiers related to the piping configuration schema definition. + /// + internal static class WaveConditionsConfigurationSchemaIdentifiers + { + /// + /// The tag of elements containing the upper boundary of revetment. + /// + internal const string UpperBoundaryRevetment = "bovengrensbekleding"; + + /// + /// The tag of elements containing the lower boundary of revetment. + /// + internal const string LowerBoundaryRevetment = "ondergrensbekleding"; + + /// + /// The tag of elements containing the upper boundary of water level. + /// + internal const string UpperBoundaryWaterLevels = "bovengrenswaterstanden"; + + /// + /// The tag of elements containing the lower boundary of water level. + /// + internal const string LowerBoundaryWaterLevels = "ondergrenswaterstanden"; + + /// + /// The tag of elements containing the step size of the water levels. + /// + internal const string StepSize = "stapgrootte"; + + /// + /// The tag of elements containing the name of the foreshore profile. + /// + internal const string ForeshoreProfile = "voorlandprofiel"; + } +} \ No newline at end of file Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditionsInputConfigurationSchemaIdentifiers.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditionsInputConfigurationWriter.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Ringtoets.Revetment.IO.Test.csproj =================================================================== diff -u -r7594d7f46113b5c5f4f41bfbd0183a3789f648b9 -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Ringtoets.Revetment.IO.Test.csproj (.../Ringtoets.Revetment.IO.Test.csproj) (revision 7594d7f46113b5c5f4f41bfbd0183a3789f648b9) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Ringtoets.Revetment.IO.Test.csproj (.../Ringtoets.Revetment.IO.Test.csproj) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -56,7 +56,7 @@ - + Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/WaveConditionsCalculationConfigurationWriterTest.cs =================================================================== diff -u --- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/WaveConditionsCalculationConfigurationWriterTest.cs (revision 0) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/WaveConditionsCalculationConfigurationWriterTest.cs (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,179 @@ +// 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.Xml; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.IO.Writers; +using Ringtoets.Revetment.Data; + +namespace Ringtoets.Revetment.IO.Test +{ + [TestFixture] + public class WaveConditionsCalculationConfigurationWriterTest + { + [Test] + public void Constructor_Always_ReturnsConfigurationWriter() + { + // Call + var writer = new SimpleWaveConditionsCalculationConfigurationWriter(); + + // Assert + Assert.IsInstanceOf>(writer); + } + + [Test] + public void WriteCalculation_SparseCalculation_WritesSparseConfigurationToFile() + { + // Setup + string filePath = TestHelper.GetScratchPadPath( + $"{nameof(WriteCalculation_SparseCalculation_WritesSparseConfigurationToFile)}.xml"); + + string expectedXmlFilePath = TestHelper.GetTestDataPath( + TestDataPath.Ringtoets.Revetment.IO, + Path.Combine(nameof(WaveConditionsCalculationConfigurationWriter), "sparseConfiguration.xml")); + + var calculation = new SimpleWaveConditionsCalculation + { + Name = "Berekening 1" + }; + + try + { + using (XmlWriter xmlWriter = CreateXmlWriter(filePath)) + { + var writer = new SimpleWaveConditionsCalculationConfigurationWriter(); + + // Call + writer.PublicWriteCalculation(calculation, xmlWriter); + } + + // Assert + string actualXml = File.ReadAllText(filePath); + string expectedXml = File.ReadAllText(expectedXmlFilePath); + + Assert.AreEqual(expectedXml, actualXml); + } + finally + { + File.Delete(filePath); + } + } + + [Test] + public void WriteCalculation_CompleteCalculation_WritesCompleteConfigurationToFile() + { + // Setup + string filePath = TestHelper.GetScratchPadPath( + $"{nameof(WriteCalculation_CompleteCalculation_WritesCompleteConfigurationToFile)}.xml"); + + string expectedXmlFilePath = TestHelper.GetTestDataPath( + TestDataPath.Ringtoets.Revetment.IO, + Path.Combine(nameof(WaveConditionsCalculationConfigurationWriter), "completeConfiguration.xml")); + + var calculation = new SimpleWaveConditionsCalculation + { + Name = "Berekening 1", + Input = + { + HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("Locatie1"), + UpperBoundaryRevetment = (RoundedDouble) 1.5, + LowerBoundaryRevetment = (RoundedDouble) 0.5, + UpperBoundaryWaterLevels = (RoundedDouble) 1.4, + LowerBoundaryWaterLevels = (RoundedDouble) 0.6, + StepSize = WaveConditionsInputStepSize.One, + ForeshoreProfile = new TestForeshoreProfile("profiel1"), + Orientation = (RoundedDouble) 67.1, + UseForeshore = true, + UseBreakWater = true, + BreakWater = + { + Height = (RoundedDouble) 1.23, + Type = BreakWaterType.Dam + } + } + }; + + try + { + using (XmlWriter xmlWriter = CreateXmlWriter(filePath)) + { + var writer = new SimpleWaveConditionsCalculationConfigurationWriter(); + + // Call + writer.PublicWriteCalculation(calculation, xmlWriter); + } + + // Assert + string actualXml = File.ReadAllText(filePath); + string expectedXml = File.ReadAllText(expectedXmlFilePath); + + Assert.AreEqual(expectedXml, actualXml); + } + finally + { + File.Delete(filePath); + } + } + + private static XmlWriter CreateXmlWriter(string filePath) + { + return XmlWriter.Create(filePath, new XmlWriterSettings + { + Indent = true + }); + } + } + + public class SimpleWaveConditionsCalculationConfigurationWriter : WaveConditionsCalculationConfigurationWriter + { + public void PublicWriteCalculation(SimpleWaveConditionsCalculation calculation, XmlWriter writer) + { + WriteCalculation(calculation, writer); + } + + protected override void WriteCalculation(SimpleWaveConditionsCalculation calculation, XmlWriter writer) + { + WriteCalculation(calculation.Name, calculation.Input, writer); + } + } + + public class SimpleWaveConditionsCalculation : Observable, ICalculation + { + public WaveConditionsInput Input { get; } = new WaveConditionsInput(); + public string Name { get; set; } + public bool HasOutput { get; } + public Comment Comments { get; } + + public void ClearOutput() + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/WaveConditionsInputConfigurationWriterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationWriter/completeConfiguration.xml =================================================================== diff -u --- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationWriter/completeConfiguration.xml (revision 0) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationWriter/completeConfiguration.xml (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,17 @@ + + + Locatie1 + 1.5 + 0.5 + 1.4 + 0.6 + 1.0 + profiel1 + 67.1 + + true + havendam + 1.23 + true + + \ No newline at end of file Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationWriter/sparseConfiguration.xml =================================================================== diff -u --- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationWriter/sparseConfiguration.xml (revision 0) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationWriter/sparseConfiguration.xml (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,15 @@ + + + NaN + NaN + NaN + NaN + 0.5 + NaN + + false + havendam + 0 + false + + \ No newline at end of file Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationWriter/completeConfiguration.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsInputConfigurationWriter/sparseConfiguration.xml'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.IO/Ringtoets.StabilityStoneCover.IO.csproj =================================================================== diff -u -r633aedbd4c882f2811c3e8e6653ef352301c40b5 -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.IO/Ringtoets.StabilityStoneCover.IO.csproj (.../Ringtoets.StabilityStoneCover.IO.csproj) (revision 633aedbd4c882f2811c3e8e6653ef352301c40b5) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.IO/Ringtoets.StabilityStoneCover.IO.csproj (.../Ringtoets.StabilityStoneCover.IO.csproj) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -41,7 +41,7 @@ Properties\GlobalAssembly.cs - + Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.IO/StabilityStoneCoverCalculationConfigurationWriter.cs =================================================================== diff -u --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.IO/StabilityStoneCoverCalculationConfigurationWriter.cs (revision 0) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.IO/StabilityStoneCoverCalculationConfigurationWriter.cs (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,40 @@ +// 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.Xml; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.StabilityStoneCover.Data; +using Ringtoets.Revetment.IO; + +namespace Ringtoets.StabilityStoneCover.IO +{ + /// + /// A writer for writing out configurations of and + /// , to XML format. + /// + public class StabilityStoneCoverCalculationConfigurationWriter : WaveConditionsCalculationConfigurationWriter + { + protected override void WriteCalculation(StabilityStoneCoverWaveConditionsCalculation calculation, XmlWriter writer) + { + WriteCalculation(calculation.Name, calculation.InputParameters, writer); + } + } +} \ No newline at end of file Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.IO/StabilityStoneCoverConfigurationExporter.cs =================================================================== diff -u -r00a4b6318d0d1ae57df5ef362ba1e8908aa330be -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.IO/StabilityStoneCoverConfigurationExporter.cs (.../StabilityStoneCoverConfigurationExporter.cs) (revision 00a4b6318d0d1ae57df5ef362ba1e8908aa330be) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.IO/StabilityStoneCoverConfigurationExporter.cs (.../StabilityStoneCoverConfigurationExporter.cs) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -31,7 +31,7 @@ /// Exports a stability stone cover configuration and stores it as an XML file. /// public class StabilityStoneCoverConfigurationExporter - : ConfigurationExporter + : ConfigurationExporter { /// /// Creates a new instance of . Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.IO/StabilityStoneCoverConfigurationWriter.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/Ringtoets.StabilityStoneCover.IO.Test.csproj =================================================================== diff -u -r633aedbd4c882f2811c3e8e6653ef352301c40b5 -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/Ringtoets.StabilityStoneCover.IO.Test.csproj (.../Ringtoets.StabilityStoneCover.IO.Test.csproj) (revision 633aedbd4c882f2811c3e8e6653ef352301c40b5) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/Ringtoets.StabilityStoneCover.IO.Test.csproj (.../Ringtoets.StabilityStoneCover.IO.Test.csproj) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -50,7 +50,7 @@ Properties\GlobalAssembly.cs - + Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/StabilityStoneCoverCalculationConfigurationWriterTest.cs =================================================================== diff -u --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/StabilityStoneCoverCalculationConfigurationWriterTest.cs (revision 0) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/StabilityStoneCoverCalculationConfigurationWriterTest.cs (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,104 @@ +// 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.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.TestUtil; +using Ringtoets.StabilityStoneCover.Data; +using Ringtoets.Revetment.Data; +using Ringtoets.Revetment.IO; + +namespace Ringtoets.StabilityStoneCover.IO.Test +{ + [TestFixture] + public class StabilityStoneCoverCalculationConfigurationWriterTest + { + [Test] + public void Constructor_Always_CreateWaveConditionsInputWriter() + { + // Call + var writer = new StabilityStoneCoverCalculationConfigurationWriter(); + + // Assert + Assert.IsInstanceOf>(writer); + } + + [Test] + public void Write_GroupWithCalculationAndOtherGroup_WritesOutCalculationAndGroupToFile() + { + // Setup + string filePath = TestHelper.GetScratchPadPath("Write_GroupWithCalculationAndOtherGroup.xml"); + string expectedXmlFilePath = TestHelper.GetTestDataPath( + TestDataPath.Ringtoets.StabilityStoneCover.IO, + Path.Combine(nameof(StabilityStoneCoverCalculationConfigurationWriter), "calculationAndGroupWithNesting.xml")); + + var calculation = new StabilityStoneCoverWaveConditionsCalculation + { + Name = "Berekening 1", + InputParameters = + { + HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("hr_locatie_2"), + UpperBoundaryRevetment = (RoundedDouble) 2.5, + LowerBoundaryRevetment = (RoundedDouble) 1.3, + UpperBoundaryWaterLevels = (RoundedDouble) 2.2, + LowerBoundaryWaterLevels = (RoundedDouble) (-0.2), + StepSize = WaveConditionsInputStepSize.Two, + ForeshoreProfile = new TestForeshoreProfile("profiel2"), + Orientation = (RoundedDouble) 12.3, + UseForeshore = true, + UseBreakWater = true, + BreakWater = + { + Height = (RoundedDouble) 2.11, + Type = BreakWaterType.Wall + } + } + }; + + var calculationGroup = new CalculationGroup("NestedGroup", false); + try + { + var writer = new StabilityStoneCoverCalculationConfigurationWriter(); + + // Call + writer.Write(new ICalculationBase[] + { + calculation, + calculationGroup + }, filePath); + + // Assert + string actualXml = File.ReadAllText(filePath); + string expectedXml = File.ReadAllText(expectedXmlFilePath); + + Assert.AreEqual(expectedXml, actualXml); + } + finally + { + File.Delete(filePath); + } + } + } +} \ No newline at end of file Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/StabilityStoneCoverConfigurationExporterTest.cs =================================================================== diff -u -r00a4b6318d0d1ae57df5ef362ba1e8908aa330be -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/StabilityStoneCoverConfigurationExporterTest.cs (.../StabilityStoneCoverConfigurationExporterTest.cs) (revision 00a4b6318d0d1ae57df5ef362ba1e8908aa330be) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/StabilityStoneCoverConfigurationExporterTest.cs (.../StabilityStoneCoverConfigurationExporterTest.cs) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -43,7 +43,7 @@ // Assert Assert.IsInstanceOf< ConfigurationExporter< - StabilityStoneCoverConfigurationWriter, + StabilityStoneCoverCalculationConfigurationWriter, StabilityStoneCoverWaveConditionsCalculation>>(exporter); } Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/StabilityStoneCoverConfigurationWriterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/test-data/StabilityStoneCoverCalculationConfigurationWriter/calculationAndGroupWithNesting.xml =================================================================== diff -u --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/test-data/StabilityStoneCoverCalculationConfigurationWriter/calculationAndGroupWithNesting.xml (revision 0) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/test-data/StabilityStoneCoverCalculationConfigurationWriter/calculationAndGroupWithNesting.xml (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,20 @@ + + + + hr_locatie_2 + 2.5 + 1.3 + 2.2 + -0.2 + 2.0 + profiel2 + 12.3 + + true + verticalewand + 2.11 + true + + + + \ No newline at end of file Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/test-data/StabilityStoneCoverConfigurationWriter/calculationAndGroupWithNesting.xml'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.IO/Ringtoets.WaveImpactAsphaltCover.IO.csproj =================================================================== diff -u -r7348fb685e44d6eb4abf2854c8298c0a2189d67e -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.IO/Ringtoets.WaveImpactAsphaltCover.IO.csproj (.../Ringtoets.WaveImpactAsphaltCover.IO.csproj) (revision 7348fb685e44d6eb4abf2854c8298c0a2189d67e) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.IO/Ringtoets.WaveImpactAsphaltCover.IO.csproj (.../Ringtoets.WaveImpactAsphaltCover.IO.csproj) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -41,7 +41,7 @@ Properties\GlobalAssembly.cs - + Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.IO/WaveImpactAsphaltCoverCalculationConfigurationWriter.cs =================================================================== diff -u --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.IO/WaveImpactAsphaltCoverCalculationConfigurationWriter.cs (revision 0) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.IO/WaveImpactAsphaltCoverCalculationConfigurationWriter.cs (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,40 @@ +// 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.Xml; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.WaveImpactAsphaltCover.Data; +using Ringtoets.Revetment.IO; + +namespace Ringtoets.WaveImpactAsphaltCover.IO +{ + /// + /// A writer for writing out configurations of and + /// , to XML format. + /// + public class WaveImpactAsphaltCoverCalculationConfigurationWriter : WaveConditionsCalculationConfigurationWriter + { + protected override void WriteCalculation(WaveImpactAsphaltCoverWaveConditionsCalculation calculation, XmlWriter writer) + { + WriteCalculation(calculation.Name, calculation.InputParameters, writer); + } + } +} \ No newline at end of file Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.IO/WaveImpactAsphaltCoverConfigurationExporter.cs =================================================================== diff -u -r00a4b6318d0d1ae57df5ef362ba1e8908aa330be -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.IO/WaveImpactAsphaltCoverConfigurationExporter.cs (.../WaveImpactAsphaltCoverConfigurationExporter.cs) (revision 00a4b6318d0d1ae57df5ef362ba1e8908aa330be) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.IO/WaveImpactAsphaltCoverConfigurationExporter.cs (.../WaveImpactAsphaltCoverConfigurationExporter.cs) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -31,7 +31,7 @@ /// Exports a wave impact asphalt cover configuration and stores it as an XML file. /// public class WaveImpactAsphaltCoverConfigurationExporter - : ConfigurationExporter + : ConfigurationExporter { /// /// Creates a new instance of . Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.IO/WaveImpactAsphaltCoverConfigurationWriter.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/Ringtoets.WaveImpactAsphaltCover.IO.Test.csproj =================================================================== diff -u -r7348fb685e44d6eb4abf2854c8298c0a2189d67e -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/Ringtoets.WaveImpactAsphaltCover.IO.Test.csproj (.../Ringtoets.WaveImpactAsphaltCover.IO.Test.csproj) (revision 7348fb685e44d6eb4abf2854c8298c0a2189d67e) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/Ringtoets.WaveImpactAsphaltCover.IO.Test.csproj (.../Ringtoets.WaveImpactAsphaltCover.IO.Test.csproj) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -50,7 +50,7 @@ Properties\GlobalAssembly.cs - + Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/WaveImpactAsphaltCoverCalculationConfigurationWriterTest.cs =================================================================== diff -u --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/WaveImpactAsphaltCoverCalculationConfigurationWriterTest.cs (revision 0) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/WaveImpactAsphaltCoverCalculationConfigurationWriterTest.cs (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,104 @@ +// 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.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.TestUtil; +using Ringtoets.WaveImpactAsphaltCover.Data; +using Ringtoets.Revetment.Data; +using Ringtoets.Revetment.IO; + +namespace Ringtoets.WaveImpactAsphaltCover.IO.Test +{ + [TestFixture] + public class WaveImpactAsphaltCoverCalculationConfigurationWriterTest + { + [Test] + public void Constructor_Always_CreateWaveConditionsInputWriter() + { + // Call + var writer = new WaveImpactAsphaltCoverCalculationConfigurationWriter(); + + // Assert + Assert.IsInstanceOf>(writer); + } + + [Test] + public void Write_GroupWithCalculationAndOtherGroup_WritesOutCalculationAndGroupToFile() + { + // Setup + string filePath = TestHelper.GetScratchPadPath("Write_GroupWithCalculationAndOtherGroup.xml"); + string expectedXmlFilePath = TestHelper.GetTestDataPath( + TestDataPath.Ringtoets.WaveImpactAsphaltCover.IO, + Path.Combine(nameof(WaveImpactAsphaltCoverCalculationConfigurationWriter), "calculationAndGroupWithNesting.xml")); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Name = "Berekening 1", + InputParameters = + { + HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("hr_locatie_2"), + UpperBoundaryRevetment = (RoundedDouble) 2.5, + LowerBoundaryRevetment = (RoundedDouble) 1.3, + UpperBoundaryWaterLevels = (RoundedDouble) 2.2, + LowerBoundaryWaterLevels = (RoundedDouble) (-0.2), + StepSize = WaveConditionsInputStepSize.Two, + ForeshoreProfile = new TestForeshoreProfile("profiel2"), + Orientation = (RoundedDouble) 12.3, + UseForeshore = true, + UseBreakWater = true, + BreakWater = + { + Height = (RoundedDouble) 2.11, + Type = BreakWaterType.Wall + } + } + }; + + var calculationGroup = new CalculationGroup("NestedGroup", false); + try + { + var writer = new WaveImpactAsphaltCoverCalculationConfigurationWriter(); + + // Call + writer.Write(new ICalculationBase[] + { + calculation, + calculationGroup + }, filePath); + + // Assert + string actualXml = File.ReadAllText(filePath); + string expectedXml = File.ReadAllText(expectedXmlFilePath); + + Assert.AreEqual(expectedXml, actualXml); + } + finally + { + File.Delete(filePath); + } + } + } +} \ No newline at end of file Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/WaveImpactAsphaltCoverConfigurationExporterTest.cs =================================================================== diff -u -r00a4b6318d0d1ae57df5ef362ba1e8908aa330be -rf01786afaf51ad02f5be5e2a320461ebfe576bba --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/WaveImpactAsphaltCoverConfigurationExporterTest.cs (.../WaveImpactAsphaltCoverConfigurationExporterTest.cs) (revision 00a4b6318d0d1ae57df5ef362ba1e8908aa330be) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/WaveImpactAsphaltCoverConfigurationExporterTest.cs (.../WaveImpactAsphaltCoverConfigurationExporterTest.cs) (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -43,7 +43,7 @@ // Assert Assert.IsInstanceOf< ConfigurationExporter< - WaveImpactAsphaltCoverConfigurationWriter, + WaveImpactAsphaltCoverCalculationConfigurationWriter, WaveImpactAsphaltCoverWaveConditionsCalculation>>(exporter); } Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/WaveImpactAsphaltCoverConfigurationWriterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/test-data/WaveImpactAsphaltCoverCalculationConfigurationWriter/calculationAndGroupWithNesting.xml =================================================================== diff -u --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/test-data/WaveImpactAsphaltCoverCalculationConfigurationWriter/calculationAndGroupWithNesting.xml (revision 0) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/test-data/WaveImpactAsphaltCoverCalculationConfigurationWriter/calculationAndGroupWithNesting.xml (revision f01786afaf51ad02f5be5e2a320461ebfe576bba) @@ -0,0 +1,20 @@ + + + + hr_locatie_2 + 2.5 + 1.3 + 2.2 + -0.2 + 2.0 + profiel2 + 12.3 + + true + verticalewand + 2.11 + true + + + + \ No newline at end of file Fisheye: Tag f01786afaf51ad02f5be5e2a320461ebfe576bba refers to a dead (removed) revision in file `Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/test-data/WaveImpactAsphaltCoverConfigurationWriter/calculationAndGroupWithNesting.xml'. Fisheye: No comparison available. Pass `N' to diff?