Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsOutputProperties.cs =================================================================== diff -u -raeb6e1a439617630e7613b9ed5af152c345fa2c6 -r57c9aff5c1e30cb83c1cc2f33c7ce97dfe8d04fe --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsOutputProperties.cs (.../GrassCoverErosionInwardsOutputProperties.cs) (revision aeb6e1a439617630e7613b9ed5af152c345fa2c6) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsOutputProperties.cs (.../GrassCoverErosionInwardsOutputProperties.cs) (revision 57c9aff5c1e30cb83c1cc2f33c7ce97dfe8d04fe) @@ -43,7 +43,8 @@ public bool DynamicVisibleValidationMethod(string propertyName) { return propertyName.Contains(nameof(DikeHeight)) && data.DikeHeightOutput != null - || propertyName.Contains(nameof(OvertoppingRate)) && data.OvertoppingRateOutput != null; + || propertyName.Contains(nameof(OvertoppingRate)) && data.OvertoppingRateOutput != null + || propertyName.Equals(nameof(WaveHeight)) && !double.IsNaN(data.WaveHeight); } #region GrassCoverErosionInwards result @@ -109,6 +110,7 @@ } [PropertyOrder(6)] + [DynamicVisible] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Result), 1, 3)] [ResourcesDisplayName(typeof(GrassCoverErosionInwardsFormsResources), nameof(GrassCoverErosionInwardsFormsResources.GrassCoverErosionInwardsOutput_WaveHeight_Displayname))] [ResourcesDescription(typeof(GrassCoverErosionInwardsFormsResources), nameof(GrassCoverErosionInwardsFormsResources.GrassCoverErosionInwardsOutput_WaveHeight_Description))] Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsOutputPropertiesTest.cs =================================================================== diff -u -raeb6e1a439617630e7613b9ed5af152c345fa2c6 -r57c9aff5c1e30cb83c1cc2f33c7ce97dfe8d04fe --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsOutputPropertiesTest.cs (.../GrassCoverErosionInwardsOutputPropertiesTest.cs) (revision aeb6e1a439617630e7613b9ed5af152c345fa2c6) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsOutputPropertiesTest.cs (.../GrassCoverErosionInwardsOutputPropertiesTest.cs) (revision 57c9aff5c1e30cb83c1cc2f33c7ce97dfe8d04fe) @@ -167,7 +167,7 @@ var probabilityAssessmentOutput = new ProbabilityAssessmentOutput(double.NaN, double.NaN, double.NaN, double.NaN, double.NaN); var dikeHeightOutput = new TestDikeHeightOutput(double.NaN); var overtoppingRateOutput = new TestOvertoppingRateOutput(double.NaN); - var output = new GrassCoverErosionInwardsOutput(double.NaN, true, probabilityAssessmentOutput, + var output = new GrassCoverErosionInwardsOutput(10, true, probabilityAssessmentOutput, dikeHeightOutput, overtoppingRateOutput); @@ -207,7 +207,7 @@ overtoppingRateOutput = new TestOvertoppingRateOutput(double.NaN); } - var output = new GrassCoverErosionInwardsOutput(double.NaN, true, probabilityAssessmentOutput, + var output = new GrassCoverErosionInwardsOutput(2, true, probabilityAssessmentOutput, dikeHeightOutput, overtoppingRateOutput); @@ -235,11 +235,13 @@ } [Test] - public void PropertyAttributes_WithoutDikeHeightAndOvertoppingRateCalculated_ReturnExpectedValues() + [TestCase(double.NaN)] + [TestCase(10)] + public void PropertyAttributes_WithoutDikeHeightAndOvertoppingRateCalculated_ReturnExpectedValues(double waveHeight) { // Setup var probabilityAssessmentOutput = new ProbabilityAssessmentOutput(double.NaN, double.NaN, double.NaN, double.NaN, double.NaN); - var output = new GrassCoverErosionInwardsOutput(double.NaN, true, probabilityAssessmentOutput, null, null); + var output = new GrassCoverErosionInwardsOutput(waveHeight, true, probabilityAssessmentOutput, null, null); // Call var properties = new GrassCoverErosionInwardsOutputProperties @@ -248,13 +250,15 @@ }; // Assert + int propertiesCount = double.IsNaN(waveHeight) ? 6 : 7; + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(7, dynamicProperties.Count); + Assert.AreEqual(propertiesCount, dynamicProperties.Count); - AssertResultOutputProperties(dynamicProperties); + AssertResultOutputProperties(dynamicProperties, !double.IsNaN(waveHeight)); } - private static void AssertResultOutputProperties(PropertyDescriptorCollection dynamicProperties) + private static void AssertResultOutputProperties(PropertyDescriptorCollection dynamicProperties, bool waveHeightCalculated = true) { const string resultCategory = "\t\tResultaat"; PropertyDescriptor requiredProbabilityProperty = dynamicProperties[requiredProbabilityPropertyIndex]; @@ -292,14 +296,21 @@ "De veiligheidsfactor voor deze berekening.", true); - PropertyDescriptor waveHeightProperty = dynamicProperties[waveHeightIndex]; - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveHeightProperty, - resultCategory, - "Indicatieve golfhoogte (Hs) [m]", - "De golfhoogte van de overslag deelberekening.", - true); + if (waveHeightCalculated) + { + PropertyDescriptor waveHeightProperty = dynamicProperties[waveHeightIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveHeightProperty, + resultCategory, + "Indicatieve golfhoogte (Hs) [m]", + "De golfhoogte van de overslag deelberekening.", + true); + } - PropertyDescriptor isDominantProperty = dynamicProperties[isDominantIndex]; + int realDominantIndex = waveHeightCalculated ? + isDominantIndex : + isDominantIndex - 1; + + PropertyDescriptor isDominantProperty = dynamicProperties[realDominantIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isDominantProperty, resultCategory, "Overslag dominant [-]", Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/OvertoppingCalculationWaveHeightParser.cs =================================================================== diff -u -rae5c94bea6f603eeafeed527190799ce2b049002 -r57c9aff5c1e30cb83c1cc2f33c7ce97dfe8d04fe --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/OvertoppingCalculationWaveHeightParser.cs (.../OvertoppingCalculationWaveHeightParser.cs) (revision ae5c94bea6f603eeafeed527190799ce2b049002) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/OvertoppingCalculationWaveHeightParser.cs (.../OvertoppingCalculationWaveHeightParser.cs) (revision 57c9aff5c1e30cb83c1cc2f33c7ce97dfe8d04fe) @@ -83,7 +83,14 @@ { try { - double waveHeight = Convert.ToDouble(result[waveHeightColumn]); + double waveHeight = double.NaN; + object waveHeightResult = result[waveHeightColumn]; + + if (waveHeightResult.GetType() != typeof(DBNull)) + { + waveHeight = Convert.ToDouble(waveHeightResult); + } + bool isOvertoppingDominant = Convert.ToBoolean(result[isOvertoppingDominantColumn]); Output = new OvertoppingCalculationWaveHeightOutput(waveHeight, Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/OvertoppingCalculationWaveHeightParserTest.cs =================================================================== diff -u -rae5c94bea6f603eeafeed527190799ce2b049002 -r57c9aff5c1e30cb83c1cc2f33c7ce97dfe8d04fe --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/OvertoppingCalculationWaveHeightParserTest.cs (.../OvertoppingCalculationWaveHeightParserTest.cs) (revision ae5c94bea6f603eeafeed527190799ce2b049002) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/OvertoppingCalculationWaveHeightParserTest.cs (.../OvertoppingCalculationWaveHeightParserTest.cs) (revision 57c9aff5c1e30cb83c1cc2f33c7ce97dfe8d04fe) @@ -101,7 +101,6 @@ [Test] [TestCase("EmptyDatabase")] [TestCase("EmptyTableDesignBeta")] - [TestCase("EmptyTableDesignPointResults")] [TestCase("EmptyTableGoverningWind")] public void Parse_WithDataNotComplete_ThrowsHydraRingFileParserException(string subFolder) { @@ -155,36 +154,35 @@ } [Test] - public void Parse_NotAllColumnsHaveResults_ThrowsHydraRingFileParserException() + [TestCase(validFileOvertoppingDominant, 0.265866, true)] + [TestCase("ValidFileOvertoppingNotDominant", 0.000355406, false)] + public void Parse_ValidData_OutputSet(string file, double expectedWaveHeight, bool expectedOvertoppingDominant) { // Setup - string path = Path.Combine(testDirectory, "ValidFileNoWaveHeight"); + string path = Path.Combine(testDirectory, file); var parser = new OvertoppingCalculationWaveHeightParser(); // Call - TestDelegate test = () => parser.Parse(path, 1); + parser.Parse(path, 1); // Assert - var exception = Assert.Throws(test); - Assert.AreEqual("Er is geen resultaat voor overslag en overloop gevonden in de Hydra-Ring uitvoerdatabase.", exception.Message); - Assert.IsInstanceOf(exception.InnerException); + Assert.AreEqual(expectedWaveHeight, parser.Output.WaveHeight, 1e-11); + Assert.AreEqual(expectedOvertoppingDominant, parser.Output.IsOvertoppingDominant); } [Test] - [TestCase(validFileOvertoppingDominant, 0.265866, true)] - [TestCase("ValidFileOvertoppingNotDominant", 0.000355406, false)] - public void Parse_ValidData_OutputSet(string file, double expectedWaveHeight, bool expectedOvertoppingDominant) + public void Parse_WaveHeightNull_OutputSet() { // Setup - string path = Path.Combine(testDirectory, file); + string path = Path.Combine(testDirectory, "ValidFileWaveHeightNull"); var parser = new OvertoppingCalculationWaveHeightParser(); // Call parser.Parse(path, 1); // Assert - Assert.AreEqual(expectedWaveHeight, parser.Output.WaveHeight, 1e-11); - Assert.AreEqual(expectedOvertoppingDominant, parser.Output.IsOvertoppingDominant); + Assert.IsNaN(parser.Output.WaveHeight); + Assert.IsFalse(parser.Output.IsOvertoppingDominant); } } } \ No newline at end of file Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/test-data/Parsers/OvertoppingCalculationWaveHeightParser/EmptyTableDesignPointResults/1-output.sqlite =================================================================== diff -u -r1d8c35ad08fddf6471c168876fc01552af29fd6a -r57c9aff5c1e30cb83c1cc2f33c7ce97dfe8d04fe Binary files differ Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/test-data/Parsers/OvertoppingCalculationWaveHeightParser/ValidFileNoWaveHeight/1-output.sqlite =================================================================== diff -u -r1d8c35ad08fddf6471c168876fc01552af29fd6a -r57c9aff5c1e30cb83c1cc2f33c7ce97dfe8d04fe Binary files differ Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/test-data/Parsers/OvertoppingCalculationWaveHeightParser/ValidFileWaveHeightNull/1-output.sqlite =================================================================== diff -u Binary files differ