Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -ra3acfc43c74e601ed4e7d3a80f9a7daa58a836c6 -r85a670b5d50ae1820777e330d6db07231f7e89af --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision a3acfc43c74e601ed4e7d3a80f9a7daa58a836c6) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 85a670b5d50ae1820777e330d6db07231f7e89af) @@ -751,6 +751,15 @@ } /// + /// Looks up a localized string similar to Overig (30). + /// + public static string StandAloneFailureMechanismProperties_Contribution_Other { + get { + return ResourceManager.GetString("StandAloneFailureMechanismProperties_Contribution_Other", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Alles be&rekenen. /// public static string WaveHeight_Calculate_All { Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx =================================================================== diff -u -ra3acfc43c74e601ed4e7d3a80f9a7daa58a836c6 -r85a670b5d50ae1820777e330d6db07231f7e89af --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision a3acfc43c74e601ed4e7d3a80f9a7daa58a836c6) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision 85a670b5d50ae1820777e330d6db07231f7e89af) @@ -348,4 +348,7 @@ Lijst van alle coördinaten (X-coördinaat, Y-coördinaat) die samen de referentielijn vormen. + + Overig (30) + \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/StandAlone/StandAloneFailureMechanismProperties.cs =================================================================== diff -u -r65ce8c5ab171b234e33e2291998c9d89276db896 -r85a670b5d50ae1820777e330d6db07231f7e89af --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/StandAlone/StandAloneFailureMechanismProperties.cs (.../StandAloneFailureMechanismProperties.cs) (revision 65ce8c5ab171b234e33e2291998c9d89276db896) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/StandAlone/StandAloneFailureMechanismProperties.cs (.../StandAloneFailureMechanismProperties.cs) (revision 85a670b5d50ae1820777e330d6db07231f7e89af) @@ -24,6 +24,7 @@ using Core.Common.Gui.PropertyBag; using Core.Common.Util.Attributes; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Integration.Forms.Properties; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.Integration.Forms.PropertyClasses.StandAlone @@ -48,6 +49,22 @@ Data = failureMechanism; } + [DynamicVisibleValidationMethod] + public bool DynamicVisibleValidationMethod(string propertyName) + { + if (!data.IsRelevant && ShouldHidePropertyWhenFailureMechanismIrrelevant(propertyName)) + { + return false; + } + + return true; + } + + private bool ShouldHidePropertyWhenFailureMechanismIrrelevant(string propertyName) + { + return nameof(Contribution).Equals(propertyName); + } + #region General [PropertyOrder(1)] @@ -74,8 +91,21 @@ } } + [DynamicVisible] [PropertyOrder(3)] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.FailureMechanism_Contribution_DisplayName))] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.FailureMechanism_Contribution_Description))] + public string Contribution + { + get + { + return Resources.StandAloneFailureMechanismProperties_Contribution_Other; + } + } + + [PropertyOrder(4)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.FailureMechanism_IsRelevant_DisplayName))] [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.FailureMechanism_IsRelevant_Description))] public bool IsRelevant Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/StandAlone/StandAloneFailureMechanismPropertiesTest.cs =================================================================== diff -u -r65ce8c5ab171b234e33e2291998c9d89276db896 -r85a670b5d50ae1820777e330d6db07231f7e89af --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/StandAlone/StandAloneFailureMechanismPropertiesTest.cs (.../StandAloneFailureMechanismPropertiesTest.cs) (revision 65ce8c5ab171b234e33e2291998c9d89276db896) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/StandAlone/StandAloneFailureMechanismPropertiesTest.cs (.../StandAloneFailureMechanismPropertiesTest.cs) (revision 85a670b5d50ae1820777e330d6db07231f7e89af) @@ -24,7 +24,6 @@ using Core.Common.Gui.PropertyBag; using Core.Common.TestUtil; using NUnit.Framework; -using Rhino.Mocks; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Integration.Forms.PropertyClasses.StandAlone; @@ -46,20 +45,26 @@ } [Test] - public void Constructor_WithFailureMechanism_ExpectedValues() + [TestCase(true)] + [TestCase(false)] + public void Constructor_ExpectedValues(bool isRelevant) { // Setup - var mocks = new MockRepository(); - var failureMechanism = mocks.Stub(); - mocks.ReplayAll(); + var failureMechanism = new TestFailureMechanism + { + IsRelevant = isRelevant + }; // Call var properties = new StandAloneFailureMechanismProperties(failureMechanism); // Assert Assert.IsInstanceOf>(properties); Assert.AreSame(failureMechanism, properties.Data); - mocks.VerifyAll(); + Assert.AreEqual(failureMechanism.Name, properties.Name); + Assert.AreEqual(failureMechanism.Code, properties.Code); + Assert.AreEqual("Overig (30)", properties.Contribution); + Assert.AreEqual(failureMechanism.IsRelevant, properties.IsRelevant); } [Test] @@ -83,14 +88,12 @@ } [Test] - [TestCase(true)] - [TestCase(false)] - public void Constructor_Always_PropertiesHaveExpectedAttributesValues(bool isRelevant) + public void Constructor_IsRelevantTrue_PropertiesHaveExpectedAttributesValues() { // Setup var failureMechanism = new TestFailureMechanism { - IsRelevant = isRelevant + IsRelevant = true }; // Call @@ -100,7 +103,7 @@ const string generalCategory = "Algemeen"; PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(3, dynamicProperties.Count); + Assert.AreEqual(4, dynamicProperties.Count); PropertyDescriptor nameProperty = dynamicProperties[0]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, @@ -116,12 +119,81 @@ "Het label van het toetsspoor.", true); + PropertyDescriptor contributionProperty = dynamicProperties[2]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(contributionProperty, + generalCategory, + "Faalkansbijdrage [%]", + "Procentuele bijdrage van dit toetsspoor aan de totale overstromingskans van het traject.", + true); + + PropertyDescriptor isRelevantProperty = dynamicProperties[3]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isRelevantProperty, + generalCategory, + "Is relevant", + "Geeft aan of dit toetsspoor relevant is of niet.", + true); + } + + [Test] + public void Constructor_IsRelevantFalse_PropertiesHaveExpectedAttributesValues() + { + // Setup + var failureMechanism = new TestFailureMechanism + { + IsRelevant = false + }; + + // Call + var properties = new StandAloneFailureMechanismProperties(failureMechanism); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(3, dynamicProperties.Count); + + const string generalCategory = "Algemeen"; + + PropertyDescriptor nameProperty = dynamicProperties[0]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategory, + "Naam", + "De naam van het toetsspoor.", + true); + + PropertyDescriptor labelProperty = dynamicProperties[1]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(labelProperty, + generalCategory, + "Label", + "Het label van het toetsspoor.", + true); + PropertyDescriptor isRelevantProperty = dynamicProperties[2]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isRelevantProperty, generalCategory, "Is relevant", "Geeft aan of dit toetsspoor relevant is of niet.", true); } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void DynamicVisibleValidationMethod_DependingOnRelevancy_ReturnExpectedVisibility(bool isRelevant) + { + // Setup + var failureMechanism = new TestFailureMechanism + { + IsRelevant = isRelevant + }; + var properties = new StandAloneFailureMechanismProperties(failureMechanism); + + // Call & Assert + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Name))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Code))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.IsRelevant))); + + Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.Contribution))); + + Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); + } } } \ No newline at end of file