Index: Riskeer/Integration/src/Riskeer.Integration.Forms/PropertyClasses/SpecificFailurePathProperties.cs =================================================================== diff -u -r2232ff8b2af8d6a7a9005b2f2e0566ebcba2b1e9 -r53db672ea7f64a027340bc5170cfdf7b837acb48 --- Riskeer/Integration/src/Riskeer.Integration.Forms/PropertyClasses/SpecificFailurePathProperties.cs (.../SpecificFailurePathProperties.cs) (revision 2232ff8b2af8d6a7a9005b2f2e0566ebcba2b1e9) +++ Riskeer/Integration/src/Riskeer.Integration.Forms/PropertyClasses/SpecificFailurePathProperties.cs (.../SpecificFailurePathProperties.cs) (revision 53db672ea7f64a027340bc5170cfdf7b837acb48) @@ -38,6 +38,7 @@ private const int namePropertyIndex = 1; private const int inAssemblyPropertyIndex = 2; private const int nPropertyIndex = 3; + private const int applyLengthEffectInSectionPropertyIndex = 4; /// /// Creates a new instance of . @@ -54,6 +55,20 @@ Data = data; } + [DynamicVisibleValidationMethod] + public bool DynamicVisibleValidationMethod(string propertyName) + { + return data.InAssembly || !ShouldHidePropertyWhenFailurePathNotPartOfAssembly(propertyName); + } + + private static bool ShouldHidePropertyWhenFailurePathNotPartOfAssembly(string propertyName) + { + return nameof(N).Equals(propertyName) + || nameof(ApplyLengthEffectInSection).Equals(propertyName); + } + + #region General + [PropertyOrder(namePropertyIndex)] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Name_DisplayName))] @@ -83,6 +98,10 @@ } } + #endregion + + #region Length effect parameters + [DynamicVisible] [PropertyOrder(nPropertyIndex)] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] @@ -101,15 +120,24 @@ } } - [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 || !ShouldHidePropertyWhenFailurePathNotPartOfAssembly(propertyName); + get + { + return data.Input.ApplyLengthEffectInSection; + } + set + { + data.Input.ApplyLengthEffectInSection = value; + data.NotifyObservers(); + } } - private static bool ShouldHidePropertyWhenFailurePathNotPartOfAssembly(string propertyName) - { - return nameof(N).Equals(propertyName); - } + #endregion } } \ No newline at end of file Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PropertyClasses/SpecificFailurePathPropertiesTest.cs =================================================================== diff -u -rfdfcebfac58179f6b1d1e19d376342f82eaaffcd -r53db672ea7f64a027340bc5170cfdf7b837acb48 --- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PropertyClasses/SpecificFailurePathPropertiesTest.cs (.../SpecificFailurePathPropertiesTest.cs) (revision fdfcebfac58179f6b1d1e19d376342f82eaaffcd) +++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PropertyClasses/SpecificFailurePathPropertiesTest.cs (.../SpecificFailurePathPropertiesTest.cs) (revision 53db672ea7f64a027340bc5170cfdf7b837acb48) @@ -41,6 +41,7 @@ private const int namePropertyIndex = 0; private const int inAssemblyPropertyIndex = 1; private const int nPropertyIndex = 2; + private const int applyLengthEffectInSectionPropertyIndex = 3; [Test] public void Constructor_DataNull_ThrowsArgumentNullException() @@ -60,7 +61,11 @@ var random = new Random(21); var failurePath = new SpecificFailurePath { - InAssembly = random.NextBoolean() + InAssembly = random.NextBoolean(), + Input = + { + ApplyLengthEffectInSection = random.NextBoolean() + } }; // Call @@ -74,6 +79,7 @@ GeneralInput input = failurePath.Input; Assert.AreEqual(2, properties.N.NumberOfDecimalPlaces); Assert.AreEqual(input.N, properties.N, properties.N.GetAccuracy()); + Assert.AreEqual(failurePath.Input.ApplyLengthEffectInSection, properties.ApplyLengthEffectInSection); } [Test] @@ -90,7 +96,7 @@ // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(3, dynamicProperties.Count); + Assert.AreEqual(4, dynamicProperties.Count); const string generalCategory = "Algemeen"; const string lengthEffectCategory = "Lengte-effect"; @@ -113,6 +119,12 @@ lengthEffectCategory, "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."); } [Test] @@ -213,6 +225,33 @@ [Test] [TestCase(true)] [TestCase(false)] + public void ApplyLengthEffectInSection_SetNewValue_NotifyObservers(bool applyLengthEffectInSection) + { + // Setup + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var failurePath = new SpecificFailurePath(); + failurePath.Attach(observer); + + failurePath.Input.ApplyLengthEffectInSection = !applyLengthEffectInSection; + + var properties = new SpecificFailurePathProperties(failurePath); + + // Call + properties.ApplyLengthEffectInSection = applyLengthEffectInSection; + + // Assert + Assert.AreEqual(applyLengthEffectInSection, failurePath.Input.ApplyLengthEffectInSection); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] public void DynamicVisibleValidationMethod_DependingOnInAssembly_ReturnExpectedVisibility(bool inAssembly) { // Setup @@ -227,6 +266,7 @@ Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.InAssembly))); Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.N))); + Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.ApplyLengthEffectInSection))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); }