Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs =================================================================== diff -u -r449b5831547d5a6391da8ad825e7c845ef7ecc1c -r7d922899412d52bcc7c2f1432589dfcd62d364b4 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs (.../ClosingStructuresInputContextProperties.cs) (revision 449b5831547d5a6391da8ad825e7c845ef7ecc1c) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs (.../ClosingStructuresInputContextProperties.cs) (revision 7d922899412d52bcc7c2f1432589dfcd62d364b4) @@ -412,30 +412,14 @@ #endregion - public override bool IsReadOnly(string property) + protected override bool ShouldPropertyBeReadOnlyInAbsenseOfStructure(string property) { - if (property == nameof(InflowModelType)) - { - return !HasStructure(); - } - if (property == nameof(IdenticalApertures)) - { - return !HasStructure(); - } - if (property == nameof(ProbabilityOrFrequencyOpenStructureBeforeFlooding)) - { - return !HasStructure(); - } - if (property == nameof(FailureProbabilityOpenStructure)) - { - return !HasStructure(); - } - if (property == nameof(FailureProbabilityReparation)) - { - return !HasStructure(); - } - - return base.IsReadOnly(property); + return nameof(InflowModelType).Equals(property) + || nameof(IdenticalApertures).Equals(property) + || nameof(ProbabilityOrFrequencyOpenStructureBeforeFlooding).Equals(property) + || nameof(FailureProbabilityOpenStructure).Equals(property) + || nameof(FailureProbabilityReparation).Equals(property) + || base.ShouldPropertyBeReadOnlyInAbsenseOfStructure(property); } } } \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs =================================================================== diff -u -r5fae8cb70dd4efeb648c5ff5ee02c837a47172db -r7d922899412d52bcc7c2f1432589dfcd62d364b4 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs (.../ClosingStructuresInputContextPropertiesTest.cs) (revision 5fae8cb70dd4efeb648c5ff5ee02c837a47172db) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs (.../ClosingStructuresInputContextPropertiesTest.cs) (revision 7d922899412d52bcc7c2f1432589dfcd62d364b4) @@ -27,7 +27,6 @@ using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Base.Geometry; -using Core.Common.Gui.PropertyBag; using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; @@ -107,7 +106,6 @@ public void Constructor_WithDataAndHandler_ExpectedValues() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -122,7 +120,7 @@ var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call var properties = new ClosingStructuresInputContextProperties(inputContext, handler); @@ -158,7 +156,6 @@ public void Constructor_VerticalWallStructure_PropertiesHaveExpectedAttributesValues() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -173,7 +170,7 @@ var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call var properties = new ClosingStructuresInputContextProperties(inputContext, handler); @@ -251,7 +248,6 @@ public void Constructor_FloodedCulvertStructure_PropertiesHaveExpectedAttributesValues() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -266,7 +262,7 @@ var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call var properties = new ClosingStructuresInputContextProperties(inputContext, handler); @@ -354,7 +350,6 @@ public void Constructor_LowSillStructure_PropertiesHaveExpectedAttributesValues() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -369,7 +364,7 @@ var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call var properties = new ClosingStructuresInputContextProperties(inputContext, handler); @@ -388,13 +383,13 @@ Assert.AreEqual("Binnenwaterstand [m+NAP]", insideWaterLevelProperty.DisplayName); Assert.AreEqual("Binnenwaterstand.", insideWaterLevelProperty.Description); - PropertyDescriptor inflowModelTypeProperty = dynamicProperties[5]; + 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[7]; + PropertyDescriptor identicalAperturesProperty = dynamicProperties[lowSillidenticalAperturesPropertyIndex]; Assert.IsFalse(identicalAperturesProperty.IsReadOnly); Assert.AreEqual(schematizationCategory, identicalAperturesProperty.Category); Assert.AreEqual("Aantal identieke doorstroomopeningen [-]", identicalAperturesProperty.DisplayName); @@ -406,19 +401,19 @@ 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[13]; + 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[14]; + 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[15]; + PropertyDescriptor failureProbabilityReparationProperty = dynamicProperties[lowSillFailureProbabilityReparationPropertyIndex]; Assert.IsFalse(failureProbabilityReparationProperty.IsReadOnly); Assert.AreEqual(schematizationCategory, failureProbabilityReparationProperty.Category); Assert.AreEqual("Faalkans herstel van gefaalde situatie [1/jaar]", failureProbabilityReparationProperty.DisplayName); @@ -453,7 +448,6 @@ public void Constructor_WithoutStructure_CorrectReadOnlyForStructureDependentProperties() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -463,27 +457,27 @@ var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call var properties = new ClosingStructuresInputContextProperties(inputContext, handler); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - PropertyDescriptor inflowModelType = dynamicProperties[6]; + PropertyDescriptor inflowModelType = dynamicProperties[inflowModelTypePropertyIndex]; Assert.IsTrue(inflowModelType.IsReadOnly); - PropertyDescriptor identicalApertures = dynamicProperties[9]; + PropertyDescriptor identicalApertures = dynamicProperties[identicalAperturesPropertyIndex]; Assert.IsTrue(identicalApertures.IsReadOnly); - PropertyDescriptor probabilityOrFrequencyOpenStructureBeforeFlooding = dynamicProperties[16]; + PropertyDescriptor probabilityOrFrequencyOpenStructureBeforeFlooding = dynamicProperties[probabilityOrFrequencyOpenStructureBeforeFloodingPropertyIndex]; Assert.IsTrue(probabilityOrFrequencyOpenStructureBeforeFlooding.IsReadOnly); - PropertyDescriptor failureProbabilityOpenStructure = dynamicProperties[17]; + PropertyDescriptor failureProbabilityOpenStructure = dynamicProperties[failureProbabilityOpenStructurePropertyIndex]; Assert.IsTrue(failureProbabilityOpenStructure.IsReadOnly); - PropertyDescriptor failureProbabilityReparation = dynamicProperties[18]; + PropertyDescriptor failureProbabilityReparation = dynamicProperties[failureProbabilityReparationPropertyIndex]; Assert.IsTrue(failureProbabilityReparation.IsReadOnly); AssertPropertiesInState(properties.ThresholdHeightOpenWeir, true); @@ -496,7 +490,6 @@ public void GetAvailableForeshoreProfiles_SetInputContextInstanceWithForeshoreProfiles_ReturnForeshoreProfiles() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -511,7 +504,7 @@ var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); // Call @@ -526,7 +519,6 @@ public void GetAvailableStructures_SetInputContextInstanceWithStructures_ReturnStructures() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -541,7 +533,7 @@ var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); // Call @@ -662,7 +654,6 @@ public void ProbabilityOrFrequencyOpenStructureBeforeFlooding_InvalidDoubleValues_ThrowsArgumentException(double newValue) { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); @@ -671,7 +662,7 @@ var inputContext = new ClosingStructuresInputContext(input, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); const int overflow = 1; string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow); @@ -696,7 +687,6 @@ public void ProbabilityOrFrequencyOpenStructureBeforeFlooding_InvalidValues_ThrowsArgumentOutOfRangeException(double newValue) { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); @@ -705,7 +695,7 @@ var inputContext = new ClosingStructuresInputContext(input, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); string newProbabilityString = newValue.ToString("r", CultureInfo.CurrentCulture); var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); @@ -727,7 +717,6 @@ public void ProbabilityOrFrequencyOpenStructureBeforeFlooding_ValuesUnableToParse_ThrowsArgumentException(string newValue) { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); @@ -736,7 +725,7 @@ var inputContext = new ClosingStructuresInputContext(input, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); @@ -755,7 +744,6 @@ public void ProbabilityOrFrequencyOpenStructureBeforeFlooding_NullValue_ThrowsArgumentNullException() { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); @@ -764,7 +752,7 @@ var inputContext = new ClosingStructuresInputContext(input, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); @@ -785,7 +773,6 @@ public void FailureProbabilityOpenStructure_InvalidValues_ThrowsArgumentException(double newValue) { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); @@ -794,7 +781,7 @@ var inputContext = new ClosingStructuresInputContext(input, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); const int overflow = 1; string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow); @@ -818,7 +805,6 @@ public void FailureProbabilityOpenStructure_ValuesUnableToParse_ThrowsArgumentException(string newValue) { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); @@ -827,7 +813,7 @@ var inputContext = new ClosingStructuresInputContext(input, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); @@ -846,7 +832,6 @@ public void FailureProbabilityOpenStructure_NullValue_ThrowsArgumentNullException() { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); @@ -855,7 +840,7 @@ var inputContext = new ClosingStructuresInputContext(input, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); @@ -876,7 +861,6 @@ public void FailureProbabilityReparation_InvalidValues_ThrowsArgumentException(double newValue) { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); @@ -885,7 +869,7 @@ var inputContext = new ClosingStructuresInputContext(input, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); const int overflow = 1; string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow); @@ -909,7 +893,6 @@ public void FailureProbabilityReparation_ValuesUnableToParse_ThrowsArgumentException(string newValue) { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); @@ -918,7 +901,7 @@ var inputContext = new ClosingStructuresInputContext(input, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); @@ -937,7 +920,6 @@ public void FailureProbabilityReparation_NullValue_ThrowsArgumentNullException() { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); @@ -946,7 +928,7 @@ var inputContext = new ClosingStructuresInputContext(input, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); @@ -965,15 +947,14 @@ public void Structure_StructureInSection_UpdateSectionResults() { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); var calculation = new StructuresCalculation(); var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var newStructure = new TestClosingStructure(); var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); @@ -998,7 +979,6 @@ public void DynamicVisibleValidationMethod_StructureIsVerticalWall_ReturnExpectedVisibility() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -1013,7 +993,7 @@ var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); // Call & Assert @@ -1033,7 +1013,6 @@ public void DynamicVisibleValidationMethod_StructureIsLowSill_ReturnExpectedVisibility() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -1048,7 +1027,7 @@ var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); // Call & Assert @@ -1068,7 +1047,6 @@ public void DynamicVisibleValidationMethod_StructureIsFloodedCulvert_ReturnExpectedVisibility() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -1083,7 +1061,7 @@ var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); // Call & Assert @@ -1103,15 +1081,14 @@ public void DynamicVisibleValidationMethod_StructureTypeUnknown_ReturnExpectedVisibility() { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); var calculation = new StructuresCalculation(); var inputContext = new ClosingStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var handler = mockRepository.Stub(); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); @@ -1206,12 +1183,17 @@ private const int lowSillInsideWaterLevelPropertyIndex = 2; private const int lowSillStructurePropertyIndex = 3; private const int lowSillStructureLocationPropertyIndex = 4; + private const int lowSillInflowModelTypePropertyIndex = 5; private const int lowSillWidthFlowAperturesPropertyIndex = 6; + private const int lowSillidenticalAperturesPropertyIndex = 7; private const int lowSillFlowWidthAtBottomProtectionPropertyIndex = 8; private const int lowSillStorageStructureAreaPropertyIndex = 9; private const int lowSillAllowedLevelIncreaseStoragePropertyIndex = 10; private const int lowSillThresholdHeightOpenWeirPropertyIndex = 11; private const int lowSillCriticalOvertoppingDischargePropertyIndex = 12; + private const int lowSillProbabilityOrFrequencyOpenStructureBeforeFloodingPropertyIndex = 13; + private const int lowSillFailureProbabilityOpenStructurePropertyIndex = 14; + private const int lowSillFailureProbabilityReparationPropertyIndex = 15; private const int lowSillFailureProbabilityStructureWithErosionPropertyIndex = 16; private const int lowSillForeshoreProfilePropertyIndex = 17; private const int lowSillUseBreakWaterPropertyIndex = 18; @@ -1247,6 +1229,16 @@ #endregion + #region No structure property indices + + private const int inflowModelTypePropertyIndex = 6; + private const int identicalAperturesPropertyIndex = 9; + private const int probabilityOrFrequencyOpenStructureBeforeFloodingPropertyIndex = 16; + private const int failureProbabilityOpenStructurePropertyIndex = 17; + private const int failureProbabilityReparationPropertyIndex = 18; + #endregion + + #endregion } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs =================================================================== diff -u -r5fae8cb70dd4efeb648c5ff5ee02c837a47172db -r7d922899412d52bcc7c2f1432589dfcd62d364b4 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision 5fae8cb70dd4efeb648c5ff5ee02c837a47172db) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision 7d922899412d52bcc7c2f1432589dfcd62d364b4) @@ -569,14 +569,24 @@ } [DynamicReadOnlyValidationMethod] - public virtual bool IsReadOnly(string property) + public bool IsReadOnly(string property) { - if (property == nameof(StructureNormalOrientation)) + if (!HasStructure() && ShouldPropertyBeReadOnlyInAbsenseOfStructure(property)) { - return !HasStructure(); + return true; } return false; } + + protected virtual bool ShouldPropertyBeReadOnlyInAbsenseOfStructure(string property) + { + if (nameof(StructureNormalOrientation).Equals(property)) + { + return true; + } + + return false; + } } } \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs =================================================================== diff -u -r5fae8cb70dd4efeb648c5ff5ee02c837a47172db -r7d922899412d52bcc7c2f1432589dfcd62d364b4 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision 5fae8cb70dd4efeb648c5ff5ee02c837a47172db) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision 7d922899412d52bcc7c2f1432589dfcd62d364b4) @@ -109,13 +109,10 @@ #endregion - public override bool IsReadOnly(string property) + protected override bool ShouldPropertyBeReadOnlyInAbsenseOfStructure(string property) { - if (property == nameof(FailureProbabilityStructureWithErosion)) - { - return !HasStructure(); - } - return base.IsReadOnly(property); + return nameof(FailureProbabilityStructureWithErosion).Equals(property) + || base.ShouldPropertyBeReadOnlyInAbsenseOfStructure(property); } public override IEnumerable GetAvailableForeshoreProfiles() Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs =================================================================== diff -u -r3163642d26872e5a54e31f9d7640192bc7191363 -r7d922899412d52bcc7c2f1432589dfcd62d364b4 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 3163642d26872e5a54e31f9d7640192bc7191363) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 7d922899412d52bcc7c2f1432589dfcd62d364b4) @@ -26,7 +26,6 @@ using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Base.Geometry; -using Core.Common.Gui.PropertyBag; using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; @@ -64,11 +63,13 @@ private const int stormDurationPropertyIndex = 15; private MockRepository mockRepository; + private IAssessmentSection assessmentSection; [SetUp] public void SetUp() { mockRepository = new MockRepository(); + assessmentSection = mockRepository.StrictMock(); } [Test] @@ -90,7 +91,6 @@ public void Constructor_WithoutHandler_ExpectedValues() { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); @@ -99,7 +99,7 @@ var inputContext = new HeightStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call TestDelegate test = () => new HeightStructuresInputContextProperties(inputContext, null); @@ -113,7 +113,6 @@ public void Constructor_WithDataAndHandler_ExpectedValues() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -123,7 +122,7 @@ var inputContext = new HeightStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call var properties = new HeightStructuresInputContextProperties(inputContext, handler); @@ -142,7 +141,6 @@ public void Constructor_WithData_PropertiesHaveExpectedAttributesValues() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -151,7 +149,7 @@ var inputContext = new HeightStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call var properties = new HeightStructuresInputContextProperties(inputContext, handler); @@ -194,7 +192,6 @@ public void Constructor_WithOrWithoutStructure_CorrectReadOnlyForStructureDependentProperties(bool hasStructure) { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -203,7 +200,7 @@ var inputContext = new HeightStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); if (hasStructure) { calculation.InputParameters.Structure = new TestHeightStructure(); @@ -237,7 +234,6 @@ public void GetAvailableForeshoreProfiles_SetInputContextInstanceWithForeshoreProfiles_ReturnForeshoreProfiles() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -252,7 +248,7 @@ var inputContext = new HeightStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var properties = new HeightStructuresInputContextProperties(inputContext, handler); // Call @@ -267,7 +263,6 @@ public void GetAvailableStructures_SetInputContextInstanceWithStructures_ReturnStructures() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -282,7 +277,7 @@ var inputContext = new HeightStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var properties = new HeightStructuresInputContextProperties(inputContext, handler); // Call @@ -297,15 +292,14 @@ public void SetStructure_StructureInSection_UpdateSectionResults() { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); var calculation = new StructuresCalculation(); var inputContext = new HeightStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var newStructure = new TestHeightStructure(); var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); @@ -338,7 +332,6 @@ { // Setup var observable = mockRepository.StrictMock(); - var assessmentSection = mockRepository.StrictMock(); observable.Expect(o => o.NotifyObservers()); mockRepository.ReplayAll(); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs =================================================================== diff -u -r5762f5a734abc237f01cd62257cedd7ba2e9c8e8 -r7d922899412d52bcc7c2f1432589dfcd62d364b4 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision 5762f5a734abc237f01cd62257cedd7ba2e9c8e8) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision 7d922899412d52bcc7c2f1432589dfcd62d364b4) @@ -182,122 +182,136 @@ var schematizationCategory = "Schematisatie"; PropertyDescriptor hydraulicBoundaryLocationProperty = dynamicProperties[expectedSelectedHydraulicBoundaryLocationPropertyIndex]; - Assert.IsNotNull(hydraulicBoundaryLocationProperty); - Assert.IsFalse(hydraulicBoundaryLocationProperty.IsReadOnly); - Assert.AreEqual(hydraulicDataCategory, hydraulicBoundaryLocationProperty.Category); - Assert.AreEqual("Locatie met hydraulische randvoorwaarden", hydraulicBoundaryLocationProperty.DisplayName); - Assert.AreEqual("De locatie met hydraulische randvoorwaarden waarvan het berekende toetspeil wordt gebruikt.", hydraulicBoundaryLocationProperty.Description); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + hydraulicBoundaryLocationProperty, + hydraulicDataCategory, + "Locatie met hydraulische randvoorwaarden", + "De locatie met hydraulische randvoorwaarden waarvan het berekende toetspeil wordt gebruikt."); PropertyDescriptor assessmentLevelProperty = dynamicProperties[expectedAssessmentLevelPropertyIndex]; - Assert.IsNotNull(assessmentLevelProperty); - Assert.IsTrue(assessmentLevelProperty.IsReadOnly); - Assert.AreEqual(hydraulicDataCategory, assessmentLevelProperty.Category); - Assert.AreEqual("Toetspeil [m+NAP]", assessmentLevelProperty.DisplayName); - Assert.AreEqual("Waterstand met een overschrijdingsfrequentie gelijk aan de trajectnorm.", assessmentLevelProperty.Description); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + assessmentLevelProperty, + hydraulicDataCategory, + "Toetspeil [m+NAP]", + "Waterstand met een overschrijdingsfrequentie gelijk aan de trajectnorm.", + true); PropertyDescriptor useHydraulicBoundaryLocationProperty = dynamicProperties[expectedUseHydraulicBoundaryLocationPropertyIndex]; - Assert.IsNotNull(useHydraulicBoundaryLocationProperty); - Assert.AreEqual(hydraulicDataCategory, useHydraulicBoundaryLocationProperty.Category); - Assert.AreEqual("Handmatig toetspeil invoeren", useHydraulicBoundaryLocationProperty.DisplayName); - Assert.AreEqual("Sta toe om het toetspeil handmatig te specificeren?", useHydraulicBoundaryLocationProperty.Description); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + useHydraulicBoundaryLocationProperty, + hydraulicDataCategory, + "Handmatig toetspeil invoeren", + "Sta toe om het toetspeil handmatig te specificeren?"); PropertyDescriptor dampingsFactorExitProperty = dynamicProperties[expectedDampingFactorExitPropertyIndex]; - Assert.IsNotNull(dampingsFactorExitProperty); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + dampingsFactorExitProperty, + hydraulicDataCategory, + "Dempingsfactor bij uittredepunt [-]", + "Dempingsfactor relateert respons van stijghoogte bij binnenteen aan buitenwaterstand.", + true); Assert.IsInstanceOf(dampingsFactorExitProperty.Converter); - Assert.AreEqual(hydraulicDataCategory, dampingsFactorExitProperty.Category); - Assert.AreEqual("Dempingsfactor bij uittredepunt [-]", dampingsFactorExitProperty.DisplayName); - Assert.AreEqual("Dempingsfactor relateert respons van stijghoogte bij binnenteen aan buitenwaterstand.", dampingsFactorExitProperty.Description); PropertyDescriptor phreaticLevelExitProperty = dynamicProperties[expectedPhreaticLevelExitPropertyIndex]; - Assert.IsNotNull(phreaticLevelExitProperty); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + phreaticLevelExitProperty, + hydraulicDataCategory, + "Polderpeil [m+NAP]", + "Polderpeil.", + true); Assert.IsInstanceOf(phreaticLevelExitProperty.Converter); - Assert.AreEqual(hydraulicDataCategory, phreaticLevelExitProperty.Category); - Assert.AreEqual("Polderpeil [m+NAP]", phreaticLevelExitProperty.DisplayName); - Assert.AreEqual("Polderpeil.", phreaticLevelExitProperty.Description); PropertyDescriptor piezometricHeadExitProperty = dynamicProperties[expectedPiezometricHeadExitPropertyIndex]; - Assert.IsNotNull(piezometricHeadExitProperty); - Assert.IsTrue(piezometricHeadExitProperty.IsReadOnly); - Assert.AreEqual(hydraulicDataCategory, piezometricHeadExitProperty.Category); - Assert.AreEqual("Stijghoogte bij uittredepunt [m+NAP]", piezometricHeadExitProperty.DisplayName); - Assert.AreEqual("Stijghoogte bij uittredepunt.", piezometricHeadExitProperty.Description); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + piezometricHeadExitProperty, + hydraulicDataCategory, + "Stijghoogte bij uittredepunt [m+NAP]", + "Stijghoogte bij uittredepunt.", + true); PropertyDescriptor surfaceLineProperty = dynamicProperties[expectedSurfaceLinePropertyIndex]; - Assert.IsNotNull(surfaceLineProperty); - Assert.IsFalse(surfaceLineProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, surfaceLineProperty.Category); - Assert.AreEqual("Profielschematisatie", surfaceLineProperty.DisplayName); - Assert.AreEqual("De schematisatie van de hoogte van het dwarsprofiel.", surfaceLineProperty.Description); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + surfaceLineProperty, + schematizationCategory, + "Profielschematisatie", + "De schematisatie van de hoogte van het dwarsprofiel."); PropertyDescriptor stochasticSoilModelProperty = dynamicProperties[expectedStochasticSoilModelPropertyIndex]; - Assert.IsNotNull(stochasticSoilModelProperty); - Assert.IsFalse(stochasticSoilModelProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, stochasticSoilModelProperty.Category); - Assert.AreEqual("Stochastisch ondergrondmodel", stochasticSoilModelProperty.DisplayName); - Assert.AreEqual("De verschillende opbouwen van de ondergrond en hun respectieve kansen van voorkomen.", stochasticSoilModelProperty.Description); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + stochasticSoilModelProperty, + schematizationCategory, + "Stochastisch ondergrondmodel", + "De verschillende opbouwen van de ondergrond en hun respectieve kansen van voorkomen."); PropertyDescriptor stochasticSoilProfileProperty = dynamicProperties[expectedStochasticSoilProfilePropertyIndex]; - Assert.IsNotNull(stochasticSoilProfileProperty); - Assert.IsFalse(stochasticSoilProfileProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, stochasticSoilProfileProperty.Category); - Assert.AreEqual("Ondergrondschematisatie", stochasticSoilProfileProperty.DisplayName); - Assert.AreEqual("De opbouw van de ondergrond.", stochasticSoilProfileProperty.Description); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + stochasticSoilProfileProperty, + schematizationCategory, + "Ondergrondschematisatie", + "De opbouw van de ondergrond."); PropertyDescriptor seepageLengthProperty = dynamicProperties[expectedSeepageLengthPropertyIndex]; - Assert.IsNotNull(seepageLengthProperty); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + seepageLengthProperty, + schematizationCategory, + "Kwelweglengte [m]", + "De horizontale afstand tussen intrede- en uittredepunt die het kwelwater ondergronds aflegt voordat het weer aan de oppervlakte komt.", + true); Assert.IsInstanceOf(seepageLengthProperty.Converter); - Assert.IsTrue(seepageLengthProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, seepageLengthProperty.Category); - Assert.AreEqual("Kwelweglengte [m]", seepageLengthProperty.DisplayName); - Assert.AreEqual("De horizontale afstand tussen intrede- en uittredepunt die het kwelwater ondergronds aflegt voordat het weer aan de oppervlakte komt.", seepageLengthProperty.Description); PropertyDescriptor thicknessCoverageLayerProperty = dynamicProperties[expectedThicknessCoverageLayerPropertyIndex]; - Assert.IsNotNull(thicknessCoverageLayerProperty); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + thicknessCoverageLayerProperty, + schematizationCategory, + "Totale deklaagdikte bij uittredepunt [m]", + "Totale deklaagdikte bij uittredepunt.", + true); Assert.IsInstanceOf(thicknessCoverageLayerProperty.Converter); - Assert.IsTrue(thicknessCoverageLayerProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, thicknessCoverageLayerProperty.Category); - Assert.AreEqual("Totale deklaagdikte bij uittredepunt [m]", thicknessCoverageLayerProperty.DisplayName); - Assert.AreEqual("Totale deklaagdikte bij uittredepunt.", thicknessCoverageLayerProperty.Description); PropertyDescriptor effectiveThicknessCoverageLayerProperty = dynamicProperties[expectedEffectiveThicknessCoverageLayerPropertyIndex]; - Assert.IsNotNull(effectiveThicknessCoverageLayerProperty); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + effectiveThicknessCoverageLayerProperty, + schematizationCategory, + "Effectieve deklaagdikte bij uittredepunt [m]", + "Effectieve deklaagdikte bij uittredepunt.", + true); Assert.IsInstanceOf(effectiveThicknessCoverageLayerProperty.Converter); - Assert.IsTrue(effectiveThicknessCoverageLayerProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, effectiveThicknessCoverageLayerProperty.Category); - Assert.AreEqual("Effectieve deklaagdikte bij uittredepunt [m]", effectiveThicknessCoverageLayerProperty.DisplayName); - Assert.AreEqual("Effectieve deklaagdikte bij uittredepunt.", effectiveThicknessCoverageLayerProperty.Description); PropertyDescriptor thicknessAquiferLayerProperty = dynamicProperties[expectedThicknessAquiferLayerPropertyIndex]; - Assert.IsNotNull(thicknessAquiferLayerProperty); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + thicknessAquiferLayerProperty, + schematizationCategory, + "Dikte watervoerend pakket [m]", + "De dikte van de bovenste voor doorlatendheid te onderscheiden zandlaag of combinatie van zandlagen.", + true); Assert.IsInstanceOf(thicknessAquiferLayerProperty.Converter); - Assert.IsTrue(thicknessAquiferLayerProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, thicknessAquiferLayerProperty.Category); - Assert.AreEqual("Dikte watervoerend pakket [m]", thicknessAquiferLayerProperty.DisplayName); - Assert.AreEqual("De dikte van de bovenste voor doorlatendheid te onderscheiden zandlaag of combinatie van zandlagen.", thicknessAquiferLayerProperty.Description); PropertyDescriptor darcyPermeabilityProperty = dynamicProperties[expectedDarcyPermeabilityPropertyIndex]; - Assert.IsNotNull(darcyPermeabilityProperty); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + darcyPermeabilityProperty, + schematizationCategory, + "Doorlatendheid aquifer [m/s]", + "Darcy-snelheid waarmee water door de eerste voor doorlatendheid te onderscheiden zandlaag loopt.", + true); Assert.IsInstanceOf(darcyPermeabilityProperty.Converter); - Assert.IsTrue(darcyPermeabilityProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, darcyPermeabilityProperty.Category); - Assert.AreEqual("Doorlatendheid aquifer [m/s]", darcyPermeabilityProperty.DisplayName); - Assert.AreEqual("Darcy-snelheid waarmee water door de eerste voor doorlatendheid te onderscheiden zandlaag loopt.", darcyPermeabilityProperty.Description); PropertyDescriptor diameter70Property = dynamicProperties[expectedDiameter70PropertyIndex]; - Assert.IsNotNull(diameter70Property); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + diameter70Property, + schematizationCategory, + "De d70 in de bovenste zandlaag [m]", + "Zeefmaat waar 70 gewichtsprocent van de korrels uit een zandlaag doorheen gaat. Hier de korreldiameter van het bovenste gedeelte van de voor doorlatendheid te onderscheiden zandlaag, bepaald zonder fijne fractie (< 63µm).", + true); Assert.IsInstanceOf(diameter70Property.Converter); - Assert.IsTrue(diameter70Property.IsReadOnly); - Assert.AreEqual(schematizationCategory, diameter70Property.Category); - Assert.AreEqual("De d70 in de bovenste zandlaag [m]", diameter70Property.DisplayName); - Assert.AreEqual("Zeefmaat waar 70 gewichtsprocent van de korrels uit een zandlaag doorheen gaat. Hier de korreldiameter van het bovenste gedeelte van de voor doorlatendheid te onderscheiden zandlaag, bepaald zonder fijne fractie (< 63µm).", diameter70Property.Description); PropertyDescriptor saturatedVolumicWeightOfCoverageLayerProperty = dynamicProperties[expectedSaturatedVolumicWeightOfCoverageLayerPropertyIndex]; - Assert.IsNotNull(saturatedVolumicWeightOfCoverageLayerProperty); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + saturatedVolumicWeightOfCoverageLayerProperty, + schematizationCategory, + "Verzadigd gewicht deklaag [kN/m³]", + "Verzadigd gewicht deklaag.", + true); Assert.IsInstanceOf(saturatedVolumicWeightOfCoverageLayerProperty.Converter); - Assert.IsTrue(saturatedVolumicWeightOfCoverageLayerProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, saturatedVolumicWeightOfCoverageLayerProperty.Category); - Assert.AreEqual("Verzadigd gewicht deklaag [kN/m³]", saturatedVolumicWeightOfCoverageLayerProperty.DisplayName); - Assert.AreEqual("Verzadigd gewicht deklaag.", saturatedVolumicWeightOfCoverageLayerProperty.Description); mocks.VerifyAll(); } @@ -343,21 +357,23 @@ // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - var schematizationCategory = "Schematisatie"; + const string schematizationCategory = "Schematisatie"; PropertyDescriptor entryPointLProperty = dynamicProperties[expectedEntryPointLPropertyIndex]; - Assert.IsNotNull(entryPointLProperty); - Assert.AreEqual(!withSurfaceLine, entryPointLProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, entryPointLProperty.Category); - Assert.AreEqual("Intredepunt", entryPointLProperty.DisplayName); - Assert.AreEqual("De positie in het dwarsprofiel van het intredepunt.", entryPointLProperty.Description); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + entryPointLProperty, + schematizationCategory, + "Intredepunt", + "De positie in het dwarsprofiel van het intredepunt.", + !withSurfaceLine); PropertyDescriptor exitPointLProperty = dynamicProperties[expectedExitPointLPropertyIndex]; - Assert.IsNotNull(exitPointLProperty); - Assert.AreEqual(!withSurfaceLine, exitPointLProperty.IsReadOnly); - Assert.AreEqual(schematizationCategory, exitPointLProperty.Category); - Assert.AreEqual("Uittredepunt", exitPointLProperty.DisplayName); - Assert.AreEqual("De positie in het dwarsprofiel van het uittredepunt.", exitPointLProperty.Description); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + exitPointLProperty, + schematizationCategory, + "Uittredepunt", + "De positie in het dwarsprofiel van het uittredepunt.", + !withSurfaceLine); mocks.VerifyAll(); } @@ -401,29 +417,30 @@ Assert.AreEqual(18, dynamicProperties.Count); PropertyDescriptor hydraulicBoundaryLocationProperty = dynamicProperties[expectedSelectedHydraulicBoundaryLocationPropertyIndex]; - Assert.IsNotNull(hydraulicBoundaryLocationProperty); - Assert.IsFalse(hydraulicBoundaryLocationProperty.IsReadOnly); - Assert.AreEqual(hydraulicDataCategory, hydraulicBoundaryLocationProperty.Category); - Assert.AreEqual("Locatie met hydraulische randvoorwaarden", hydraulicBoundaryLocationProperty.DisplayName); - Assert.AreEqual("De locatie met hydraulische randvoorwaarden waarvan het berekende toetspeil wordt gebruikt.", hydraulicBoundaryLocationProperty.Description); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + hydraulicBoundaryLocationProperty, + hydraulicDataCategory, + "Locatie met hydraulische randvoorwaarden", + "De locatie met hydraulische randvoorwaarden waarvan het berekende toetspeil wordt gebruikt."); PropertyDescriptor assessmentLevelProperty = dynamicProperties[expectedAssessmentLevelPropertyIndex]; - Assert.IsNotNull(assessmentLevelProperty); - Assert.IsTrue(assessmentLevelProperty.IsReadOnly); - Assert.AreEqual(hydraulicDataCategory, assessmentLevelProperty.Category); - Assert.AreEqual("Toetspeil [m+NAP]", assessmentLevelProperty.DisplayName); - Assert.AreEqual("Waterstand met een overschrijdingsfrequentie gelijk aan de trajectnorm.", assessmentLevelProperty.Description); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + assessmentLevelProperty, + hydraulicDataCategory, + "Toetspeil [m+NAP]", + "Waterstand met een overschrijdingsfrequentie gelijk aan de trajectnorm.", + true); } else { Assert.AreEqual(17, dynamicProperties.Count); PropertyDescriptor assessmentLevelProperty = dynamicProperties[0]; - Assert.IsNotNull(assessmentLevelProperty); - Assert.IsFalse(assessmentLevelProperty.IsReadOnly); - Assert.AreEqual(hydraulicDataCategory, assessmentLevelProperty.Category); - Assert.AreEqual("Toetspeil [m+NAP]", assessmentLevelProperty.DisplayName); - Assert.AreEqual("Waterstand met een overschrijdingsfrequentie gelijk aan de trajectnorm.", assessmentLevelProperty.Description); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + assessmentLevelProperty, + hydraulicDataCategory, + "Toetspeil [m+NAP]", + "Waterstand met een overschrijdingsfrequentie gelijk aan de trajectnorm."); } } Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs =================================================================== diff -u -r5fae8cb70dd4efeb648c5ff5ee02c837a47172db -r7d922899412d52bcc7c2f1432589dfcd62d364b4 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs (.../StabilityPointStructuresInputContextProperties.cs) (revision 5fae8cb70dd4efeb648c5ff5ee02c837a47172db) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs (.../StabilityPointStructuresInputContextProperties.cs) (revision 7d922899412d52bcc7c2f1432589dfcd62d364b4) @@ -647,37 +647,16 @@ #endregion - public override bool IsReadOnly(string property) + protected override bool ShouldPropertyBeReadOnlyInAbsenseOfStructure(string property) { - if (property == nameof(InflowModelType)) - { - return !HasStructure(); - } - if (property == nameof(LoadSchematizationType)) - { - return !HasStructure(); - } - if (property == nameof(LevellingCount)) - { - return !HasStructure(); - } - if (property == nameof(EvaluationLevel)) - { - return !HasStructure(); - } - if (property == nameof(VerticalDistance)) - { - return !HasStructure(); - } - if (property == nameof(FailureProbabilityRepairClosure)) - { - return !HasStructure(); - } - if (property == nameof(ProbabilityCollisionSecondaryStructure)) - { - return !HasStructure(); - } - return base.IsReadOnly(property); + return nameof(InflowModelType).Equals(property) + || nameof(LoadSchematizationType).Equals(property) + || nameof(LevellingCount).Equals(property) + || nameof(EvaluationLevel).Equals(property) + || nameof(VerticalDistance).Equals(property) + || nameof(FailureProbabilityRepairClosure).Equals(property) + || nameof(ProbabilityCollisionSecondaryStructure).Equals(property) + || base.ShouldPropertyBeReadOnlyInAbsenseOfStructure(property); } } } \ No newline at end of file Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs =================================================================== diff -u -r3163642d26872e5a54e31f9d7640192bc7191363 -r7d922899412d52bcc7c2f1432589dfcd62d364b4 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs (.../StabilityPointStructuresInputContextPropertiesTest.cs) (revision 3163642d26872e5a54e31f9d7640192bc7191363) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs (.../StabilityPointStructuresInputContextPropertiesTest.cs) (revision 7d922899412d52bcc7c2f1432589dfcd62d364b4) @@ -27,7 +27,6 @@ using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Base.Geometry; -using Core.Common.Gui.PropertyBag; using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; @@ -107,7 +106,6 @@ public void Constructor_WithData_ExpectedValues() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -117,7 +115,7 @@ var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); @@ -164,7 +162,6 @@ public void Constructor_LinearLowSillStructure_PropertiesHaveExpectedAttributesValues() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -181,7 +178,7 @@ var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); @@ -338,7 +335,6 @@ public void Constructor_QuadraticLowSillStructure_PropertiesHaveExpectedAttributesValues() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -355,7 +351,7 @@ var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); @@ -512,7 +508,6 @@ public void Constructor_LinearFloodedCulvertStructure_PropertiesHaveExpectedAttributesValues() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -529,7 +524,7 @@ var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); @@ -696,7 +691,6 @@ public void Constructor_QuadraticFloodedCulvertStructure_PropertiesHaveExpectedAttributesValues() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -713,7 +707,7 @@ var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); @@ -880,7 +874,6 @@ public void Constructor_WithoutStructure_CorrectReadOnlyForStructureDependentProperties() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -890,37 +883,37 @@ var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - - PropertyDescriptor structureNormalOrientation = dynamicProperties[10]; + var structureNormalOrientationPropertyIndex = 10; + PropertyDescriptor structureNormalOrientation = dynamicProperties[structureNormalOrientationPropertyIndex]; Assert.IsTrue(structureNormalOrientation.IsReadOnly); - - PropertyDescriptor inflowModelType = dynamicProperties[11]; + + PropertyDescriptor inflowModelType = dynamicProperties[inflowModelTypePropertyIndex]; Assert.IsTrue(inflowModelType.IsReadOnly); - PropertyDescriptor loadSchematizationType = dynamicProperties[12]; + PropertyDescriptor loadSchematizationType = dynamicProperties[loadSchematizationTypePropertyIndex]; Assert.IsTrue(loadSchematizationType.IsReadOnly); - PropertyDescriptor levellingCount = dynamicProperties[18]; + PropertyDescriptor levellingCount = dynamicProperties[levellingCountPropertyIndex]; Assert.IsTrue(levellingCount.IsReadOnly); - PropertyDescriptor evaluationLevel = dynamicProperties[25]; + PropertyDescriptor evaluationLevel = dynamicProperties[evaluationLevelPropertyIndex]; Assert.IsTrue(evaluationLevel.IsReadOnly); - PropertyDescriptor verticalDistance = dynamicProperties[26]; + PropertyDescriptor verticalDistance = dynamicProperties[verticalDistancePropertyIndex]; Assert.IsTrue(verticalDistance.IsReadOnly); - PropertyDescriptor failureProbabilityRepairClosure = dynamicProperties[27]; + PropertyDescriptor failureProbabilityRepairClosure = dynamicProperties[failureProbabilityRepairClosurePropertyIndex]; Assert.IsTrue(failureProbabilityRepairClosure.IsReadOnly); - PropertyDescriptor probabilityCollisionSecondaryStructure = dynamicProperties[31]; + PropertyDescriptor probabilityCollisionSecondaryStructure = dynamicProperties[probabilityCollisionSecondaryStructurePropertyIndex]; Assert.IsTrue(probabilityCollisionSecondaryStructure.IsReadOnly); AssertPropertiesInState(properties.LevelCrestStructure, true); @@ -943,7 +936,6 @@ public void GetAvailableForeshoreProfiles_SetInputContextInstanceWithForeshoreProfiles_ReturnForeshoreProfiles() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -958,7 +950,7 @@ var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); // Call @@ -973,7 +965,6 @@ public void GetAvailableStructures_SetInputContextInstanceWithStructures_ReturnStructures() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -988,7 +979,7 @@ var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); // Call @@ -1213,7 +1204,6 @@ public void SetFailureProbabilityRepairClosure_InvalidValues_ThrowsArgumentException(double newValue) { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); @@ -1222,7 +1212,7 @@ var inputContext = new StabilityPointStructuresInputContext(input, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); const int overflow = 1; string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow); @@ -1246,7 +1236,6 @@ public void SetFailureProbabilityRepairClosure_ValuesUnableToParse_ThrowsArgumentException(string newValue) { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); @@ -1255,7 +1244,7 @@ var inputContext = new StabilityPointStructuresInputContext(input, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); @@ -1274,7 +1263,6 @@ public void SetFailureProbabilityRepairClosure_NullValue_ThrowsArgumentNullException() { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); @@ -1283,7 +1271,7 @@ var inputContext = new StabilityPointStructuresInputContext(input, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); @@ -1304,7 +1292,6 @@ public void SetProbabilityCollisionSecondaryStructure_InvalidValues_ThrowsArgumentException(double newValue) { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); @@ -1313,7 +1300,7 @@ var inputContext = new StabilityPointStructuresInputContext(input, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); const int overflow = 1; string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow); @@ -1337,7 +1324,6 @@ public void SetProbabilityCollisionSecondaryStructure_ValuesUnableToParse_ThrowsArgumentException(string newValue) { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); @@ -1346,7 +1332,7 @@ var inputContext = new StabilityPointStructuresInputContext(input, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); @@ -1365,7 +1351,6 @@ public void SetProbabilityCollisionSecondaryStructure_NullValue_ThrowsArgumentNullException() { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); @@ -1374,7 +1359,7 @@ var inputContext = new StabilityPointStructuresInputContext(input, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); @@ -1393,15 +1378,14 @@ public void SetStructure_StructureInSection_UpdateSectionResults() { // Setup - var assessmentSectionStub = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); var calculation = new StructuresCalculation(); var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var newStructure = new TestStabilityPointStructure(); var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); @@ -1426,7 +1410,6 @@ public void DynamicVisibleValidationMethod_StructureTypeUnknown_ReturnExpectedValues() { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -1435,7 +1418,7 @@ var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); // Call & Assert @@ -1453,7 +1436,6 @@ public void DynamicVisibleValidationMethod_LowSillStructure_ReturnExpectedValues(LoadSchematizationType schematizationType) { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -1469,7 +1451,7 @@ var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); // Call & Assert @@ -1487,7 +1469,6 @@ public void DynamicVisibleValidationMethod_FloodedCulvertStructure_ReturnExpectedValues(LoadSchematizationType schematizationType) { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -1503,7 +1484,7 @@ var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); // Call & Assert @@ -1521,7 +1502,6 @@ public void DynamicVisibleValidationMethod_LinearModel_ReturnExpectedValues(StabilityPointStructureInflowModelType structureType) { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -1537,7 +1517,7 @@ var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); // Call & Assert @@ -1555,7 +1535,6 @@ public void DynamicVisibleValidationMethod_QuadraticModel_ReturnExpectedValues(StabilityPointStructureInflowModelType structureType) { // Setup - var assessmentSectionStub = mockRepository.Stub(); var handler = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -1571,7 +1550,7 @@ var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, - assessmentSectionStub); + assessmentSection); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); // Call & Assert @@ -1784,5 +1763,17 @@ private const int quadraticFloodedCulvertUseForeshorePropertyIndex = 34; #endregion + + #region No structure property Indices + + private const int inflowModelTypePropertyIndex = 11; + private const int loadSchematizationTypePropertyIndex = 12; + private const int levellingCountPropertyIndex = 18; + private const int evaluationLevelPropertyIndex = 25; + private const int verticalDistancePropertyIndex = 26; + private const int failureProbabilityRepairClosurePropertyIndex = 27; + private const int probabilityCollisionSecondaryStructurePropertyIndex = 31; + + #endregion } } \ No newline at end of file