Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Configurations/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Configurations/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Configurations/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader.cs (revision fcd598284a0dfe0fd6142a9ab514ee1ec12edee0) @@ -0,0 +1,63 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Xml.Linq; +using Core.Common.Base.IO; +using Ringtoets.Common.IO.Configurations; +using Ringtoets.Common.IO.Configurations.Helpers; +using Ringtoets.GrassCoverErosionOutwards.IO.Configurations.Converters; +using Ringtoets.GrassCoverErosionOutwards.IO.Properties; +using Ringtoets.Revetment.IO.Configurations; + +namespace Ringtoets.GrassCoverErosionOutwards.IO.Configurations +{ + /// + /// This class reads a wave conditions calculation configuration from XML and creates a collection of corresponding + /// , typically containing one or more . + /// + public class GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader : WaveConditionsCalculationConfigurationReader + { + /// + /// Creates a new instance of . + /// + /// The file path to the XML file. + /// Thrown when is invalid. + /// Thrown when: + /// + /// points to a file that does not exist. + /// points to a file that does not contain valid XML. + /// points to a file that does not pass the schema validation. + /// points to a file that does not contain configuration elements. + /// + /// + public GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader(string xmlFilePath) + : base(xmlFilePath, Resources.GEBUConfiguratieSchema) {} + + protected override GrassCoverErosionOutwardsWaveConditionsCalculationConfiguration ParseCalculationElement(XElement calculationElement) + { + var configuration = new GrassCoverErosionOutwardsWaveConditionsCalculationConfiguration(calculationElement.Attribute(ConfigurationSchemaIdentifiers.NameAttribute).Value); + ParseCalculationElementData(calculationElement, configuration); + configuration.CategoryType = (ConfigurationGrassCoverErosionOutwardsCategoryType?) calculationElement.GetConvertedValueFromDescendantStringElement(WaveConditionsCalculationConfigurationSchemaIdentifiers.CategoryType); + return configuration; + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Properties/Resources.Designer.cs =================================================================== diff -u -rbb81cbc775643d95f096bddf5e5dbdae234cf921 -rfcd598284a0dfe0fd6142a9ab514ee1ec12edee0 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision bb81cbc775643d95f096bddf5e5dbdae234cf921) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision fcd598284a0dfe0fd6142a9ab514ee1ec12edee0) @@ -128,6 +128,26 @@ } /// + /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8"?><!-- + ///Copyright (C) Stichting Deltares 2017. All rights reserved. + /// + ///This file is part of Ringtoets. + /// + ///Ringtoets is free software: you can redistribute it and/or modify + ///it under the terms of the GNU General Public License as published by + ///the Free Software Foundation, either version 3 of the License, or + ///(at your option) any later version. + /// + ///This program is distributed in the hope that it will be useful, + ///but WITHOUT ANY WARRANTY; without even the implied warranty of [rest of string was truncated]";. + /// + internal static string GEBUConfiguratieSchema { + get { + return ResourceManager.GetString("GEBUConfiguratieSchema", resourceCulture); + } + } + + /// /// Looks up a localized string similar to h V-VI. /// internal static string MetaData_WaterLevelCalculationForFactorizedLowerLimitNorm { Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Properties/Resources.resx =================================================================== diff -u -rbb81cbc775643d95f096bddf5e5dbdae234cf921 -rfcd598284a0dfe0fd6142a9ab514ee1ec12edee0 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Properties/Resources.resx (.../Resources.resx) (revision bb81cbc775643d95f096bddf5e5dbdae234cf921) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Properties/Resources.resx (.../Resources.resx) (revision fcd598284a0dfe0fd6142a9ab514ee1ec12edee0) @@ -132,6 +132,10 @@ IIv-IIIv + + + ..\Resources\GEBUConfiguratieSchema.xsd;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + h V-VI Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Resources/GEBUConfiguratieSchema.xsd =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Resources/GEBUConfiguratieSchema.xsd (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Resources/GEBUConfiguratieSchema.xsd (revision fcd598284a0dfe0fd6142a9ab514ee1ec12edee0) @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Ringtoets.GrassCoverErosionOutwards.IO.csproj =================================================================== diff -u -ra455d755f3419ccee4d8110b9e3d573ad6f3d24b -rfcd598284a0dfe0fd6142a9ab514ee1ec12edee0 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Ringtoets.GrassCoverErosionOutwards.IO.csproj (.../Ringtoets.GrassCoverErosionOutwards.IO.csproj) (revision a455d755f3419ccee4d8110b9e3d573ad6f3d24b) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Ringtoets.GrassCoverErosionOutwards.IO.csproj (.../Ringtoets.GrassCoverErosionOutwards.IO.csproj) (revision fcd598284a0dfe0fd6142a9ab514ee1ec12edee0) @@ -14,12 +14,14 @@ + + @@ -37,6 +39,9 @@ Copying.licenseheader + + Designer + @@ -98,8 +103,8 @@ ResXFileCodeGenerator - Resources.Designer.cs Designer + Resources.Designer.cs \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Configurations/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReaderTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Configurations/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReaderTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Configurations/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReaderTest.cs (revision fcd598284a0dfe0fd6142a9ab514ee1ec12edee0) @@ -0,0 +1,112 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Xml.Schema; +using Core.Common.Base.IO; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.IO.Configurations; +using Ringtoets.GrassCoverErosionOutwards.IO.Configurations; +using Ringtoets.Revetment.IO.Configurations; + +namespace Ringtoets.GrassCoverErosionOutwards.IO.Test.Configurations +{ + [TestFixture] + public class GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReaderTest + { + private readonly string testDirectoryPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionOutwards.IO, + nameof(GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader)); + + private static IEnumerable InvalidConfigurations + { + get + { + yield return new TestCaseData("invalidCalculationMultipleCategoryType.xml", + "Element 'categoriegrens' cannot appear more than once if content model type is \"all\".") + .SetName("invalidCalculationMultipleCategoryType"); + yield return new TestCaseData("invalidCategoryTypeUnknownValue.xml", + "The 'categoriegrens' element is invalid - The value 'A-B' is invalid according to its datatype 'String' - The Enumeration constraint failed.") + .SetName("invalidCategoryTypeUnknownValue"); + } + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + string filePath = Path.Combine(testDirectoryPath, "validConfigurationEmptyCalculation.xml"); + + // Call + var reader = new GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader(filePath); + + // Assert + Assert.IsInstanceOf>(reader); + } + + [Test] + [TestCaseSource(nameof(InvalidConfigurations))] + public void Constructor_FileInvalidBasedOnSchemaDefinition_ThrowCriticalFileReadException(string fileName, string expectedParsingMessage) + { + // Setup + string filePath = Path.Combine(testDirectoryPath, fileName); + + // Call + TestDelegate call = () => new GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader(filePath); + + // Assert + var exception = Assert.Throws(call); + Assert.IsInstanceOf(exception.InnerException); + StringAssert.Contains(expectedParsingMessage, exception.InnerException?.Message); + } + + [Test] + public void Read_ValidConfigurationWithFullCalculation_ReturnExpectedReadWaveConditionsCalculation() + { + // Setup + string filePath = Path.Combine(testDirectoryPath, "validConfigurationFullCalculation.xml"); + var reader = new GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader(filePath); + + // Call + IEnumerable readItems = reader.Read().ToArray(); + + // Assert + var calculation = (GrassCoverErosionOutwardsWaveConditionsCalculationConfiguration)readItems.Single(); + + Assert.IsNotNull(calculation); + Assert.AreEqual("HRlocatie", calculation.HydraulicBoundaryLocationName); + Assert.AreEqual(1.1, calculation.UpperBoundaryRevetment); + Assert.AreEqual(2.2, calculation.LowerBoundaryRevetment); + Assert.AreEqual(3.3, calculation.UpperBoundaryWaterLevels); + Assert.AreEqual(4.4, calculation.LowerBoundaryWaterLevels); + Assert.AreEqual(ConfigurationWaveConditionsInputStepSize.Half, calculation.StepSize); + Assert.AreEqual("Voorlandprofiel", calculation.ForeshoreProfileId); + Assert.AreEqual(5.5, calculation.Orientation); + Assert.IsTrue(calculation.WaveReduction.UseBreakWater); + Assert.AreEqual(ConfigurationBreakWaterType.Caisson, calculation.WaveReduction.BreakWaterType); + Assert.AreEqual(6.6, calculation.WaveReduction.BreakWaterHeight); + Assert.IsFalse(calculation.WaveReduction.UseForeshoreProfile); + Assert.AreEqual(ConfigurationGrassCoverErosionOutwardsCategoryType.MechanismSpecificLowerLimitNorm, calculation.CategoryType); + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Ringtoets.GrassCoverErosionOutwards.IO.Test.csproj =================================================================== diff -u -ra455d755f3419ccee4d8110b9e3d573ad6f3d24b -rfcd598284a0dfe0fd6142a9ab514ee1ec12edee0 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Ringtoets.GrassCoverErosionOutwards.IO.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.IO.Test.csproj) (revision a455d755f3419ccee4d8110b9e3d573ad6f3d24b) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Ringtoets.GrassCoverErosionOutwards.IO.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.IO.Test.csproj) (revision fcd598284a0dfe0fd6142a9ab514ee1ec12edee0) @@ -16,11 +16,13 @@ + + Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader/invalidCalculationMultipleCategoryType.xml =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader/invalidCalculationMultipleCategoryType.xml (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader/invalidCalculationMultipleCategoryType.xml (revision fcd598284a0dfe0fd6142a9ab514ee1ec12edee0) @@ -0,0 +1,7 @@ + + + + Iv-IIv + IVv-Vv + + \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader/invalidCategoryTypeEmpty.xml =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader/invalidCategoryTypeEmpty.xml (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader/invalidCategoryTypeEmpty.xml (revision fcd598284a0dfe0fd6142a9ab514ee1ec12edee0) @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader/invalidCategoryTypeUnknownValue.xml =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader/invalidCategoryTypeUnknownValue.xml (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader/invalidCategoryTypeUnknownValue.xml (revision fcd598284a0dfe0fd6142a9ab514ee1ec12edee0) @@ -0,0 +1,6 @@ + + + + A-B + + \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader/validConfigurationEmptyCalculation.xml =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader/validConfigurationEmptyCalculation.xml (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader/validConfigurationEmptyCalculation.xml (revision fcd598284a0dfe0fd6142a9ab514ee1ec12edee0) @@ -0,0 +1,4 @@ + + + + Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader/validConfigurationFullCalculation.xml =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader/validConfigurationFullCalculation.xml (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/test-data/GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationReader/validConfigurationFullCalculation.xml (revision fcd598284a0dfe0fd6142a9ab514ee1ec12edee0) @@ -0,0 +1,20 @@ + + + + HRlocatie + IIIv-IVv + 1.1 + 2.2 + 3.3 + 4.4 + 0.5 + Voorlandprofiel + 5.5 + + true + caisson + 6.6 + false + + +