Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/HeightStructuresCalculationConfigurationExporterTest.cs =================================================================== diff -u -rcc1268d7cb906524d4cabcd4cbd9ae16676cf059 -rbe64b9f33b3065a4d80c0a93c1cafe3d74f43513 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/HeightStructuresCalculationConfigurationExporterTest.cs (.../HeightStructuresCalculationConfigurationExporterTest.cs) (revision cc1268d7cb906524d4cabcd4cbd9ae16676cf059) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/HeightStructuresCalculationConfigurationExporterTest.cs (.../HeightStructuresCalculationConfigurationExporterTest.cs) (revision be64b9f33b3065a4d80c0a93c1cafe3d74f43513) @@ -39,53 +39,88 @@ public class HeightStructuresCalculationConfigurationExporterTest : CustomSchemaCalculationConfigurationExporterDesignGuidelinesTestFixture< HeightStructuresCalculationConfigurationExporter, - HeightStructuresCalculationConfigurationWriter, - StructuresCalculation, + HeightStructuresCalculationConfigurationWriter, + StructuresCalculation, HeightStructureCalculationConfiguration> { + private static IEnumerable Calculations + { + get + { + yield return new TestCaseData("completeConfiguration", new[] + { + CreateFullCalculation() + }) + .SetName("Calculation configuration with all parameters set"); + yield return new TestCaseData("sparseConfiguration", new[] + { + CreateSparseCalculation() + }) + .SetName("Calculation configuration with none of its parameters set"); + yield return new TestCaseData("configurationWithStructure", new[] + { + CreateCalculationWithStructure() + }) + .SetName("Calculation configuration with a structure set"); + yield return new TestCaseData("configurationWithForeshoreProfile", new[] + { + CreateCalculationWithForeshoreProfile() + }) + .SetName("Calculation configuration with foreshore profile"); + yield return new TestCaseData("configurationWithUseBreakWater", new[] + { + CreateCalculationWithUseBreakWater() + }) + .SetName("Calculation configuration with use breakwater true"); + yield return new TestCaseData("folderWithSubfolderAndCalculation", new[] + { + new CalculationGroup("Testmap", false) + { + Children = + { + CreateFullCalculation(), + new CalculationGroup("Nested", false) + { + Children = + { + CreateSparseCalculation() + } + } + } + } + }) + .SetName("Calculation configuration with hierarchy"); + } + } + [Test] - public void Export_ValidData_ReturnTrueAndWritesFile() + [TestCaseSource(nameof(Calculations))] + public void Export_ValidData_ReturnTrueAndWritesFile(string fileName, ICalculationBase[] calculations) { // Setup - StructuresCalculation calculation = CreateFullCalculation(); - StructuresCalculation calculation2 = new StructuresCalculation - { - Name = "Berekening 2" - }; + string testDirectory = TestHelper.GetTestDataPath( + TestDataPath.Ringtoets.HeightStructures.IO, + nameof(HeightStructuresCalculationConfigurationExporter)); - CalculationGroup calculationGroup2 = new CalculationGroup("Nested", false) - { - Children = - { - calculation2 - } - }; + string expectedXmlFilePath = Path.Combine(testDirectory, $"{fileName}.xml"); - CalculationGroup calculationGroup = new CalculationGroup("Testmap", false) - { - Children = - { - calculation, - calculationGroup2 - } - }; - - string expectedXmlFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HeightStructures.IO, - Path.Combine(nameof(HeightStructuresCalculationConfigurationWriter), - "folderWithSubfolderAndCalculation.xml")); - // Call and Assert - WriteAndValidate(new[] + WriteAndValidate(calculations, expectedXmlFilePath); + } + + private static ICalculation CreateSparseCalculation() + { + return new StructuresCalculation { - calculationGroup - }, expectedXmlFilePath); + Name = "sparse config" + }; } private static StructuresCalculation CreateFullCalculation() { return new TestHeightStructuresCalculation { - Name = "Berekening 1", + Name = "full config", InputParameters = { HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("Locatie1"), @@ -100,40 +135,40 @@ Type = BreakWaterType.Dam, Height = (RoundedDouble) 1.234 }, - StormDuration = new VariationCoefficientLogNormalDistribution() + StormDuration = new VariationCoefficientLogNormalDistribution { Mean = (RoundedDouble) 6.0 }, - ModelFactorSuperCriticalFlow = new NormalDistribution() + ModelFactorSuperCriticalFlow = new NormalDistribution { Mean = (RoundedDouble) 1.10 }, - FlowWidthAtBottomProtection = new LogNormalDistribution() + FlowWidthAtBottomProtection = new LogNormalDistribution { Mean = (RoundedDouble) 15.2, StandardDeviation = (RoundedDouble) 0.1 }, - WidthFlowApertures = new NormalDistribution() + WidthFlowApertures = new NormalDistribution { Mean = (RoundedDouble) 13.2, StandardDeviation = (RoundedDouble) 0.3 }, - StorageStructureArea = new VariationCoefficientLogNormalDistribution() + StorageStructureArea = new VariationCoefficientLogNormalDistribution { Mean = (RoundedDouble) 15000, CoefficientOfVariation = (RoundedDouble) 0.01 }, - AllowedLevelIncreaseStorage = new LogNormalDistribution() + AllowedLevelIncreaseStorage = new LogNormalDistribution { Mean = (RoundedDouble) 0.2, StandardDeviation = (RoundedDouble) 0.01 }, - LevelCrestStructure = new NormalDistribution() + LevelCrestStructure = new NormalDistribution { Mean = (RoundedDouble) 4.3, StandardDeviation = (RoundedDouble) 0.2 }, - CriticalOvertoppingDischarge = new VariationCoefficientLogNormalDistribution() + CriticalOvertoppingDischarge = new VariationCoefficientLogNormalDistribution { Mean = (RoundedDouble) 2, CoefficientOfVariation = (RoundedDouble) 0.1 @@ -142,6 +177,50 @@ }; } + private static StructuresCalculation CreateCalculationWithForeshoreProfile() + { + return new StructuresCalculation + { + Name = "with foreshore profile", + InputParameters = + { + ForeshoreProfile = new TestForeshoreProfile("profiel1"), + UseForeshore = true + } + }; + } + + private static StructuresCalculation CreateCalculationWithUseBreakWater() + { + return new StructuresCalculation + { + Name = "with use breakwater", + InputParameters = + { + ForeshoreProfile = new TestForeshoreProfile("profiel1"), + BreakWater = + { + Type = BreakWaterType.Caisson, + Height = (RoundedDouble) 1.23 + }, + UseBreakWater = true, + UseForeshore = false + } + }; + } + + private static StructuresCalculation CreateCalculationWithStructure() + { + return new StructuresCalculation + { + Name = "with structure", + InputParameters = + { + Structure = new TestHeightStructure("kunstwerk1"), + } + }; + } + protected override StructuresCalculation CreateCalculation() { return new TestHeightStructuresCalculation();