Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextPropertiesTest.cs =================================================================== diff -u -rfb9bf56793b90226745888c194ba6ae760f83f4c -ra0500683a36518c9b3cd5bb74fee36b858dda96d --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextPropertiesTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextPropertiesTest.cs) (revision fb9bf56793b90226745888c194ba6ae760f83f4c) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextPropertiesTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextPropertiesTest.cs) (revision a0500683a36518c9b3cd5bb74fee36b858dda96d) @@ -29,7 +29,6 @@ using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Forms.TestUtil; using Ringtoets.GrassCoverErosionInwards.Data; -using Ringtoets.GrassCoverErosionInwards.Data.Properties; using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; using Ringtoets.GrassCoverErosionInwards.Forms.PropertyClasses; @@ -40,11 +39,12 @@ { private const int namePropertyIndex = 0; private const int codePropertyIndex = 1; - private const int lengthEffectPropertyIndex = 2; - private const int frunupModelFactorPropertyIndex = 3; - private const int fbFactorPropertyIndex = 4; - private const int fnFactorPropertyIndex = 5; - private const int fshallowModelFactorPropertyIndex = 6; + private const int isRelevantPropertyIndex = 2; + private const int lengthEffectPropertyIndex = 3; + private const int frunupModelFactorPropertyIndex = 4; + private const int fbFactorPropertyIndex = 5; + private const int fnFactorPropertyIndex = 6; + private const int fshallowModelFactorPropertyIndex = 7; private MockRepository mockRepository; [SetUp] @@ -88,22 +88,28 @@ } [Test] - public void Constructor_ExpectedValues() + [TestCase(true)] + [TestCase(false)] + public void Constructor_ExpectedValues(bool isRelevant) { // Setup var assessmentSection = mockRepository.Stub(); var handler = mockRepository.Stub>(); mockRepository.ReplayAll(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + IsRelevant = isRelevant + }; var properties = new GrassCoverErosionInwardsFailureMechanismContextProperties( new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSection), handler); // Assert - Assert.AreEqual(Resources.GrassCoverErosionInwardsFailureMechanism_DisplayName, properties.Name); - Assert.AreEqual(Resources.GrassCoverErosionInwardsFailureMechanism_DisplayCode, properties.Code); + Assert.AreEqual("Dijken en dammen - Grasbekleding erosie kruin en binnentalud", properties.Name); + Assert.AreEqual("GEKB", properties.Code); + Assert.AreEqual(isRelevant, properties.IsRelevant); Assert.AreEqual(2, properties.LengthEffect); var generalInput = new GeneralGrassCoverErosionInwardsInput(); @@ -122,14 +128,17 @@ } [Test] - public void Constructor_Always_PropertiesHaveExpectedAttributesValues() + public void Constructor_IsRelevantTrue_PropertiesHaveExpectedAttributesValues() { // Setup var assessmentSection = mockRepository.Stub(); var handler = mockRepository.Stub>(); mockRepository.ReplayAll(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + IsRelevant = true + }; // Call var properties = new GrassCoverErosionInwardsFailureMechanismContextProperties( @@ -142,7 +151,7 @@ var modelSettingsCategory = "Modelinstellingen"; PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(7, dynamicProperties.Count); + Assert.AreEqual(8, dynamicProperties.Count); PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, @@ -158,6 +167,13 @@ "Het label van het toetsspoor.", true); + PropertyDescriptor isRelevantProperty = dynamicProperties[isRelevantPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isRelevantProperty, + generalCategory, + "Is relevant", + "Geeft aan of dit toetsspoor relevant is of niet.", + true); + PropertyDescriptor lengthEffectProperty = dynamicProperties[lengthEffectPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(lengthEffectProperty, lengthEffectParameterCategory, @@ -200,6 +216,54 @@ } [Test] + public void Constructor_IsRelevantFalse_PropertiesHaveExpectedAttributesValues() + { + // Setup + var assessmentSection = mockRepository.Stub(); + var handler = mockRepository.Stub>(); + mockRepository.ReplayAll(); + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + IsRelevant = false + }; + + // Call + var properties = new GrassCoverErosionInwardsFailureMechanismContextProperties( + new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSection), + handler); + + // Assert + var generalCategory = "Algemeen"; + + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(3, dynamicProperties.Count); + + PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategory, + "Naam", + "De naam van het toetsspoor.", + true); + + PropertyDescriptor codeProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(codeProperty, + generalCategory, + "Label", + "Het label van het toetsspoor.", + true); + + PropertyDescriptor isRelevantProperty = dynamicProperties[isRelevantPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isRelevantProperty, + generalCategory, + "Is relevant", + "Geeft aan of dit toetsspoor relevant is of niet.", + true); + + mockRepository.VerifyAll(); + } + + [Test] [TestCase(0, TestName = "LenghtEffect_InvalidValue_ThrowsArgumentOutOfRangeExceptionNoNotifcations(0)")] [TestCase(-1, TestName = "LenghtEffect_InvalidValue_ThrowsArgumentOutOfRangeExceptionNoNotifcations(-1)")] [TestCase(-20, TestName = "LenghtEffect_InvalidValue_ThrowsArgumentOutOfRangeExceptionNoNotifcations(-20)")] @@ -267,5 +331,65 @@ Assert.IsTrue(changeHandler.Called); mockRepository.VerifyAll(); } + + [Test] + public void DynamicVisibleValidationMethod_ForRelevantFailureMechanism_ReturnExpectedVisibility() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var changeHandler = mocks.Stub>(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + IsRelevant = true + }; + var context = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSection); + + var properties = new GrassCoverErosionInwardsFailureMechanismContextProperties(context, changeHandler); + + // Call & Assert + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.LengthEffect))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Name))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Code))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.IsRelevant))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.FrunupModelFactor))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.FbFactor))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.FnFactor))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.FshallowModelFactor))); + + Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); + } + + [Test] + public void DynamicVisibleValidationMethod_ForIrrelevantFailureMechanism_ReturnExpectedVisibility() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var changeHandler = mocks.Stub>(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + IsRelevant = false + }; + var context = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSection); + + var properties = new GrassCoverErosionInwardsFailureMechanismContextProperties(context, changeHandler); + + // Call & Assert + Assert.IsFalse(properties.DynamicVisibleValidationMethod(nameof(properties.LengthEffect))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Name))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Code))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.IsRelevant))); + Assert.IsFalse(properties.DynamicVisibleValidationMethod(nameof(properties.FrunupModelFactor))); + Assert.IsFalse(properties.DynamicVisibleValidationMethod(nameof(properties.FbFactor))); + Assert.IsFalse(properties.DynamicVisibleValidationMethod(nameof(properties.FnFactor))); + Assert.IsFalse(properties.DynamicVisibleValidationMethod(nameof(properties.FshallowModelFactor))); + + Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); + } } } \ No newline at end of file