Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsWaterStressesProperties.cs =================================================================== diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -rae1fbf8ec3aba9623ab57d35b1aeea9c509789ce --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsWaterStressesProperties.cs (.../MacroStabilityInwardsWaterStressesProperties.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsWaterStressesProperties.cs (.../MacroStabilityInwardsWaterStressesProperties.cs) (revision ae1fbf8ec3aba9623ab57d35b1aeea9c509789ce) @@ -30,6 +30,7 @@ using Riskeer.MacroStabilityInwards.Data; using Riskeer.MacroStabilityInwards.Forms.PresentationObjects; using Riskeer.MacroStabilityInwards.Forms.Properties; +using Riskeer.MacroStabilityInwards.Primitives; namespace Riskeer.MacroStabilityInwards.Forms.PropertyClasses { @@ -295,6 +296,33 @@ } } + [DynamicReadOnlyValidationMethod] + public bool DynamicReadOnlyValidationMethod(string propertyName) + { + if (propertyName == nameof(AdjustPhreaticLine3And4ForUplift) + || propertyName == nameof(LeakageLengthInwardsPhreaticLine3) + || propertyName == nameof(LeakageLengthOutwardsPhreaticLine3) + || propertyName == nameof(PiezometricHeadPhreaticLine2Inwards) + || propertyName == nameof(PiezometricHeadPhreaticLine2Outwards)) + { + if (data.DikeSoilScenario == MacroStabilityInwardsDikeSoilScenario.SandDikeOnSand) + { + return true; + } + } + + if (propertyName == nameof(LeakageLengthInwardsPhreaticLine4) || propertyName == nameof(LeakageLengthOutwardsPhreaticLine4)) + { + if (data.DikeSoilScenario == MacroStabilityInwardsDikeSoilScenario.SandDikeOnSand + || data.DikeSoilScenario == MacroStabilityInwardsDikeSoilScenario.ClayDikeOnSand) + { + return true; + } + } + + return false; + } + public override string ToString() { return string.Empty; Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsInputContextPropertiesTest.cs =================================================================== diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -rae1fbf8ec3aba9623ab57d35b1aeea9c509789ce --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsInputContextPropertiesTest.cs (.../MacroStabilityInwardsInputContextPropertiesTest.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsInputContextPropertiesTest.cs (.../MacroStabilityInwardsInputContextPropertiesTest.cs) (revision ae1fbf8ec3aba9623ab57d35b1aeea9c509789ce) @@ -1360,10 +1360,10 @@ handler); // Call - bool result = properties.DynamicReadOnlyValidationMethod("AssessmentLevel"); + bool result = properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsInputContextProperties.AssessmentLevel)); // Assert - Assert.AreNotEqual(useAssessmentLevelManualInput, result); + Assert.AreEqual(!useAssessmentLevelManualInput, result); } [Test] Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsWaterStressesPropertiesTest.cs =================================================================== diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -rae1fbf8ec3aba9623ab57d35b1aeea9c509789ce --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsWaterStressesPropertiesTest.cs (.../MacroStabilityInwardsWaterStressesPropertiesTest.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsWaterStressesPropertiesTest.cs (.../MacroStabilityInwardsWaterStressesPropertiesTest.cs) (revision ae1fbf8ec3aba9623ab57d35b1aeea9c509789ce) @@ -456,6 +456,95 @@ } [Test] + public void DynamicReadOnlyValidationMethod_DikeSoilScenarioSandDikeOnSand_ReturnsExpectedReadOnly() + { + // Setup + var mocks = new MockRepository(); + var propertyChangeHandler = mocks.Stub(); + mocks.ReplayAll(); + + var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) + { + DikeSoilScenario = MacroStabilityInwardsDikeSoilScenario.SandDikeOnSand + }; + var properties = new MacroStabilityInwardsWaterStressesProperties(input, + AssessmentSectionTestHelper.GetTestAssessmentLevel(), + propertyChangeHandler); + + // Call & Assert + Assert.IsTrue(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.AdjustPhreaticLine3And4ForUplift))); + Assert.IsTrue(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.LeakageLengthInwardsPhreaticLine3))); + Assert.IsTrue(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.LeakageLengthOutwardsPhreaticLine3))); + Assert.IsTrue(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.LeakageLengthInwardsPhreaticLine4))); + Assert.IsTrue(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.LeakageLengthOutwardsPhreaticLine4))); + Assert.IsTrue(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.PiezometricHeadPhreaticLine2Inwards))); + Assert.IsTrue(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.PiezometricHeadPhreaticLine2Outwards))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.WaterLevelRiverAverage))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.MinimumLevelPhreaticLineAtDikeTopPolder))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.MinimumLevelPhreaticLineAtDikeTopRiver))); + } + + [Test] + public void DynamicReadOnlyValidationMethod_DikeSoilScenarioClayDikeOnSand_ReturnsExpectedReadOnly() + { + // Setup + var mocks = new MockRepository(); + var propertyChangeHandler = mocks.Stub(); + mocks.ReplayAll(); + + var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) + { + DikeSoilScenario = MacroStabilityInwardsDikeSoilScenario.ClayDikeOnSand + }; + var properties = new MacroStabilityInwardsWaterStressesProperties(input, + AssessmentSectionTestHelper.GetTestAssessmentLevel(), + propertyChangeHandler); + + // Call & Assert + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.AdjustPhreaticLine3And4ForUplift))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.LeakageLengthInwardsPhreaticLine3))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.LeakageLengthOutwardsPhreaticLine3))); + Assert.IsTrue(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.LeakageLengthInwardsPhreaticLine4))); + Assert.IsTrue(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.LeakageLengthOutwardsPhreaticLine4))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.PiezometricHeadPhreaticLine2Inwards))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.PiezometricHeadPhreaticLine2Outwards))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.WaterLevelRiverAverage))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.MinimumLevelPhreaticLineAtDikeTopPolder))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.MinimumLevelPhreaticLineAtDikeTopRiver))); + } + + [Test] + [TestCase(MacroStabilityInwardsDikeSoilScenario.ClayDikeOnClay)] + [TestCase(MacroStabilityInwardsDikeSoilScenario.SandDikeOnClay)] + public void DynamicReadOnlyValidationMethod_OtherDikeSoilScenario_ReturnsExpectedReadOnly(MacroStabilityInwardsDikeSoilScenario dikeSoilScenario) + { + // Setup + var mocks = new MockRepository(); + var propertyChangeHandler = mocks.Stub(); + mocks.ReplayAll(); + + var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) + { + DikeSoilScenario = dikeSoilScenario + }; + var properties = new MacroStabilityInwardsWaterStressesProperties(input, + AssessmentSectionTestHelper.GetTestAssessmentLevel(), + propertyChangeHandler); + + // Call & Assert + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.AdjustPhreaticLine3And4ForUplift))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.LeakageLengthInwardsPhreaticLine3))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.LeakageLengthOutwardsPhreaticLine3))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.LeakageLengthInwardsPhreaticLine4))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.LeakageLengthOutwardsPhreaticLine4))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.PiezometricHeadPhreaticLine2Inwards))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.PiezometricHeadPhreaticLine2Outwards))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.WaterLevelRiverAverage))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.MinimumLevelPhreaticLineAtDikeTopPolder))); + Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.MinimumLevelPhreaticLineAtDikeTopRiver))); + } + + [Test] public void ToString_Always_ReturnEmptyString() { // Setup