Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs =================================================================== diff -u -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 -r449b5831547d5a6391da8ad825e7c845ef7ecc1c --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 449b5831547d5a6391da8ad825e7c845ef7ecc1c) @@ -193,6 +193,45 @@ } [Test] + [TestCase(true)] + [TestCase(false)] + public void Constructor_WithOrWithoutStructure_CorrectReadOnlyForStructureDependentProperties(bool hasStructure) + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + var handler = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanism = new HeightStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + var inputContext = new HeightStructuresInputContext(calculation.InputParameters, + calculation, + failureMechanism, + assessmentSectionStub); + if (hasStructure) + { + calculation.InputParameters.Structure = new TestHeightStructure(); + } + + // Call + var properties = new HeightStructuresInputContextProperties(inputContext, handler); + + // Assert + AssertPropertiesInState(properties.LevelCrestStructure, !hasStructure); + + mockRepository.VerifyAll(); + } + + private static void AssertPropertiesInState(object properties, bool expectedReadOnly) + { + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(3, dynamicProperties.Count); + + Assert.AreEqual(expectedReadOnly, dynamicProperties[1].IsReadOnly); + Assert.AreEqual(expectedReadOnly, dynamicProperties[2].IsReadOnly); + } + + [Test] public void GetAvailableForeshoreProfiles_SetInputContextInstanceWithForeshoreProfiles_ReturnForeshoreProfiles() { // Setup @@ -305,6 +344,7 @@ var calculation = new StructuresCalculation(); HeightStructuresInput input = calculation.InputParameters; input.ForeshoreProfile = new TestForeshoreProfile(); + input.Structure = new TestHeightStructure(); var customHandler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] {