Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs =================================================================== diff -u -rdbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a -rd69cf89498b4f926407d0261a747a4a7a8d37e62 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs (.../ClosingStructuresInputContextProperties.cs) (revision dbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs (.../ClosingStructuresInputContextProperties.cs) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62) @@ -45,8 +45,7 @@ ClosingStructure, ClosingStructuresInput, StructuresCalculation, - ClosingStructuresFailureMechanism>, - IPropertyChangeHandler + ClosingStructuresFailureMechanism> { private const int hydraulicBoundaryLocationPropertyIndex = 1; private const int stormDurationPropertyIndex = 2; Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs =================================================================== diff -u -r545b105a213ed85564861b4bcf6d2d6425dbde50 -rd69cf89498b4f926407d0261a747a4a7a8d37e62 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs (.../ClosingStructuresInputContextPropertiesTest.cs) (revision 545b105a213ed85564861b4bcf6d2d6425dbde50) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs (.../ClosingStructuresInputContextPropertiesTest.cs) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62) @@ -38,6 +38,7 @@ using Ringtoets.ClosingStructures.Forms.PropertyClasses; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Probability; using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.Helpers; @@ -69,6 +70,319 @@ } [Test] + public void Constructor_VerticalWallStructure_PropertiesHaveExpectedAttributesValues() + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + var calculation = new StructuresCalculation + { + InputParameters = + { + Structure = new TestClosingStructure(ClosingStructureInflowModelType.VerticalWall) + } + }; + var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, + calculation, + failureMechanism, + assessmentSectionStub); + + // Call + var properties = new ClosingStructuresInputContextProperties + { + Data = inputContext + }; + + // Assert + const string schematizationCategory = "Schematisatie"; + const string modelSettingsCategory = "Modelinstellingen"; + + var dynamicPropertyBag = new DynamicPropertyBag(properties); + PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + Assert.AreEqual(22, dynamicProperties.Count); + + PropertyDescriptor inflowModelTypeProperty = dynamicProperties[verticalWallInflowModelTypePropertyIndex]; + Assert.IsInstanceOf(inflowModelTypeProperty.Converter); + Assert.AreEqual(schematizationCategory, inflowModelTypeProperty.Category); + Assert.AreEqual("Instroommodel", inflowModelTypeProperty.DisplayName); + Assert.AreEqual("Instroommodel van het kunstwerk.", inflowModelTypeProperty.Description); + + PropertyDescriptor identicalAperturesProperty = dynamicProperties[verticalWallIdenticalAperturesPropertyIndex]; + Assert.IsFalse(identicalAperturesProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, identicalAperturesProperty.Category); + Assert.AreEqual("Aantal identieke doorstroomopeningen [-]", identicalAperturesProperty.DisplayName); + Assert.AreEqual("Aantal identieke doorstroomopeningen.", identicalAperturesProperty.Description); + + PropertyDescriptor levelCrestStructureNotClosingProperty = dynamicProperties[verticalWallLevelCrestStructureNotClosingPropertyIndex]; + Assert.IsInstanceOf(levelCrestStructureNotClosingProperty.Converter); + Assert.AreEqual(schematizationCategory, levelCrestStructureNotClosingProperty.Category); + Assert.AreEqual("Kruinhoogte niet gesloten kering [m+NAP]", levelCrestStructureNotClosingProperty.DisplayName); + Assert.AreEqual("Niveau kruin bij niet gesloten maximaal kerende keermiddelen.", levelCrestStructureNotClosingProperty.Description); + + PropertyDescriptor probabilityOrFrequencyOpenStructureBeforeFloodingProperty = dynamicProperties[verticalWallProbabilityOrFrequencyOpenStructureBeforeFloodingPropertyIndex]; + Assert.IsFalse(probabilityOrFrequencyOpenStructureBeforeFloodingProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, probabilityOrFrequencyOpenStructureBeforeFloodingProperty.Category); + Assert.AreEqual("Kans op open staan bij naderend hoogwater [1/jaar]", probabilityOrFrequencyOpenStructureBeforeFloodingProperty.DisplayName); + Assert.AreEqual("Kans op open staan bij naderend hoogwater.", probabilityOrFrequencyOpenStructureBeforeFloodingProperty.Description); + + PropertyDescriptor failureProbabilityOpenStructureProperty = dynamicProperties[verticalWallFailureProbabilityOpenStructurePropertyIndex]; + Assert.IsFalse(failureProbabilityOpenStructureProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, failureProbabilityOpenStructureProperty.Category); + Assert.AreEqual("Kans mislukken sluiting [1/jaar]", failureProbabilityOpenStructureProperty.DisplayName); + Assert.AreEqual("Kans op mislukken sluiting van geopend kunstwerk.", failureProbabilityOpenStructureProperty.Description); + + PropertyDescriptor failureProbabilityReparationProperty = dynamicProperties[verticalWallFailureProbabilityReparationPropertyIndex]; + Assert.IsFalse(failureProbabilityReparationProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, failureProbabilityReparationProperty.Category); + Assert.AreEqual("Faalkans herstel van gefaalde situatie [1/jaar]", failureProbabilityReparationProperty.DisplayName); + Assert.AreEqual("Faalkans herstel van gefaalde situatie.", failureProbabilityReparationProperty.Description); + + PropertyDescriptor factorStormDurationOpenStructureProperty = dynamicProperties[verticalWallFactorStormDurationOpenStructurePropertyIndex]; + Assert.IsFalse(factorStormDurationOpenStructureProperty.IsReadOnly); + Assert.AreEqual(modelSettingsCategory, factorStormDurationOpenStructureProperty.Category); + Assert.AreEqual("Factor voor stormduur hoogwater [-]", factorStormDurationOpenStructureProperty.DisplayName); + Assert.AreEqual("Factor voor stormduur hoogwater gegeven geopend kunstwerk.", factorStormDurationOpenStructureProperty.Description); + + // Only check the order of the base properties + Assert.AreEqual("Kunstwerk", dynamicProperties[verticalWallStructurePropertyIndex].DisplayName); + Assert.AreEqual("Locatie (RD) [m]", dynamicProperties[verticalWallStructureLocationPropertyIndex].DisplayName); + Assert.AreEqual("Oriëntatie [°]", dynamicProperties[verticalWallStructureNormalOrientationPropertyIndex].DisplayName); + Assert.AreEqual("Stroomvoerende breedte bodembescherming [m]", dynamicProperties[verticalWallFlowWidthAtBottomProtectionPropertyIndex].DisplayName); + Assert.AreEqual("Breedte van doorstroomopening [m]", dynamicProperties[verticalWallWidthFlowAperturesPropertyIndex].DisplayName); + Assert.AreEqual("Kombergend oppervlak [m²]", dynamicProperties[verticalWallStorageStructureAreaPropertyIndex].DisplayName); + Assert.AreEqual("Toegestane peilverhoging komberging [m]", dynamicProperties[verticalWallAllowedLevelIncreaseStoragePropertyIndex].DisplayName); + Assert.AreEqual("Kritiek instromend debiet [m³/s/m]", dynamicProperties[verticalWallCriticalOvertoppingDischargePropertyIndex].DisplayName); + Assert.AreEqual("Faalkans gegeven erosie bodem [1/jaar]", dynamicProperties[verticalWallFailureProbabilityStructureWithErosionPropertyIndex].DisplayName); + Assert.AreEqual("Modelfactor overloopdebiet volkomen overlaat [-]", dynamicProperties[verticalWallModelFactorSuperCriticalFlowPropertyIndex].DisplayName); + Assert.AreEqual("Voorlandprofiel", dynamicProperties[verticalWallForeshoreProfilePropertyIndex].DisplayName); + Assert.AreEqual("Dam", dynamicProperties[verticalWallUseBreakWaterPropertyIndex].DisplayName); + Assert.AreEqual("Voorlandgeometrie", dynamicProperties[verticalWallUseForeshorePropertyIndex].DisplayName); + Assert.AreEqual("Locatie met hydraulische randvoorwaarden", dynamicProperties[verticalWallHydraulicBoundaryLocationPropertyIndex].DisplayName); + Assert.AreEqual("Stormduur [uur]", dynamicProperties[verticalWallStormDurationPropertyIndex].DisplayName); + + mockRepository.VerifyAll(); + } + + [Test] + public void Constructor_FloodedCulvertStructure_PropertiesHaveExpectedAttributesValues() + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + var calculation = new StructuresCalculation + { + InputParameters = + { + Structure = new TestClosingStructure(ClosingStructureInflowModelType.FloodedCulvert) + } + }; + var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, + calculation, + failureMechanism, + assessmentSectionStub); + + // Call + var properties = new ClosingStructuresInputContextProperties + { + Data = inputContext + }; + + // Assert + const string schematizationCategory = "Schematisatie"; + const string hydraulicDataCategory = "Hydraulische gegevens"; + const string modelSettingsCategory = "Modelinstellingen"; + + var dynamicPropertyBag = new DynamicPropertyBag(properties); + PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + Assert.AreEqual(21, dynamicProperties.Count); + + PropertyDescriptor insideWaterLevelProperty = dynamicProperties[floodedCulvertInsideWaterLevelPropertyIndex]; + Assert.IsInstanceOf(insideWaterLevelProperty.Converter); + Assert.AreEqual(hydraulicDataCategory, insideWaterLevelProperty.Category); + Assert.AreEqual("Binnenwaterstand [m+NAP]", insideWaterLevelProperty.DisplayName); + Assert.AreEqual("Binnenwaterstand.", insideWaterLevelProperty.Description); + + PropertyDescriptor inflowModelTypeProperty = dynamicProperties[floodedCulvertInflowModelTypePropertyIndex]; + Assert.IsInstanceOf(inflowModelTypeProperty.Converter); + Assert.AreEqual(schematizationCategory, inflowModelTypeProperty.Category); + Assert.AreEqual("Instroommodel", inflowModelTypeProperty.DisplayName); + Assert.AreEqual("Instroommodel van het kunstwerk.", inflowModelTypeProperty.Description); + + PropertyDescriptor areaFlowAperturesProperty = dynamicProperties[floodedCulvertAreaFlowAperturesPropertyIndex]; + Assert.IsInstanceOf(areaFlowAperturesProperty.Converter); + Assert.AreEqual(schematizationCategory, areaFlowAperturesProperty.Category); + Assert.AreEqual("Doorstroomoppervlak [m²]", areaFlowAperturesProperty.DisplayName); + Assert.AreEqual("Doorstroomoppervlak van doorstroomopeningen.", areaFlowAperturesProperty.Description); + + PropertyDescriptor identicalAperturesProperty = dynamicProperties[floodedCulvertIdenticalAperturesPropertyIndex]; + Assert.IsFalse(identicalAperturesProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, identicalAperturesProperty.Category); + Assert.AreEqual("Aantal identieke doorstroomopeningen [-]", identicalAperturesProperty.DisplayName); + Assert.AreEqual("Aantal identieke doorstroomopeningen.", identicalAperturesProperty.Description); + + PropertyDescriptor probabilityOrFrequencyOpenStructureBeforeFloodingProperty = dynamicProperties[floodedCulvertProbabilityOpenOrFrequencyStructureBeforeFloodingPropertyIndex]; + Assert.IsFalse(probabilityOrFrequencyOpenStructureBeforeFloodingProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, probabilityOrFrequencyOpenStructureBeforeFloodingProperty.Category); + Assert.AreEqual("Kans op open staan bij naderend hoogwater [1/jaar]", probabilityOrFrequencyOpenStructureBeforeFloodingProperty.DisplayName); + Assert.AreEqual("Kans op open staan bij naderend hoogwater.", probabilityOrFrequencyOpenStructureBeforeFloodingProperty.Description); + + PropertyDescriptor failureProbabilityOpenStructureProperty = dynamicProperties[floodedCulvertFailureProbabilityOpenStructurePropertyIndex]; + Assert.IsFalse(failureProbabilityOpenStructureProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, failureProbabilityOpenStructureProperty.Category); + Assert.AreEqual("Kans mislukken sluiting [1/jaar]", failureProbabilityOpenStructureProperty.DisplayName); + Assert.AreEqual("Kans op mislukken sluiting van geopend kunstwerk.", failureProbabilityOpenStructureProperty.Description); + + PropertyDescriptor failureProbabilityReparationProperty = dynamicProperties[floodedCulvertFailureProbabilityReparationPropertyIndex]; + Assert.IsFalse(failureProbabilityReparationProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, failureProbabilityReparationProperty.Category); + Assert.AreEqual("Faalkans herstel van gefaalde situatie [1/jaar]", failureProbabilityReparationProperty.DisplayName); + Assert.AreEqual("Faalkans herstel van gefaalde situatie.", failureProbabilityReparationProperty.Description); + + PropertyDescriptor drainCoefficientProperty = dynamicProperties[floodedCulvertDrainCoefficientPropertyIndex]; + Assert.IsInstanceOf(drainCoefficientProperty.Converter); + Assert.AreEqual(modelSettingsCategory, drainCoefficientProperty.Category); + Assert.AreEqual("Afvoercoëfficiënt [-]", drainCoefficientProperty.DisplayName); + Assert.AreEqual("Afvoercoëfficiënt.", drainCoefficientProperty.Description); + + PropertyDescriptor factorStormDurationOpenStructureProperty = dynamicProperties[floodedCulvertFactorStormDurationOpenStructurePropertyIndex]; + Assert.IsFalse(factorStormDurationOpenStructureProperty.IsReadOnly); + Assert.AreEqual(modelSettingsCategory, factorStormDurationOpenStructureProperty.Category); + Assert.AreEqual("Factor voor stormduur hoogwater [-]", factorStormDurationOpenStructureProperty.DisplayName); + Assert.AreEqual("Factor voor stormduur hoogwater gegeven geopend kunstwerk.", factorStormDurationOpenStructureProperty.Description); + + // Only check the order of the base properties + Assert.AreEqual("Kunstwerk", dynamicProperties[floodedCulvertStructurePropertyIndex].DisplayName); + Assert.AreEqual("Locatie (RD) [m]", dynamicProperties[floodedCulvertStructureLocationPropertyIndex].DisplayName); + Assert.AreEqual("Stroomvoerende breedte bodembescherming [m]", dynamicProperties[floodedCulvertFlowWidthAtBottomProtectionPropertyIndex].DisplayName); + Assert.AreEqual("Kombergend oppervlak [m²]", dynamicProperties[floodedCulvertStorageStructureAreaPropertyIndex].DisplayName); + Assert.AreEqual("Toegestane peilverhoging komberging [m]", dynamicProperties[floodedCulvertAllowedLevelIncreaseStoragePropertyIndex].DisplayName); + Assert.AreEqual("Kritiek instromend debiet [m³/s/m]", dynamicProperties[floodedCulvertCriticalOvertoppingDischargePropertyIndex].DisplayName); + Assert.AreEqual("Faalkans gegeven erosie bodem [1/jaar]", dynamicProperties[floodedCulvertFailureProbabilityStructureWithErosionPropertyIndex].DisplayName); + Assert.AreEqual("Voorlandprofiel", dynamicProperties[floodedCulvertForeshoreProfilePropertyIndex].DisplayName); + Assert.AreEqual("Dam", dynamicProperties[floodedCulvertUseBreakWaterPropertyIndex].DisplayName); + Assert.AreEqual("Voorlandgeometrie", dynamicProperties[floodedCulvertUseForeshorePropertyIndex].DisplayName); + Assert.AreEqual("Locatie met hydraulische randvoorwaarden", dynamicProperties[floodedCulvertHydraulicBoundaryLocationPropertyIndex].DisplayName); + Assert.AreEqual("Stormduur [uur]", dynamicProperties[floodedCulvertStormDurationPropertyIndex].DisplayName); + + mockRepository.VerifyAll(); + } + + [Test] + public void Constructor_LowSillStructure_PropertiesHaveExpectedAttributesValues() + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + var calculation = new StructuresCalculation + { + InputParameters = + { + Structure = new TestClosingStructure(ClosingStructureInflowModelType.LowSill) + } + }; + var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, + calculation, + failureMechanism, + assessmentSectionStub); + + // Call + var properties = new ClosingStructuresInputContextProperties + { + Data = inputContext + }; + + // Assert + const string schematizationCategory = "Schematisatie"; + const string hydraulicDataCategory = "Hydraulische gegevens"; + const string modelSettingsCategory = "Modelinstellingen"; + + var dynamicPropertyBag = new DynamicPropertyBag(properties); + PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + Assert.AreEqual(22, dynamicProperties.Count); + + PropertyDescriptor insideWaterLevelProperty = dynamicProperties[lowSillInsideWaterLevelPropertyIndex]; + Assert.IsInstanceOf(insideWaterLevelProperty.Converter); + Assert.AreEqual(hydraulicDataCategory, insideWaterLevelProperty.Category); + Assert.AreEqual("Binnenwaterstand [m+NAP]", insideWaterLevelProperty.DisplayName); + Assert.AreEqual("Binnenwaterstand.", insideWaterLevelProperty.Description); + + PropertyDescriptor inflowModelTypeProperty = dynamicProperties[lowSillInflowModelTypePropertyIndex]; + Assert.IsInstanceOf(inflowModelTypeProperty.Converter); + Assert.AreEqual(schematizationCategory, inflowModelTypeProperty.Category); + Assert.AreEqual("Instroommodel", inflowModelTypeProperty.DisplayName); + Assert.AreEqual("Instroommodel van het kunstwerk.", inflowModelTypeProperty.Description); + + PropertyDescriptor identicalAperturesProperty = dynamicProperties[lowSillIdenticalAperturesPropertyIndex]; + Assert.IsFalse(identicalAperturesProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, identicalAperturesProperty.Category); + Assert.AreEqual("Aantal identieke doorstroomopeningen [-]", identicalAperturesProperty.DisplayName); + Assert.AreEqual("Aantal identieke doorstroomopeningen.", identicalAperturesProperty.Description); + + PropertyDescriptor thresholdHeightOpenWeirProperty = dynamicProperties[lowSillThresholdHeightOpenWeirPropertyIndex]; + Assert.IsInstanceOf(thresholdHeightOpenWeirProperty.Converter); + Assert.AreEqual(schematizationCategory, thresholdHeightOpenWeirProperty.Category); + Assert.AreEqual("Drempelhoogte [m+NAP]", thresholdHeightOpenWeirProperty.DisplayName); + Assert.AreEqual("Drempelhoogte niet gesloten kering of hoogte van de onderkant van de wand/drempel.", thresholdHeightOpenWeirProperty.Description); + + PropertyDescriptor probabilityOrFrequencyOpenStructureBeforeFloodingProperty = dynamicProperties[lowSillProbabilityOrFrequencyOpenStructureBeforeFloodingPropertyIndex]; + Assert.IsFalse(probabilityOrFrequencyOpenStructureBeforeFloodingProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, probabilityOrFrequencyOpenStructureBeforeFloodingProperty.Category); + Assert.AreEqual("Kans op open staan bij naderend hoogwater [1/jaar]", probabilityOrFrequencyOpenStructureBeforeFloodingProperty.DisplayName); + Assert.AreEqual("Kans op open staan bij naderend hoogwater.", probabilityOrFrequencyOpenStructureBeforeFloodingProperty.Description); + + PropertyDescriptor failureProbabilityOpenStructureProperty = dynamicProperties[lowSillFailureProbabilityOpenStructurePropertyIndex]; + Assert.IsFalse(failureProbabilityOpenStructureProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, failureProbabilityOpenStructureProperty.Category); + Assert.AreEqual("Kans mislukken sluiting [1/jaar]", failureProbabilityOpenStructureProperty.DisplayName); + Assert.AreEqual("Kans op mislukken sluiting van geopend kunstwerk.", failureProbabilityOpenStructureProperty.Description); + + PropertyDescriptor failureProbabilityReparationProperty = dynamicProperties[lowSillFailureProbabilityReparationPropertyIndex]; + Assert.IsFalse(failureProbabilityReparationProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, failureProbabilityReparationProperty.Category); + Assert.AreEqual("Faalkans herstel van gefaalde situatie [1/jaar]", failureProbabilityReparationProperty.DisplayName); + Assert.AreEqual("Faalkans herstel van gefaalde situatie.", failureProbabilityReparationProperty.Description); + + PropertyDescriptor factorStormDurationOpenStructureProperty = dynamicProperties[lowSillFactorStormDurationOpenStructurePropertyIndex]; + Assert.IsFalse(factorStormDurationOpenStructureProperty.IsReadOnly); + Assert.AreEqual(modelSettingsCategory, factorStormDurationOpenStructureProperty.Category); + Assert.AreEqual("Factor voor stormduur hoogwater [-]", factorStormDurationOpenStructureProperty.DisplayName); + Assert.AreEqual("Factor voor stormduur hoogwater gegeven geopend kunstwerk.", factorStormDurationOpenStructureProperty.Description); + + // Only check the order of the base properties + Assert.AreEqual("Kunstwerk", dynamicProperties[lowSillStructurePropertyIndex].DisplayName); + Assert.AreEqual("Locatie (RD) [m]", dynamicProperties[lowSillStructureLocationPropertyIndex].DisplayName); + Assert.AreEqual("Stroomvoerende breedte bodembescherming [m]", dynamicProperties[lowSillFlowWidthAtBottomProtectionPropertyIndex].DisplayName); + Assert.AreEqual("Breedte van doorstroomopening [m]", dynamicProperties[lowSillWidthFlowAperturesPropertyIndex].DisplayName); + Assert.AreEqual("Kombergend oppervlak [m²]", dynamicProperties[lowSillStorageStructureAreaPropertyIndex].DisplayName); + Assert.AreEqual("Toegestane peilverhoging komberging [m]", dynamicProperties[lowSillAllowedLevelIncreaseStoragePropertyIndex].DisplayName); + Assert.AreEqual("Kritiek instromend debiet [m³/s/m]", dynamicProperties[lowSillCriticalOvertoppingDischargePropertyIndex].DisplayName); + Assert.AreEqual("Faalkans gegeven erosie bodem [1/jaar]", dynamicProperties[lowSillFailureProbabilityStructureWithErosionPropertyIndex].DisplayName); + Assert.AreEqual("Modelfactor overloopdebiet volkomen overlaat [-]", dynamicProperties[lowSillModelFactorSuperCriticalFlowPropertyIndex].DisplayName); + Assert.AreEqual("Voorlandprofiel", dynamicProperties[lowSillForeshoreProfilePropertyIndex].DisplayName); + Assert.AreEqual("Dam", dynamicProperties[lowSillUseBreakWaterPropertyIndex].DisplayName); + Assert.AreEqual("Voorlandgeometrie", dynamicProperties[lowSillUseForeshorePropertyIndex].DisplayName); + Assert.AreEqual("Locatie met hydraulische randvoorwaarden", dynamicProperties[lowSillHydraulicBoundaryLocationPropertyIndex].DisplayName); + Assert.AreEqual("Stormduur [uur]", dynamicProperties[lowSillStormDurationPropertyIndex].DisplayName); + + mockRepository.VerifyAll(); + } + + [Test] public void Data_SetNewInputContextInstance_ReturnCorrectPropertyValues() { // Setup @@ -229,9 +543,69 @@ } [Test] + [TestCase(true)] + [TestCase(false)] + public void FactorStormDurationOpenStructure_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.FactorStormDurationOpenStructure = new Random(21).NextRoundedDouble()); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void InflowModelType_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.InflowModelType = new Random(21).NextEnumValue()); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void ProbabilityOrFrequencyOpenStructureBeforeFlooding_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.ProbabilityOrFrequencyOpenStructureBeforeFlooding = new Random(21).NextDouble().ToString(CultureInfo.CurrentCulture)); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void FailureProbabilityOpenStructure_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.FailureProbabilityOpenStructure = new Random(21).NextDouble().ToString(CultureInfo.CurrentCulture)); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void FailureProbabilityReparation_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.FailureProbabilityReparation = new Random(21).NextDouble().ToString(CultureInfo.CurrentCulture)); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void IdenticalApertures_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.IdenticalApertures = new Random(21).Next()); + } + + [Test] [TestCase(double.MinValue)] [TestCase(double.MaxValue)] - public void SetProbabilityOrFrequencyOpenStructureBeforeFlooding_InvalidDoubleValues_ThrowsArgumentException(double newValue) + public void ProbabilityOrFrequencyOpenStructureBeforeFlooding_InvalidDoubleValues_ThrowsArgumentException(double newValue) { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -265,7 +639,7 @@ [Test] [TestCase(double.MinValue)] [TestCase(double.MaxValue)] - public void SetProbabilityOrFrequencyOpenStructureBeforeFlooding_InvalidValues_ThrowsArgumentOutOfRangeException(double newValue) + public void ProbabilityOrFrequencyOpenStructureBeforeFlooding_InvalidValues_ThrowsArgumentOutOfRangeException(double newValue) { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -298,7 +672,7 @@ [Test] [TestCase("no double value")] [TestCase("")] - public void SetProbabilityOrFrequencyOpenStructureBeforeFlooding_ValuesUnableToParse_ThrowsArgumentException(string newValue) + public void ProbabilityOrFrequencyOpenStructureBeforeFlooding_ValuesUnableToParse_ThrowsArgumentException(string newValue) { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -327,7 +701,7 @@ } [Test] - public void SetProbabilityOrFrequencyOpenStructureBeforeFlooding_NullValue_ThrowsArgumentNullException() + public void ProbabilityOrFrequencyOpenStructureBeforeFlooding_NullValue_ThrowsArgumentNullException() { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -358,7 +732,7 @@ [Test] [TestCase(double.MinValue)] [TestCase(double.MaxValue)] - public void SetFailureProbabilityOpenStructure_InvalidValues_ThrowsArgumentException(double newValue) + public void FailureProbabilityOpenStructure_InvalidValues_ThrowsArgumentException(double newValue) { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -392,7 +766,7 @@ [Test] [TestCase("no double value")] [TestCase("")] - public void SetFailureProbabilityOpenStructure_ValuesUnableToParse_ThrowsArgumentException(string newValue) + public void FailureProbabilityOpenStructure_ValuesUnableToParse_ThrowsArgumentException(string newValue) { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -421,7 +795,7 @@ } [Test] - public void SetFailureProbabilityOpenStructure_NullValue_ThrowsArgumentNullException() + public void FailureProbabilityOpenStructure_NullValue_ThrowsArgumentNullException() { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -452,7 +826,7 @@ [Test] [TestCase(double.MinValue)] [TestCase(double.MaxValue)] - public void SetFailureProbabilityReparation_InvalidValues_ThrowsArgumentException(double newValue) + public void FailureProbabilityReparation_InvalidValues_ThrowsArgumentException(double newValue) { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -486,7 +860,7 @@ [Test] [TestCase("no double value")] [TestCase("")] - public void SetFailureProbabilityReparation_ValuesUnableToParse_ThrowsArgumentException(string newValue) + public void FailureProbabilityReparation_ValuesUnableToParse_ThrowsArgumentException(string newValue) { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -515,7 +889,7 @@ } [Test] - public void SetFailureProbabilityReparation_NullValue_ThrowsArgumentNullException() + public void FailureProbabilityReparation_NullValue_ThrowsArgumentNullException() { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -544,326 +918,13 @@ } [Test] - public void Constructor_VerticalWallStructure_PropertiesHaveExpectedAttributesValues() + public void Structure_StructureInSection_UpdateSectionResults() { // Setup var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); - var calculation = new StructuresCalculation - { - InputParameters = - { - Structure = new TestClosingStructure(ClosingStructureInflowModelType.VerticalWall) - } - }; - var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, - calculation, - failureMechanism, - assessmentSectionStub); - - // Call - var properties = new ClosingStructuresInputContextProperties - { - Data = inputContext - }; - - // Assert - const string schematizationCategory = "Schematisatie"; - const string modelSettingsCategory = "Modelinstellingen"; - - var dynamicPropertyBag = new DynamicPropertyBag(properties); - PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[] - { - new BrowsableAttribute(true) - }); - Assert.AreEqual(22, dynamicProperties.Count); - - PropertyDescriptor inflowModelTypeProperty = dynamicProperties[verticalWallInflowModelTypePropertyIndex]; - Assert.IsInstanceOf(inflowModelTypeProperty.Converter); - Assert.AreEqual(schematizationCategory, inflowModelTypeProperty.Category); - Assert.AreEqual("Instroommodel", inflowModelTypeProperty.DisplayName); - Assert.AreEqual("Instroommodel van het kunstwerk.", inflowModelTypeProperty.Description); - - PropertyDescriptor identicalAperturesProperty = dynamicProperties[verticalWallIdenticalAperturesPropertyIndex]; - Assert.IsFalse(identicalAperturesProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, identicalAperturesProperty.Category); - Assert.AreEqual("Aantal identieke doorstroomopeningen [-]", identicalAperturesProperty.DisplayName); - Assert.AreEqual("Aantal identieke doorstroomopeningen.", identicalAperturesProperty.Description); - - PropertyDescriptor levelCrestStructureNotClosingProperty = dynamicProperties[verticalWallLevelCrestStructureNotClosingPropertyIndex]; - Assert.IsInstanceOf(levelCrestStructureNotClosingProperty.Converter); - Assert.AreEqual(schematizationCategory, levelCrestStructureNotClosingProperty.Category); - Assert.AreEqual("Kruinhoogte niet gesloten kering [m+NAP]", levelCrestStructureNotClosingProperty.DisplayName); - Assert.AreEqual("Niveau kruin bij niet gesloten maximaal kerende keermiddelen.", levelCrestStructureNotClosingProperty.Description); - - PropertyDescriptor probabilityOrFrequencyOpenStructureBeforeFloodingProperty = dynamicProperties[verticalWallProbabilityOrFrequencyOpenStructureBeforeFloodingPropertyIndex]; - Assert.IsFalse(probabilityOrFrequencyOpenStructureBeforeFloodingProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, probabilityOrFrequencyOpenStructureBeforeFloodingProperty.Category); - Assert.AreEqual("Kans op open staan bij naderend hoogwater [1/jaar]", probabilityOrFrequencyOpenStructureBeforeFloodingProperty.DisplayName); - Assert.AreEqual("Kans op open staan bij naderend hoogwater.", probabilityOrFrequencyOpenStructureBeforeFloodingProperty.Description); - - PropertyDescriptor failureProbabilityOpenStructureProperty = dynamicProperties[verticalWallFailureProbabilityOpenStructurePropertyIndex]; - Assert.IsFalse(failureProbabilityOpenStructureProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, failureProbabilityOpenStructureProperty.Category); - Assert.AreEqual("Kans mislukken sluiting [1/jaar]", failureProbabilityOpenStructureProperty.DisplayName); - Assert.AreEqual("Kans op mislukken sluiting van geopend kunstwerk.", failureProbabilityOpenStructureProperty.Description); - - PropertyDescriptor failureProbabilityReparationProperty = dynamicProperties[verticalWallFailureProbabilityReparationPropertyIndex]; - Assert.IsFalse(failureProbabilityReparationProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, failureProbabilityReparationProperty.Category); - Assert.AreEqual("Faalkans herstel van gefaalde situatie [1/jaar]", failureProbabilityReparationProperty.DisplayName); - Assert.AreEqual("Faalkans herstel van gefaalde situatie.", failureProbabilityReparationProperty.Description); - - PropertyDescriptor factorStormDurationOpenStructureProperty = dynamicProperties[verticalWallFactorStormDurationOpenStructurePropertyIndex]; - Assert.IsFalse(factorStormDurationOpenStructureProperty.IsReadOnly); - Assert.AreEqual(modelSettingsCategory, factorStormDurationOpenStructureProperty.Category); - Assert.AreEqual("Factor voor stormduur hoogwater [-]", factorStormDurationOpenStructureProperty.DisplayName); - Assert.AreEqual("Factor voor stormduur hoogwater gegeven geopend kunstwerk.", factorStormDurationOpenStructureProperty.Description); - - // Only check the order of the base properties - Assert.AreEqual("Kunstwerk", dynamicProperties[verticalWallStructurePropertyIndex].DisplayName); - Assert.AreEqual("Locatie (RD) [m]", dynamicProperties[verticalWallStructureLocationPropertyIndex].DisplayName); - Assert.AreEqual("Oriëntatie [°]", dynamicProperties[verticalWallStructureNormalOrientationPropertyIndex].DisplayName); - Assert.AreEqual("Stroomvoerende breedte bodembescherming [m]", dynamicProperties[verticalWallFlowWidthAtBottomProtectionPropertyIndex].DisplayName); - Assert.AreEqual("Breedte van doorstroomopening [m]", dynamicProperties[verticalWallWidthFlowAperturesPropertyIndex].DisplayName); - Assert.AreEqual("Kombergend oppervlak [m²]", dynamicProperties[verticalWallStorageStructureAreaPropertyIndex].DisplayName); - Assert.AreEqual("Toegestane peilverhoging komberging [m]", dynamicProperties[verticalWallAllowedLevelIncreaseStoragePropertyIndex].DisplayName); - Assert.AreEqual("Kritiek instromend debiet [m³/s/m]", dynamicProperties[verticalWallCriticalOvertoppingDischargePropertyIndex].DisplayName); - Assert.AreEqual("Faalkans gegeven erosie bodem [1/jaar]", dynamicProperties[verticalWallFailureProbabilityStructureWithErosionPropertyIndex].DisplayName); - Assert.AreEqual("Modelfactor overloopdebiet volkomen overlaat [-]", dynamicProperties[verticalWallModelFactorSuperCriticalFlowPropertyIndex].DisplayName); - Assert.AreEqual("Voorlandprofiel", dynamicProperties[verticalWallForeshoreProfilePropertyIndex].DisplayName); - Assert.AreEqual("Dam", dynamicProperties[verticalWallUseBreakWaterPropertyIndex].DisplayName); - Assert.AreEqual("Voorlandgeometrie", dynamicProperties[verticalWallUseForeshorePropertyIndex].DisplayName); - Assert.AreEqual("Locatie met hydraulische randvoorwaarden", dynamicProperties[verticalWallHydraulicBoundaryLocationPropertyIndex].DisplayName); - Assert.AreEqual("Stormduur [uur]", dynamicProperties[verticalWallStormDurationPropertyIndex].DisplayName); - - mockRepository.VerifyAll(); - } - - [Test] - public void Constructor_FloodedCulvertStructure_PropertiesHaveExpectedAttributesValues() - { - // Setup - var assessmentSectionStub = mockRepository.Stub(); - mockRepository.ReplayAll(); - - var failureMechanism = new ClosingStructuresFailureMechanism(); - var calculation = new StructuresCalculation - { - InputParameters = - { - Structure = new TestClosingStructure(ClosingStructureInflowModelType.FloodedCulvert) - } - }; - var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, - calculation, - failureMechanism, - assessmentSectionStub); - - // Call - var properties = new ClosingStructuresInputContextProperties - { - Data = inputContext - }; - - // Assert - const string schematizationCategory = "Schematisatie"; - const string hydraulicDataCategory = "Hydraulische gegevens"; - const string modelSettingsCategory = "Modelinstellingen"; - - var dynamicPropertyBag = new DynamicPropertyBag(properties); - PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[] - { - new BrowsableAttribute(true) - }); - Assert.AreEqual(21, dynamicProperties.Count); - - PropertyDescriptor insideWaterLevelProperty = dynamicProperties[floodedCulvertInsideWaterLevelPropertyIndex]; - Assert.IsInstanceOf(insideWaterLevelProperty.Converter); - Assert.AreEqual(hydraulicDataCategory, insideWaterLevelProperty.Category); - Assert.AreEqual("Binnenwaterstand [m+NAP]", insideWaterLevelProperty.DisplayName); - Assert.AreEqual("Binnenwaterstand.", insideWaterLevelProperty.Description); - - PropertyDescriptor inflowModelTypeProperty = dynamicProperties[floodedCulvertInflowModelTypePropertyIndex]; - Assert.IsInstanceOf(inflowModelTypeProperty.Converter); - Assert.AreEqual(schematizationCategory, inflowModelTypeProperty.Category); - Assert.AreEqual("Instroommodel", inflowModelTypeProperty.DisplayName); - Assert.AreEqual("Instroommodel van het kunstwerk.", inflowModelTypeProperty.Description); - - PropertyDescriptor areaFlowAperturesProperty = dynamicProperties[floodedCulvertAreaFlowAperturesPropertyIndex]; - Assert.IsInstanceOf(areaFlowAperturesProperty.Converter); - Assert.AreEqual(schematizationCategory, areaFlowAperturesProperty.Category); - Assert.AreEqual("Doorstroomoppervlak [m²]", areaFlowAperturesProperty.DisplayName); - Assert.AreEqual("Doorstroomoppervlak van doorstroomopeningen.", areaFlowAperturesProperty.Description); - - PropertyDescriptor identicalAperturesProperty = dynamicProperties[floodedCulvertIdenticalAperturesPropertyIndex]; - Assert.IsFalse(identicalAperturesProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, identicalAperturesProperty.Category); - Assert.AreEqual("Aantal identieke doorstroomopeningen [-]", identicalAperturesProperty.DisplayName); - Assert.AreEqual("Aantal identieke doorstroomopeningen.", identicalAperturesProperty.Description); - - PropertyDescriptor probabilityOrFrequencyOpenStructureBeforeFloodingProperty = dynamicProperties[floodedCulvertProbabilityOpenOrFrequencyStructureBeforeFloodingPropertyIndex]; - Assert.IsFalse(probabilityOrFrequencyOpenStructureBeforeFloodingProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, probabilityOrFrequencyOpenStructureBeforeFloodingProperty.Category); - Assert.AreEqual("Kans op open staan bij naderend hoogwater [1/jaar]", probabilityOrFrequencyOpenStructureBeforeFloodingProperty.DisplayName); - Assert.AreEqual("Kans op open staan bij naderend hoogwater.", probabilityOrFrequencyOpenStructureBeforeFloodingProperty.Description); - - PropertyDescriptor failureProbabilityOpenStructureProperty = dynamicProperties[floodedCulvertFailureProbabilityOpenStructurePropertyIndex]; - Assert.IsFalse(failureProbabilityOpenStructureProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, failureProbabilityOpenStructureProperty.Category); - Assert.AreEqual("Kans mislukken sluiting [1/jaar]", failureProbabilityOpenStructureProperty.DisplayName); - Assert.AreEqual("Kans op mislukken sluiting van geopend kunstwerk.", failureProbabilityOpenStructureProperty.Description); - - PropertyDescriptor failureProbabilityReparationProperty = dynamicProperties[floodedCulvertFailureProbabilityReparationPropertyIndex]; - Assert.IsFalse(failureProbabilityReparationProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, failureProbabilityReparationProperty.Category); - Assert.AreEqual("Faalkans herstel van gefaalde situatie [1/jaar]", failureProbabilityReparationProperty.DisplayName); - Assert.AreEqual("Faalkans herstel van gefaalde situatie.", failureProbabilityReparationProperty.Description); - - PropertyDescriptor drainCoefficientProperty = dynamicProperties[floodedCulvertDrainCoefficientPropertyIndex]; - Assert.IsInstanceOf(drainCoefficientProperty.Converter); - Assert.AreEqual(modelSettingsCategory, drainCoefficientProperty.Category); - Assert.AreEqual("Afvoercoëfficiënt [-]", drainCoefficientProperty.DisplayName); - Assert.AreEqual("Afvoercoëfficiënt.", drainCoefficientProperty.Description); - - PropertyDescriptor factorStormDurationOpenStructureProperty = dynamicProperties[floodedCulvertFactorStormDurationOpenStructurePropertyIndex]; - Assert.IsFalse(factorStormDurationOpenStructureProperty.IsReadOnly); - Assert.AreEqual(modelSettingsCategory, factorStormDurationOpenStructureProperty.Category); - Assert.AreEqual("Factor voor stormduur hoogwater [-]", factorStormDurationOpenStructureProperty.DisplayName); - Assert.AreEqual("Factor voor stormduur hoogwater gegeven geopend kunstwerk.", factorStormDurationOpenStructureProperty.Description); - - // Only check the order of the base properties - Assert.AreEqual("Kunstwerk", dynamicProperties[floodedCulvertStructurePropertyIndex].DisplayName); - Assert.AreEqual("Locatie (RD) [m]", dynamicProperties[floodedCulvertStructureLocationPropertyIndex].DisplayName); - Assert.AreEqual("Stroomvoerende breedte bodembescherming [m]", dynamicProperties[floodedCulvertFlowWidthAtBottomProtectionPropertyIndex].DisplayName); - Assert.AreEqual("Kombergend oppervlak [m²]", dynamicProperties[floodedCulvertStorageStructureAreaPropertyIndex].DisplayName); - Assert.AreEqual("Toegestane peilverhoging komberging [m]", dynamicProperties[floodedCulvertAllowedLevelIncreaseStoragePropertyIndex].DisplayName); - Assert.AreEqual("Kritiek instromend debiet [m³/s/m]", dynamicProperties[floodedCulvertCriticalOvertoppingDischargePropertyIndex].DisplayName); - Assert.AreEqual("Faalkans gegeven erosie bodem [1/jaar]", dynamicProperties[floodedCulvertFailureProbabilityStructureWithErosionPropertyIndex].DisplayName); - Assert.AreEqual("Voorlandprofiel", dynamicProperties[floodedCulvertForeshoreProfilePropertyIndex].DisplayName); - Assert.AreEqual("Dam", dynamicProperties[floodedCulvertUseBreakWaterPropertyIndex].DisplayName); - Assert.AreEqual("Voorlandgeometrie", dynamicProperties[floodedCulvertUseForeshorePropertyIndex].DisplayName); - Assert.AreEqual("Locatie met hydraulische randvoorwaarden", dynamicProperties[floodedCulvertHydraulicBoundaryLocationPropertyIndex].DisplayName); - Assert.AreEqual("Stormduur [uur]", dynamicProperties[floodedCulvertStormDurationPropertyIndex].DisplayName); - - mockRepository.VerifyAll(); - } - - [Test] - public void Constructor_LowSillStructure_PropertiesHaveExpectedAttributesValues() - { - // Setup - var assessmentSectionStub = mockRepository.Stub(); - mockRepository.ReplayAll(); - - var failureMechanism = new ClosingStructuresFailureMechanism(); - var calculation = new StructuresCalculation - { - InputParameters = - { - Structure = new TestClosingStructure(ClosingStructureInflowModelType.LowSill) - } - }; - var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, - calculation, - failureMechanism, - assessmentSectionStub); - - // Call - var properties = new ClosingStructuresInputContextProperties - { - Data = inputContext - }; - - // Assert - const string schematizationCategory = "Schematisatie"; - const string hydraulicDataCategory = "Hydraulische gegevens"; - const string modelSettingsCategory = "Modelinstellingen"; - - var dynamicPropertyBag = new DynamicPropertyBag(properties); - PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[] - { - new BrowsableAttribute(true) - }); - Assert.AreEqual(22, dynamicProperties.Count); - - PropertyDescriptor insideWaterLevelProperty = dynamicProperties[lowSillInsideWaterLevelPropertyIndex]; - Assert.IsInstanceOf(insideWaterLevelProperty.Converter); - Assert.AreEqual(hydraulicDataCategory, insideWaterLevelProperty.Category); - Assert.AreEqual("Binnenwaterstand [m+NAP]", insideWaterLevelProperty.DisplayName); - Assert.AreEqual("Binnenwaterstand.", insideWaterLevelProperty.Description); - - PropertyDescriptor inflowModelTypeProperty = dynamicProperties[lowSillInflowModelTypePropertyIndex]; - Assert.IsInstanceOf(inflowModelTypeProperty.Converter); - Assert.AreEqual(schematizationCategory, inflowModelTypeProperty.Category); - Assert.AreEqual("Instroommodel", inflowModelTypeProperty.DisplayName); - Assert.AreEqual("Instroommodel van het kunstwerk.", inflowModelTypeProperty.Description); - - PropertyDescriptor identicalAperturesProperty = dynamicProperties[lowSillIdenticalAperturesPropertyIndex]; - Assert.IsFalse(identicalAperturesProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, identicalAperturesProperty.Category); - Assert.AreEqual("Aantal identieke doorstroomopeningen [-]", identicalAperturesProperty.DisplayName); - Assert.AreEqual("Aantal identieke doorstroomopeningen.", identicalAperturesProperty.Description); - - PropertyDescriptor thresholdHeightOpenWeirProperty = dynamicProperties[lowSillThresholdHeightOpenWeirPropertyIndex]; - Assert.IsInstanceOf(thresholdHeightOpenWeirProperty.Converter); - Assert.AreEqual(schematizationCategory, thresholdHeightOpenWeirProperty.Category); - Assert.AreEqual("Drempelhoogte [m+NAP]", thresholdHeightOpenWeirProperty.DisplayName); - Assert.AreEqual("Drempelhoogte niet gesloten kering of hoogte van de onderkant van de wand/drempel.", thresholdHeightOpenWeirProperty.Description); - - PropertyDescriptor probabilityOrFrequencyOpenStructureBeforeFloodingProperty = dynamicProperties[lowSillProbabilityOrFrequencyOpenStructureBeforeFloodingPropertyIndex]; - Assert.IsFalse(probabilityOrFrequencyOpenStructureBeforeFloodingProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, probabilityOrFrequencyOpenStructureBeforeFloodingProperty.Category); - Assert.AreEqual("Kans op open staan bij naderend hoogwater [1/jaar]", probabilityOrFrequencyOpenStructureBeforeFloodingProperty.DisplayName); - Assert.AreEqual("Kans op open staan bij naderend hoogwater.", probabilityOrFrequencyOpenStructureBeforeFloodingProperty.Description); - - PropertyDescriptor failureProbabilityOpenStructureProperty = dynamicProperties[lowSillFailureProbabilityOpenStructurePropertyIndex]; - Assert.IsFalse(failureProbabilityOpenStructureProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, failureProbabilityOpenStructureProperty.Category); - Assert.AreEqual("Kans mislukken sluiting [1/jaar]", failureProbabilityOpenStructureProperty.DisplayName); - Assert.AreEqual("Kans op mislukken sluiting van geopend kunstwerk.", failureProbabilityOpenStructureProperty.Description); - - PropertyDescriptor failureProbabilityReparationProperty = dynamicProperties[lowSillFailureProbabilityReparationPropertyIndex]; - Assert.IsFalse(failureProbabilityReparationProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, failureProbabilityReparationProperty.Category); - Assert.AreEqual("Faalkans herstel van gefaalde situatie [1/jaar]", failureProbabilityReparationProperty.DisplayName); - Assert.AreEqual("Faalkans herstel van gefaalde situatie.", failureProbabilityReparationProperty.Description); - - PropertyDescriptor factorStormDurationOpenStructureProperty = dynamicProperties[lowSillFactorStormDurationOpenStructurePropertyIndex]; - Assert.IsFalse(factorStormDurationOpenStructureProperty.IsReadOnly); - Assert.AreEqual(modelSettingsCategory, factorStormDurationOpenStructureProperty.Category); - Assert.AreEqual("Factor voor stormduur hoogwater [-]", factorStormDurationOpenStructureProperty.DisplayName); - Assert.AreEqual("Factor voor stormduur hoogwater gegeven geopend kunstwerk.", factorStormDurationOpenStructureProperty.Description); - - // Only check the order of the base properties - Assert.AreEqual("Kunstwerk", dynamicProperties[lowSillStructurePropertyIndex].DisplayName); - Assert.AreEqual("Locatie (RD) [m]", dynamicProperties[lowSillStructureLocationPropertyIndex].DisplayName); - Assert.AreEqual("Stroomvoerende breedte bodembescherming [m]", dynamicProperties[lowSillFlowWidthAtBottomProtectionPropertyIndex].DisplayName); - Assert.AreEqual("Breedte van doorstroomopening [m]", dynamicProperties[lowSillWidthFlowAperturesPropertyIndex].DisplayName); - Assert.AreEqual("Kombergend oppervlak [m²]", dynamicProperties[lowSillStorageStructureAreaPropertyIndex].DisplayName); - Assert.AreEqual("Toegestane peilverhoging komberging [m]", dynamicProperties[lowSillAllowedLevelIncreaseStoragePropertyIndex].DisplayName); - Assert.AreEqual("Kritiek instromend debiet [m³/s/m]", dynamicProperties[lowSillCriticalOvertoppingDischargePropertyIndex].DisplayName); - Assert.AreEqual("Faalkans gegeven erosie bodem [1/jaar]", dynamicProperties[lowSillFailureProbabilityStructureWithErosionPropertyIndex].DisplayName); - Assert.AreEqual("Modelfactor overloopdebiet volkomen overlaat [-]", dynamicProperties[lowSillModelFactorSuperCriticalFlowPropertyIndex].DisplayName); - Assert.AreEqual("Voorlandprofiel", dynamicProperties[lowSillForeshoreProfilePropertyIndex].DisplayName); - Assert.AreEqual("Dam", dynamicProperties[lowSillUseBreakWaterPropertyIndex].DisplayName); - Assert.AreEqual("Voorlandgeometrie", dynamicProperties[lowSillUseForeshorePropertyIndex].DisplayName); - Assert.AreEqual("Locatie met hydraulische randvoorwaarden", dynamicProperties[lowSillHydraulicBoundaryLocationPropertyIndex].DisplayName); - Assert.AreEqual("Stormduur [uur]", dynamicProperties[lowSillStormDurationPropertyIndex].DisplayName); - - mockRepository.VerifyAll(); - } - - [Test] - public void SetStructure_StructureInSection_UpdateSectionResults() - { - // Setup - var assessmentSectionStub = mockRepository.Stub(); - mockRepository.ReplayAll(); - - var failureMechanism = new ClosingStructuresFailureMechanism(); var calculation = new StructuresCalculation(); var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, calculation, @@ -1113,5 +1174,52 @@ #endregion #endregion + + private void SetPropertyAndVerifyNotifcationsAndOutput( + bool hasOutput, + Action setProperty) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + + var calculationObserver = mocks.StrictMock(); + int numberOfChangedProperties = hasOutput ? 1 : 0; + calculationObserver.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties); + + var inputObserver = mocks.StrictMock(); + inputObserver.Expect(o => o.UpdateObserver()); + + mocks.ReplayAll(); + + var calculation = new StructuresCalculation(); + + if (hasOutput) + { + calculation.Output = new TestStructuresOutput(); + } + calculation.Attach(calculationObserver); + + ClosingStructuresInput inputParameters = calculation.InputParameters; + inputParameters.Attach(inputObserver); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var properties = new ClosingStructuresInputContextProperties + { + Data = new ClosingStructuresInputContext(inputParameters, + calculation, + failureMechanism, + assessmentSection) + }; + + // Call + setProperty(properties); + + // Assert + Assert.IsFalse(calculation.HasOutput); + + mocks.VerifyAll(); + } } } \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/Ringtoets.ClosingStructures.Plugin.Test.csproj =================================================================== diff -u -r5f8541d2a46730d67fc2d859caa6de2921bbc820 -rd69cf89498b4f926407d0261a747a4a7a8d37e62 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/Ringtoets.ClosingStructures.Plugin.Test.csproj (.../Ringtoets.ClosingStructures.Plugin.Test.csproj) (revision 5f8541d2a46730d67fc2d859caa6de2921bbc820) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/Ringtoets.ClosingStructures.Plugin.Test.csproj (.../Ringtoets.ClosingStructures.Plugin.Test.csproj) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62) @@ -129,6 +129,10 @@ Ringtoets.Common.IO True + + {4843D6E5-066F-4795-94F5-1D53932DD03C} + Ringtoets.Common.Data.TestUtil + {74CBA865-9338-447F-BAD9-28312446AE84} Ringtoets.HydraRing.Calculation.TestUtil Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rf2f7d22ee59276f5df1f83fd409899bd895ea163 -rd69cf89498b4f926407d0261a747a4a7a8d37e62 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationContextTreeNodeInfoTest.cs) (revision f2f7d22ee59276f5df1f83fd409899bd895ea163) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationContextTreeNodeInfoTest.cs) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62) @@ -45,6 +45,7 @@ using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.Probability; using Ringtoets.Common.Data.Structures; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -158,7 +159,7 @@ var failureMechanism = new ClosingStructuresFailureMechanism(); var calculation = new StructuresCalculation { - Output = new TestClosingStructuresOutput() + Output = new TestStructuresOutput() }; var calculationContext = new ClosingStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); @@ -657,10 +658,5 @@ // Assert Assert.IsNull(result.Calculation); } - - private class TestClosingStructuresOutput : ProbabilityAssessmentOutput - { - public TestClosingStructuresOutput() : base(0, 0, 0, 0, 0) {} - } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresCalculationTest.cs =================================================================== diff -u -rb4e3629ea2130359117dd403af8db3c8ae0c680b -rd69cf89498b4f926407d0261a747a4a7a8d37e62 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresCalculationTest.cs (.../StructuresCalculationTest.cs) (revision b4e3629ea2130359117dd403af8db3c8ae0c680b) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresCalculationTest.cs (.../StructuresCalculationTest.cs) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62) @@ -22,8 +22,8 @@ using Core.Common.Base; using NUnit.Framework; using Ringtoets.Common.Data.Calculation; -using Ringtoets.Common.Data.Probability; using Ringtoets.Common.Data.Structures; +using Ringtoets.Common.Data.TestUtil; namespace Ringtoets.Common.Data.Test.Structures { @@ -136,10 +136,5 @@ public void NotifyObservers() {} } - - private class TestStructuresOutput : ProbabilityAssessmentOutput - { - public TestStructuresOutput() : base(0, 0, 0, 0, 0) {} - } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj =================================================================== diff -u -r23d1e296e2da4364fbfe346e68d582dfcf966bb0 -rd69cf89498b4f926407d0261a747a4a7a8d37e62 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj (.../Ringtoets.Common.Data.TestUtil.Test.csproj) (revision 23d1e296e2da4364fbfe346e68d582dfcf966bb0) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj (.../Ringtoets.Common.Data.TestUtil.Test.csproj) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62) @@ -63,6 +63,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/TestStructuresOutputTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/TestStructuresOutputTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/TestStructuresOutputTest.cs (revision d69cf89498b4f926407d0261a747a4a7a8d37e62) @@ -0,0 +1,22 @@ +using NUnit.Framework; + +namespace Ringtoets.Common.Data.TestUtil.Test +{ + [TestFixture] + public class TestStructuresOutputTest + { + [Test] + public void Constructor_SetExpectedValues() + { + // Call + var output = new TestStructuresOutput(); + + // Assert + Assert.AreEqual(0, output.FactorOfSafety.Value); + Assert.AreEqual(0, output.RequiredProbability); + Assert.AreEqual(0, output.Probability); + Assert.AreEqual(0, output.RequiredReliability.Value); + Assert.AreEqual(0, output.Reliability.Value); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/Ringtoets.Common.Data.TestUtil.csproj =================================================================== diff -u -r23d1e296e2da4364fbfe346e68d582dfcf966bb0 -rd69cf89498b4f926407d0261a747a4a7a8d37e62 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/Ringtoets.Common.Data.TestUtil.csproj (.../Ringtoets.Common.Data.TestUtil.csproj) (revision 23d1e296e2da4364fbfe346e68d582dfcf966bb0) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/Ringtoets.Common.Data.TestUtil.csproj (.../Ringtoets.Common.Data.TestUtil.csproj) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62) @@ -64,6 +64,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/TestStructuresOutput.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/TestStructuresOutput.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/TestStructuresOutput.cs (revision d69cf89498b4f926407d0261a747a4a7a8d37e62) @@ -0,0 +1,16 @@ +using Ringtoets.Common.Data.Probability; + +namespace Ringtoets.Common.Data.TestUtil +{ + /// + /// Simple that can be used for tests where actual output + /// values are not important. + /// + public class TestStructuresOutput : ProbabilityAssessmentOutput + { + /// + /// Creates new instance of . + /// + public TestStructuresOutput() : base(0, 0, 0, 0, 0) {} + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs =================================================================== diff -u -r545b105a213ed85564861b4bcf6d2d6425dbde50 -rd69cf89498b4f926407d0261a747a4a7a8d37e62 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs (.../StructuresInputBasePropertiesTest.cs) (revision 545b105a213ed85564861b4bcf6d2d6425dbde50) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs (.../StructuresInputBasePropertiesTest.cs) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62) @@ -57,28 +57,137 @@ } [Test] + public void Constructor_ConstructionPropertiesIsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SimpleStructuresInputProperties(null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("constructionProperties", paramName); + } + + [Test] public void Constructor_ExpectedValues() { + // Setup + var constructionProperties = GetRandomConstructionProperties(); + // Call - var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties()); + var properties = new SimpleStructuresInputProperties(constructionProperties); // Assert Assert.IsInstanceOf, IFailureMechanism>>>(properties); Assert.IsInstanceOf(properties); Assert.IsInstanceOf>(properties); Assert.IsInstanceOf(properties); Assert.IsNull(properties.Data); - } - [Test] - public void Constructor_ConstructionPropertiesIsNull_ThrowsArgumentNullException() - { - // Call - TestDelegate call = () => new SimpleStructuresInputProperties(null); + const string schematizationCategory = "Schematisatie"; + const string hydraulicDataCategory = "Hydraulische gegevens"; + const string modelSettingsCategory = "Modelinstellingen"; - // Assert - string paramName = Assert.Throws(call).ParamName; - Assert.AreEqual("constructionProperties", paramName); + var dynamicPropertyBag = new DynamicPropertyBag(properties); + PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties( + new Attribute[] + { + new BrowsableAttribute(true) + }); + Assert.AreEqual(15, dynamicProperties.Count); + + PropertyDescriptor structureProperty = dynamicProperties[constructionProperties.StructurePropertyIndex]; + Assert.IsFalse(structureProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, structureProperty.Category); + Assert.AreEqual("Kunstwerk", structureProperty.DisplayName); + Assert.AreEqual("Het kunstwerk dat gebruikt wordt in de berekening.", structureProperty.Description); + + PropertyDescriptor structureLocationProperty = dynamicProperties[constructionProperties.StructureLocationPropertyIndex]; + Assert.IsTrue(structureLocationProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, structureLocationProperty.Category); + Assert.AreEqual("Locatie (RD) [m]", structureLocationProperty.DisplayName); + Assert.AreEqual("De coördinaten van de locatie van het kunstwerk in het Rijksdriehoeksstelsel.", structureLocationProperty.Description); + + PropertyDescriptor structureNormalOrientationProperty = dynamicProperties[constructionProperties.StructureNormalOrientationPropertyIndex]; + Assert.IsFalse(structureNormalOrientationProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, structureNormalOrientationProperty.Category); + Assert.AreEqual("Oriëntatie [°]", structureNormalOrientationProperty.DisplayName); + Assert.AreEqual("Oriëntatie van de normaal van het kunstwerk ten opzichte van het noorden.", structureNormalOrientationProperty.Description); + + PropertyDescriptor flowWidthAtBottomProtectionProperty = dynamicProperties[constructionProperties.FlowWidthAtBottomProtectionPropertyIndex]; + Assert.IsInstanceOf(flowWidthAtBottomProtectionProperty.Converter); + Assert.AreEqual(schematizationCategory, flowWidthAtBottomProtectionProperty.Category); + Assert.AreEqual("Stroomvoerende breedte bodembescherming [m]", flowWidthAtBottomProtectionProperty.DisplayName); + Assert.AreEqual("Stroomvoerende breedte bodembescherming.", flowWidthAtBottomProtectionProperty.Description); + + PropertyDescriptor widthFlowAperturesProperty = dynamicProperties[constructionProperties.WidthFlowAperturesPropertyIndex]; + Assert.IsInstanceOf(widthFlowAperturesProperty.Converter); + Assert.AreEqual(schematizationCategory, widthFlowAperturesProperty.Category); + Assert.AreEqual("Breedte van doorstroomopening [m]", widthFlowAperturesProperty.DisplayName); + Assert.AreEqual("Breedte van de doorstroomopening.", widthFlowAperturesProperty.Description); + + PropertyDescriptor storageStructureAreaProperty = dynamicProperties[constructionProperties.StorageStructureAreaPropertyIndex]; + Assert.IsInstanceOf(storageStructureAreaProperty.Converter); + Assert.AreEqual(schematizationCategory, storageStructureAreaProperty.Category); + Assert.AreEqual("Kombergend oppervlak [m²]", storageStructureAreaProperty.DisplayName); + Assert.AreEqual("Kombergend oppervlak.", storageStructureAreaProperty.Description); + + PropertyDescriptor allowedLevelIncreaseStorageProperty = dynamicProperties[constructionProperties.AllowedLevelIncreaseStoragePropertyIndex]; + Assert.IsInstanceOf(allowedLevelIncreaseStorageProperty.Converter); + Assert.AreEqual(schematizationCategory, allowedLevelIncreaseStorageProperty.Category); + Assert.AreEqual("Toegestane peilverhoging komberging [m]", allowedLevelIncreaseStorageProperty.DisplayName); + Assert.AreEqual("Toegestane peilverhoging komberging.", allowedLevelIncreaseStorageProperty.Description); + + PropertyDescriptor criticalOvertoppingDischargeProperty = dynamicProperties[constructionProperties.CriticalOvertoppingDischargePropertyIndex]; + Assert.IsInstanceOf(criticalOvertoppingDischargeProperty.Converter); + Assert.AreEqual(schematizationCategory, criticalOvertoppingDischargeProperty.Category); + Assert.AreEqual("Kritiek instromend debiet [m³/s/m]", criticalOvertoppingDischargeProperty.DisplayName); + Assert.AreEqual("Kritiek instromend debiet directe invoer per strekkende meter.", criticalOvertoppingDischargeProperty.Description); + + PropertyDescriptor failureProbabilityStructureWithErosionProperty = dynamicProperties[constructionProperties.FailureProbabilityStructureWithErosionPropertyIndex]; + Assert.IsFalse(failureProbabilityStructureWithErosionProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, failureProbabilityStructureWithErosionProperty.Category); + Assert.AreEqual("Faalkans gegeven erosie bodem [1/jaar]", failureProbabilityStructureWithErosionProperty.DisplayName); + Assert.AreEqual("Faalkans kunstwerk gegeven erosie bodem.", failureProbabilityStructureWithErosionProperty.Description); + + PropertyDescriptor modelFactorSuperCriticalFlowProperty = dynamicProperties[constructionProperties.ModelFactorSuperCriticalFlowPropertyIndex]; + Assert.IsInstanceOf(modelFactorSuperCriticalFlowProperty.Converter); + Assert.AreEqual(modelSettingsCategory, modelFactorSuperCriticalFlowProperty.Category); + Assert.AreEqual("Modelfactor overloopdebiet volkomen overlaat [-]", modelFactorSuperCriticalFlowProperty.DisplayName); + Assert.AreEqual("Modelfactor voor het overloopdebiet over een volkomen overlaat.", modelFactorSuperCriticalFlowProperty.Description); + + PropertyDescriptor foreshoreProfileProperty = dynamicProperties[constructionProperties.ForeshoreProfilePropertyIndex]; + Assert.IsFalse(foreshoreProfileProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, foreshoreProfileProperty.Category); + Assert.AreEqual("Voorlandprofiel", foreshoreProfileProperty.DisplayName); + Assert.AreEqual("De schematisatie van het voorlandprofiel.", foreshoreProfileProperty.Description); + + PropertyDescriptor useBreakWaterProperty = dynamicProperties[constructionProperties.UseBreakWaterPropertyIndex]; + Assert.IsInstanceOf(useBreakWaterProperty.Converter); + Assert.IsTrue(useBreakWaterProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, useBreakWaterProperty.Category); + Assert.AreEqual("Dam", useBreakWaterProperty.DisplayName); + Assert.AreEqual("Eigenschappen van de dam.", useBreakWaterProperty.Description); + + PropertyDescriptor useForeshoreProperty = dynamicProperties[constructionProperties.UseForeshorePropertyIndex]; + Assert.IsInstanceOf(useForeshoreProperty.Converter); + Assert.IsTrue(useForeshoreProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, useForeshoreProperty.Category); + Assert.AreEqual("Voorlandgeometrie", useForeshoreProperty.DisplayName); + Assert.AreEqual("Eigenschappen van de voorlandgeometrie.", useForeshoreProperty.Description); + + PropertyDescriptor hydraulicBoundaryLocationProperty = dynamicProperties[constructionProperties.HydraulicBoundaryLocationPropertyIndex]; + Assert.IsFalse(hydraulicBoundaryLocationProperty.IsReadOnly); + Assert.AreEqual(hydraulicDataCategory, hydraulicBoundaryLocationProperty.Category); + Assert.AreEqual("Locatie met hydraulische randvoorwaarden", hydraulicBoundaryLocationProperty.DisplayName); + Assert.AreEqual("De locatie met hydraulische randvoorwaarden.", hydraulicBoundaryLocationProperty.Description); + + PropertyDescriptor stormDurationProperty = dynamicProperties[constructionProperties.StormDurationPropertyIndex]; + Assert.IsInstanceOf(stormDurationProperty.Converter); + Assert.AreEqual(hydraulicDataCategory, stormDurationProperty.Category); + Assert.AreEqual("Stormduur [uur]", stormDurationProperty.DisplayName); + Assert.AreEqual("Stormduur.", stormDurationProperty.Description); + + mockRepository.VerifyAll(); } [Test] @@ -363,8 +472,58 @@ } [Test] - public void SetStructure_NullValue_AfterSettingStructureCalled() + [TestCase(true)] + [TestCase(false)] + public void Structure_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.Structure = new SimpleStructure()); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void StructureNormalOrientation_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.StructureNormalOrientation = new Random(21).NextRoundedDouble()); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void FailureProbabilityStructureWithErosion_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.FailureProbabilityStructureWithErosion = new Random(21).NextDouble().ToString(CultureInfo.CurrentCulture)); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void SelectedHydraulicBoundaryLocation_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.SelectedHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation(CreateHydraulicBoundaryLocation(), null)); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void ForeshoreProfile_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.ForeshoreProfile = new TestForeshoreProfile()); + } + + [Test] + public void Structure_NullValue_AfterSettingStructureCalled() + { // Setup var assessmentSectionStub = mockRepository.Stub(); var failureMechanismStub = mockRepository.Stub(); @@ -391,7 +550,7 @@ } [Test] - public void SetStructure_ValidValue_AfterSettingStructureCalled() + public void Structure_ValidValue_AfterSettingStructureCalled() { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -421,7 +580,7 @@ [Test] [TestCase(double.MinValue)] [TestCase(double.MaxValue)] - public void SetFailureProbabilityStructureWithErosion_InvalidValues_ThrowsArgumentException(double newValue) + public void FailureProbabilityStructureWithErosion_InvalidValues_ThrowsArgumentException(double newValue) { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -451,7 +610,7 @@ [Test] [TestCase("no double value")] [TestCase("")] - public void SetFailureProbabilityStructureWithErosion_ValuesUnableToParse_ThrowsArgumentException(string newValue) + public void FailureProbabilityStructureWithErosion_ValuesUnableToParse_ThrowsArgumentException(string newValue) { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -479,7 +638,7 @@ } [Test] - public void SetFailureProbabilityStructureWithErosion_NullValue_ThrowsArgumentNullException() + public void FailureProbabilityStructureWithErosion_NullValue_ThrowsArgumentNullException() { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -506,135 +665,6 @@ mockRepository.VerifyAll(); } - [Test] - public void Constructor_Always_PropertiesHaveExpectedAttributesValues() - { - // Setup - var assessmentSectionStub = mockRepository.Stub(); - var failureMechanismStub = mockRepository.Stub(); - mockRepository.ReplayAll(); - - var calculation = new StructuresCalculation(); - var inputContext = new SimpleInputContext(calculation.InputParameters, - calculation, - failureMechanismStub, - assessmentSectionStub); - var constructionProperties = GetRandomConstructionProperties(); - - // Call - var properties = new SimpleStructuresInputProperties(constructionProperties) - { - Data = inputContext - }; - - // Assert - const string schematizationCategory = "Schematisatie"; - const string hydraulicDataCategory = "Hydraulische gegevens"; - const string modelSettingsCategory = "Modelinstellingen"; - - var dynamicPropertyBag = new DynamicPropertyBag(properties); - PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties( - new Attribute[] - { - new BrowsableAttribute(true) - }); - Assert.AreEqual(15, dynamicProperties.Count); - - PropertyDescriptor structureProperty = dynamicProperties[constructionProperties.StructurePropertyIndex]; - Assert.IsFalse(structureProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, structureProperty.Category); - Assert.AreEqual("Kunstwerk", structureProperty.DisplayName); - Assert.AreEqual("Het kunstwerk dat gebruikt wordt in de berekening.", structureProperty.Description); - - PropertyDescriptor structureLocationProperty = dynamicProperties[constructionProperties.StructureLocationPropertyIndex]; - Assert.IsTrue(structureLocationProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, structureLocationProperty.Category); - Assert.AreEqual("Locatie (RD) [m]", structureLocationProperty.DisplayName); - Assert.AreEqual("De coördinaten van de locatie van het kunstwerk in het Rijksdriehoeksstelsel.", structureLocationProperty.Description); - - PropertyDescriptor structureNormalOrientationProperty = dynamicProperties[constructionProperties.StructureNormalOrientationPropertyIndex]; - Assert.IsFalse(structureNormalOrientationProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, structureNormalOrientationProperty.Category); - Assert.AreEqual("Oriëntatie [°]", structureNormalOrientationProperty.DisplayName); - Assert.AreEqual("Oriëntatie van de normaal van het kunstwerk ten opzichte van het noorden.", structureNormalOrientationProperty.Description); - - PropertyDescriptor flowWidthAtBottomProtectionProperty = dynamicProperties[constructionProperties.FlowWidthAtBottomProtectionPropertyIndex]; - Assert.IsInstanceOf(flowWidthAtBottomProtectionProperty.Converter); - Assert.AreEqual(schematizationCategory, flowWidthAtBottomProtectionProperty.Category); - Assert.AreEqual("Stroomvoerende breedte bodembescherming [m]", flowWidthAtBottomProtectionProperty.DisplayName); - Assert.AreEqual("Stroomvoerende breedte bodembescherming.", flowWidthAtBottomProtectionProperty.Description); - - PropertyDescriptor widthFlowAperturesProperty = dynamicProperties[constructionProperties.WidthFlowAperturesPropertyIndex]; - Assert.IsInstanceOf(widthFlowAperturesProperty.Converter); - Assert.AreEqual(schematizationCategory, widthFlowAperturesProperty.Category); - Assert.AreEqual("Breedte van doorstroomopening [m]", widthFlowAperturesProperty.DisplayName); - Assert.AreEqual("Breedte van de doorstroomopening.", widthFlowAperturesProperty.Description); - - PropertyDescriptor storageStructureAreaProperty = dynamicProperties[constructionProperties.StorageStructureAreaPropertyIndex]; - Assert.IsInstanceOf(storageStructureAreaProperty.Converter); - Assert.AreEqual(schematizationCategory, storageStructureAreaProperty.Category); - Assert.AreEqual("Kombergend oppervlak [m²]", storageStructureAreaProperty.DisplayName); - Assert.AreEqual("Kombergend oppervlak.", storageStructureAreaProperty.Description); - - PropertyDescriptor allowedLevelIncreaseStorageProperty = dynamicProperties[constructionProperties.AllowedLevelIncreaseStoragePropertyIndex]; - Assert.IsInstanceOf(allowedLevelIncreaseStorageProperty.Converter); - Assert.AreEqual(schematizationCategory, allowedLevelIncreaseStorageProperty.Category); - Assert.AreEqual("Toegestane peilverhoging komberging [m]", allowedLevelIncreaseStorageProperty.DisplayName); - Assert.AreEqual("Toegestane peilverhoging komberging.", allowedLevelIncreaseStorageProperty.Description); - - PropertyDescriptor criticalOvertoppingDischargeProperty = dynamicProperties[constructionProperties.CriticalOvertoppingDischargePropertyIndex]; - Assert.IsInstanceOf(criticalOvertoppingDischargeProperty.Converter); - Assert.AreEqual(schematizationCategory, criticalOvertoppingDischargeProperty.Category); - Assert.AreEqual("Kritiek instromend debiet [m³/s/m]", criticalOvertoppingDischargeProperty.DisplayName); - Assert.AreEqual("Kritiek instromend debiet directe invoer per strekkende meter.", criticalOvertoppingDischargeProperty.Description); - - PropertyDescriptor failureProbabilityStructureWithErosionProperty = dynamicProperties[constructionProperties.FailureProbabilityStructureWithErosionPropertyIndex]; - Assert.IsFalse(failureProbabilityStructureWithErosionProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, failureProbabilityStructureWithErosionProperty.Category); - Assert.AreEqual("Faalkans gegeven erosie bodem [1/jaar]", failureProbabilityStructureWithErosionProperty.DisplayName); - Assert.AreEqual("Faalkans kunstwerk gegeven erosie bodem.", failureProbabilityStructureWithErosionProperty.Description); - - PropertyDescriptor modelFactorSuperCriticalFlowProperty = dynamicProperties[constructionProperties.ModelFactorSuperCriticalFlowPropertyIndex]; - Assert.IsInstanceOf(modelFactorSuperCriticalFlowProperty.Converter); - Assert.AreEqual(modelSettingsCategory, modelFactorSuperCriticalFlowProperty.Category); - Assert.AreEqual("Modelfactor overloopdebiet volkomen overlaat [-]", modelFactorSuperCriticalFlowProperty.DisplayName); - Assert.AreEqual("Modelfactor voor het overloopdebiet over een volkomen overlaat.", modelFactorSuperCriticalFlowProperty.Description); - - PropertyDescriptor foreshoreProfileProperty = dynamicProperties[constructionProperties.ForeshoreProfilePropertyIndex]; - Assert.IsFalse(foreshoreProfileProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, foreshoreProfileProperty.Category); - Assert.AreEqual("Voorlandprofiel", foreshoreProfileProperty.DisplayName); - Assert.AreEqual("De schematisatie van het voorlandprofiel.", foreshoreProfileProperty.Description); - - PropertyDescriptor useBreakWaterProperty = dynamicProperties[constructionProperties.UseBreakWaterPropertyIndex]; - Assert.IsInstanceOf(useBreakWaterProperty.Converter); - Assert.IsTrue(useBreakWaterProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, useBreakWaterProperty.Category); - Assert.AreEqual("Dam", useBreakWaterProperty.DisplayName); - Assert.AreEqual("Eigenschappen van de dam.", useBreakWaterProperty.Description); - - PropertyDescriptor useForeshoreProperty = dynamicProperties[constructionProperties.UseForeshorePropertyIndex]; - Assert.IsInstanceOf(useForeshoreProperty.Converter); - Assert.IsTrue(useForeshoreProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, useForeshoreProperty.Category); - Assert.AreEqual("Voorlandgeometrie", useForeshoreProperty.DisplayName); - Assert.AreEqual("Eigenschappen van de voorlandgeometrie.", useForeshoreProperty.Description); - - PropertyDescriptor hydraulicBoundaryLocationProperty = dynamicProperties[constructionProperties.HydraulicBoundaryLocationPropertyIndex]; - Assert.IsFalse(hydraulicBoundaryLocationProperty.IsReadOnly); - Assert.AreEqual(hydraulicDataCategory, hydraulicBoundaryLocationProperty.Category); - Assert.AreEqual("Locatie met hydraulische randvoorwaarden", hydraulicBoundaryLocationProperty.DisplayName); - Assert.AreEqual("De locatie met hydraulische randvoorwaarden.", hydraulicBoundaryLocationProperty.Description); - - PropertyDescriptor stormDurationProperty = dynamicProperties[constructionProperties.StormDurationPropertyIndex]; - Assert.IsInstanceOf(stormDurationProperty.Converter); - Assert.AreEqual(hydraulicDataCategory, stormDurationProperty.Category); - Assert.AreEqual("Stormduur [uur]", stormDurationProperty.DisplayName); - Assert.AreEqual("Stormduur.", stormDurationProperty.Description); - - mockRepository.VerifyAll(); - } - private StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties GetRandomConstructionProperties() { var structureObject = new object(); @@ -743,5 +773,51 @@ public SimpleInputContext(SimpleStructureInput wrappedData, StructuresCalculation calculation, IFailureMechanism failureMechanism, IAssessmentSection assessmentSection) : base(wrappedData, calculation, failureMechanism, assessmentSection) {} } + private void SetPropertyAndVerifyNotifcationsAndOutput( + bool hasOutput, + Action setProperty) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var failureMechanism = mocks.Stub(); + + var calculationObserver = mocks.StrictMock(); + int numberOfChangedProperties = hasOutput ? 1 : 0; + calculationObserver.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties); + + var inputObserver = mocks.StrictMock(); + inputObserver.Expect(o => o.UpdateObserver()); + + mocks.ReplayAll(); + + var calculation = new StructuresCalculation(); + + if (hasOutput) + { + calculation.Output = new TestStructuresOutput(); + } + calculation.Attach(calculationObserver); + + SimpleStructureInput inputParameters = calculation.InputParameters; + inputParameters.Attach(inputObserver); + + + var properties = new SimpleStructuresInputProperties(GetRandomConstructionProperties()) + { + Data = new SimpleInputContext(inputParameters, + calculation, + failureMechanism, + assessmentSection) + }; + + // Call + setProperty(properties); + + // Assert + Assert.IsFalse(calculation.HasOutput); + + mocks.VerifyAll(); + } } } \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs =================================================================== diff -u -rc0849c80b8bab9023c7df1e8402aa380891496d2 -rd69cf89498b4f926407d0261a747a4a7a8d37e62 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision c0849c80b8bab9023c7df1e8402aa380891496d2) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62) @@ -40,8 +40,7 @@ HeightStructure, HeightStructuresInput, StructuresCalculation, - HeightStructuresFailureMechanism>, - IPropertyChangeHandler + HeightStructuresFailureMechanism> { private const int structurePropertyIndex = 1; private const int structureLocationPropertyIndex = 2; @@ -113,11 +112,6 @@ return data.FailureMechanism.HeightStructures; } - public void PropertyChanged() - { - // TODO WTI-972 - } - protected override void AfterSettingStructure() { StructuresHelper.Update(data.FailureMechanism.SectionResults, data.Calculation); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/Ringtoets.HeightStructures.Plugin.Test.csproj =================================================================== diff -u -r586d097de0087256cb5cf3dda3a3c612721fee9c -rd69cf89498b4f926407d0261a747a4a7a8d37e62 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/Ringtoets.HeightStructures.Plugin.Test.csproj (.../Ringtoets.HeightStructures.Plugin.Test.csproj) (revision 586d097de0087256cb5cf3dda3a3c612721fee9c) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/Ringtoets.HeightStructures.Plugin.Test.csproj (.../Ringtoets.HeightStructures.Plugin.Test.csproj) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62) @@ -129,6 +129,10 @@ {d951d6da-fe83-4920-9fdb-63bf96480b54} Ringtoets.Common.Service + + {4843D6E5-066F-4795-94F5-1D53932DD03C} + Ringtoets.Common.Data.TestUtil + {74CBA865-9338-447F-BAD9-28312446AE84} Ringtoets.HydraRing.Calculation.TestUtil Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rf2f7d22ee59276f5df1f83fd409899bd895ea163 -rd69cf89498b4f926407d0261a747a4a7a8d37e62 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationContextTreeNodeInfoTest.cs) (revision f2f7d22ee59276f5df1f83fd409899bd895ea163) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationContextTreeNodeInfoTest.cs) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62) @@ -42,6 +42,7 @@ using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.Probability; using Ringtoets.Common.Data.Structures; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.HeightStructures.Data; using Ringtoets.HeightStructures.Data.TestUtil; using Ringtoets.HeightStructures.Forms.PresentationObjects; @@ -147,7 +148,7 @@ var failureMechanism = new HeightStructuresFailureMechanism(); var calculation = new StructuresCalculation { - Output = new TestHeightStructuresOutput() + Output = new TestStructuresOutput() }; var calculationContext = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); @@ -803,10 +804,5 @@ base.TearDown(); } - - private class TestHeightStructuresOutput : ProbabilityAssessmentOutput - { - public TestHeightStructuresOutput() : base(0, 0, 0, 0, 0) {} - } } } \ No newline at end of file Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs =================================================================== diff -u -rdbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a -rd69cf89498b4f926407d0261a747a4a7a8d37e62 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs (.../StabilityPointStructuresInputContextProperties.cs) (revision dbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs (.../StabilityPointStructuresInputContextProperties.cs) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62) @@ -45,8 +45,7 @@ StabilityPointStructure, StabilityPointStructuresInput, StructuresCalculation, - StabilityPointStructuresFailureMechanism>, - IPropertyChangeHandler + StabilityPointStructuresFailureMechanism> { private const int hydraulicBoundaryLocationPropertyIndex = 1; private const int volumicWeightWaterPropertyIndex = 2; @@ -171,11 +170,6 @@ return data.FailureMechanism.StabilityPointStructures; } - public void PropertyChanged() - { - // TODO WTI-974 - } - protected override void AfterSettingStructure() { StructuresHelper.Update(data.FailureMechanism.SectionResults, data.Calculation);