Index: Riskeer/Integration/src/Riskeer.Integration.Forms/PropertyClasses/StandAlone/StandAloneFailurePathProperties.cs =================================================================== diff -u -rf04e7226fae683976fa27f56cdbbb8a699e20934 -rcb83886c96a9d1f96347521f3d0746877b9c15a6 --- Riskeer/Integration/src/Riskeer.Integration.Forms/PropertyClasses/StandAlone/StandAloneFailurePathProperties.cs (.../StandAloneFailurePathProperties.cs) (revision f04e7226fae683976fa27f56cdbbb8a699e20934) +++ Riskeer/Integration/src/Riskeer.Integration.Forms/PropertyClasses/StandAlone/StandAloneFailurePathProperties.cs (.../StandAloneFailurePathProperties.cs) (revision cb83886c96a9d1f96347521f3d0746877b9c15a6) @@ -44,6 +44,7 @@ private const int contributionPropertyIndex = 4; private const int inAssemblyPropertyIndex = 5; private const int nPropertyIndex = 6; + private const int applyLengthEffectInSectionPropertyIndex = 7; private readonly IAssessmentSection assessmentSection; @@ -70,6 +71,19 @@ Data = failureMechanism; } + [DynamicVisibleValidationMethod] + public bool DynamicVisibleValidationMethod(string propertyName) + { + return data.InAssembly || !ShouldHidePropertyWhenFailureMechanismNotPartOfAssembly(propertyName); + } + + private static bool ShouldHidePropertyWhenFailureMechanismNotPartOfAssembly(string propertyName) + { + return nameof(Contribution).Equals(propertyName) + || nameof(N).Equals(propertyName) + || nameof(ApplyLengthEffectInSection).Equals(propertyName); + } + #region Length effect parameters [DynamicVisible] @@ -90,19 +104,25 @@ } } - #endregion - - [DynamicVisibleValidationMethod] - public bool DynamicVisibleValidationMethod(string propertyName) + [DynamicVisible] + [PropertyOrder(applyLengthEffectInSectionPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailurePath_Apply_LengthEffect_In_Section_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailurePath_Apply_LengthEffect_In_Section_Description))] + public bool ApplyLengthEffectInSection { - return data.InAssembly || !ShouldHidePropertyWhenFailureMechanismNotPartOfAssembly(propertyName); + get + { + return data.GeneralInput.ApplyLengthEffectInSection; + } + set + { + data.GeneralInput.ApplyLengthEffectInSection = value; + data.NotifyObservers(); + } } - private static bool ShouldHidePropertyWhenFailureMechanismNotPartOfAssembly(string propertyName) - { - return nameof(Contribution).Equals(propertyName) - || nameof(N).Equals(propertyName); - } + #endregion #region General Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PropertyClasses/StandAlone/StandAloneFailurePathPropertiesTest.cs =================================================================== diff -u -rfdfcebfac58179f6b1d1e19d376342f82eaaffcd -rcb83886c96a9d1f96347521f3d0746877b9c15a6 --- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PropertyClasses/StandAlone/StandAloneFailurePathPropertiesTest.cs (.../StandAloneFailurePathPropertiesTest.cs) (revision fdfcebfac58179f6b1d1e19d376342f82eaaffcd) +++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PropertyClasses/StandAlone/StandAloneFailurePathPropertiesTest.cs (.../StandAloneFailurePathPropertiesTest.cs) (revision cb83886c96a9d1f96347521f3d0746877b9c15a6) @@ -44,6 +44,7 @@ private const int contributionPropertyIndex = 3; private const int inAssemblyPropertyIndex = 4; private const int nPropertyIndex = 5; + private const int applyLengthEffectInSectionPropertyIndex = 6; [Test] public void Constructor_FailureMechanismNull_ThrowsArgumentNullException() @@ -82,7 +83,11 @@ var failureMechanism = new TestFailureMechanism { - InAssembly = random.NextBoolean() + InAssembly = random.NextBoolean(), + GeneralInput = + { + ApplyLengthEffectInSection = random.NextBoolean() + } }; var mocks = new MockRepository(); @@ -109,6 +114,8 @@ Assert.AreEqual($"Overig ({otherContribution})", properties.Contribution); Assert.AreEqual(failureMechanism.InAssembly, properties.InAssembly); Assert.AreEqual(failureMechanism.GeneralInput.N, properties.N); + Assert.AreEqual(failureMechanism.GeneralInput.ApplyLengthEffectInSection, properties.ApplyLengthEffectInSection); + mocks.VerifyAll(); } @@ -133,7 +140,7 @@ const string lengthEffectCategory = "Lengte-effect"; PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(6, dynamicProperties.Count); + Assert.AreEqual(7, dynamicProperties.Count); PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, @@ -176,6 +183,12 @@ "N [-]", "De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in de beoordeling."); + PropertyDescriptor applySectionLengthInSectionProperty = dynamicProperties[applyLengthEffectInSectionPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(applySectionLengthInSectionProperty, + lengthEffectCategory, + "Toepassen lengte-effect binnen vak", + "Geeft aan of het lengte-effect binnen een vak toegepast wordt."); + mocks.VerifyAll(); } @@ -228,7 +241,7 @@ "In assemblage", "Geeft aan of dit faalpad wordt meegenomen in de assemblage.", true); - + mocks.VerifyAll(); } @@ -286,6 +299,32 @@ [Test] [TestCase(true)] [TestCase(false)] + public void ApplyLengthEffectInSection_SetNewValue_NotifyObservers(bool applyLengthEffectInSection) + { + // Setup + var mocks = new MockRepository(); + var failureMechanism = mocks.StrictMock(); + failureMechanism.Expect(fm => fm.NotifyObservers()); + failureMechanism.Stub(fm => fm.GeneralInput).Return(new GeneralInput()); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + failureMechanism.GeneralInput.ApplyLengthEffectInSection = !applyLengthEffectInSection; + + var properties = new StandAloneFailurePathProperties(failureMechanism, assessmentSection); + + // Call + properties.ApplyLengthEffectInSection = applyLengthEffectInSection; + + // Assert + Assert.AreEqual(applyLengthEffectInSection, failureMechanism.GeneralInput.ApplyLengthEffectInSection); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] public void DynamicVisibleValidationMethod_DependingOnInAssembly_ReturnExpectedVisibility(bool inAssembly) { // Setup @@ -307,6 +346,7 @@ Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.Contribution))); Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.N))); + Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.ApplyLengthEffectInSection))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); mocks.VerifyAll();