Index: Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Forms/PropertyClasses/ClosingStructuresCalculationsProperties.cs =================================================================== diff -u -rcf89119fc5a8184e0cbb07ec916d7b17c2e93a05 -r8e7fdb0398c15956763e9fa43c64eabbfec90133 --- Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Forms/PropertyClasses/ClosingStructuresCalculationsProperties.cs (.../ClosingStructuresCalculationsProperties.cs) (revision cf89119fc5a8184e0cbb07ec916d7b17c2e93a05) +++ Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Forms/PropertyClasses/ClosingStructuresCalculationsProperties.cs (.../ClosingStructuresCalculationsProperties.cs) (revision 8e7fdb0398c15956763e9fa43c64eabbfec90133) @@ -41,17 +41,16 @@ private const int codePropertyIndex = 2; private const int groupPropertyIndex = 3; private const int contributionPropertyIndex = 4; - private const int isRelevantPropertyIndex = 5; - private const int gravitationalAccelerationPropertyIndex = 6; + private const int gravitationalAccelerationPropertyIndex = 5; - private const int cPropertyIndex = 7; - private const int n2APropertyIndex = 8; - private const int nPropertyIndex = 9; + private const int cPropertyIndex = 6; + private const int n2APropertyIndex = 7; + private const int nPropertyIndex = 8; - private const int modelFactorOvertoppingFlowPropertyIndex = 10; - private const int modelFactorStorageVolumePropertyIndex = 11; - private const int modelFactorLongThresholdPropertyIndex = 12; - private const int modelFactorInflowVolumePropertyIndex = 13; + private const int modelFactorOvertoppingFlowPropertyIndex = 9; + private const int modelFactorStorageVolumePropertyIndex = 10; + private const int modelFactorLongThresholdPropertyIndex = 11; + private const int modelFactorInflowVolumePropertyIndex = 12; /// /// Creates a new instance of . @@ -69,28 +68,8 @@ Data = data; } - [DynamicVisibleValidationMethod] - public bool DynamicVisibleValidationMethod(string propertyName) - { - return data.IsRelevant || !ShouldHidePropertyWhenFailureMechanismIrrelevant(propertyName); - } - - private bool ShouldHidePropertyWhenFailureMechanismIrrelevant(string propertyName) - { - return nameof(Contribution).Equals(propertyName) - || nameof(GravitationalAcceleration).Equals(propertyName) - || nameof(ModelFactorOvertoppingFlow).Equals(propertyName) - || nameof(ModelFactorStorageVolume).Equals(propertyName) - || nameof(ModelFactorLongThreshold).Equals(propertyName) - || nameof(ModelFactorInflowVolume).Equals(propertyName) - || nameof(C).Equals(propertyName) - || nameof(N2A).Equals(propertyName) - || nameof(N).Equals(propertyName); - } - #region Length effect parameters - [DynamicVisible] [PropertyOrder(cPropertyIndex)] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.ClosingStructuresFailureMechanismProperties_C_DisplayName))] @@ -103,7 +82,6 @@ } } - [DynamicVisible] [PropertyOrder(n2APropertyIndex)] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.ClosingStructuresFailureMechanismProperties_N2A_DisplayName))] @@ -121,7 +99,6 @@ } } - [DynamicVisible] [PropertyOrder(nPropertyIndex)] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Rounded_DisplayName))] @@ -174,7 +151,6 @@ } } - [DynamicVisible] [PropertyOrder(contributionPropertyIndex)] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Contribution_DisplayName))] @@ -187,19 +163,6 @@ } } - [PropertyOrder(isRelevantPropertyIndex)] - [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] - [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_IsRelevant_DisplayName))] - [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_IsRelevant_Description))] - public bool IsRelevant - { - get - { - return data.IsRelevant; - } - } - - [DynamicVisible] [PropertyOrder(gravitationalAccelerationPropertyIndex)] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.GravitationalAcceleration_DisplayName))] @@ -216,7 +179,6 @@ #region Model settings - [DynamicVisible] [PropertyOrder(modelFactorOvertoppingFlowPropertyIndex)] [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] @@ -230,7 +192,6 @@ } } - [DynamicVisible] [PropertyOrder(modelFactorStorageVolumePropertyIndex)] [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] @@ -244,7 +205,6 @@ } } - [DynamicVisible] [PropertyOrder(modelFactorLongThresholdPropertyIndex)] [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] @@ -258,7 +218,6 @@ } } - [DynamicVisible] [PropertyOrder(modelFactorInflowVolumePropertyIndex)] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.StructuresInputFailureMechanismContext_ModelFactorInflowVolume_DisplayName))] Index: Riskeer/ClosingStructures/test/Riskeer.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresCalculationsPropertiesTest.cs =================================================================== diff -u -rcf89119fc5a8184e0cbb07ec916d7b17c2e93a05 -r8e7fdb0398c15956763e9fa43c64eabbfec90133 --- Riskeer/ClosingStructures/test/Riskeer.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresCalculationsPropertiesTest.cs (.../ClosingStructuresCalculationsPropertiesTest.cs) (revision cf89119fc5a8184e0cbb07ec916d7b17c2e93a05) +++ Riskeer/ClosingStructures/test/Riskeer.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresCalculationsPropertiesTest.cs (.../ClosingStructuresCalculationsPropertiesTest.cs) (revision 8e7fdb0398c15956763e9fa43c64eabbfec90133) @@ -40,39 +40,33 @@ private const int codePropertyIndex = 1; private const int groupPropertyIndex = 2; private const int contributionPropertyIndex = 3; - private const int isRelevantPropertyIndex = 4; - private const int gravitationalAccelerationPropertyIndex = 5; + private const int gravitationalAccelerationPropertyIndex = 4; - private const int cPropertyIndex = 6; - private const int n2APropertyIndex = 7; - private const int nPropertyIndex = 8; + private const int cPropertyIndex = 5; + private const int n2APropertyIndex = 6; + private const int nPropertyIndex = 7; - private const int modelFactorOvertoppingFlowPropertyIndex = 9; - private const int modelFactorStorageVolumePropertyIndex = 10; - private const int modelFactorLongThresholdPropertyIndex = 11; - private const int modelFactorInflowVolumePropertyIndex = 12; + private const int modelFactorOvertoppingFlowPropertyIndex = 8; + private const int modelFactorStorageVolumePropertyIndex = 9; + private const int modelFactorLongThresholdPropertyIndex = 10; + private const int modelFactorInflowVolumePropertyIndex = 11; [Test] public void Constructor_DataNull_ThrowArgumentNullException() { // Call - TestDelegate test = () => new ClosingStructuresCalculationsProperties(null); + void Call() => new ClosingStructuresCalculationsProperties(null); // Assert - string paramName = Assert.Throws(test).ParamName; + string paramName = Assert.Throws(Call).ParamName; Assert.AreEqual("data", paramName); } [Test] - [TestCase(true)] - [TestCase(false)] - public void Constructor_ValidValues_ExpectedValues(bool isRelevant) + public void Constructor_ExpectedValues() { // Setup - var failureMechanism = new ClosingStructuresFailureMechanism - { - IsRelevant = isRelevant - }; + var failureMechanism = new ClosingStructuresFailureMechanism(); // Call var properties = new ClosingStructuresCalculationsProperties(failureMechanism); @@ -84,7 +78,6 @@ Assert.AreEqual(failureMechanism.Code, properties.Code); Assert.AreEqual(failureMechanism.Group, properties.Group); Assert.AreEqual(failureMechanism.Contribution, properties.Contribution); - Assert.AreEqual(isRelevant, properties.IsRelevant); GeneralClosingStructuresInput generalInput = failureMechanism.GeneralInput; Assert.AreEqual(generalInput.GravitationalAcceleration, @@ -105,22 +98,18 @@ } [Test] - public void Constructor_IsRelevantTrue_PropertiesHaveExpectedAttributesValues() + public void Constructor_Always_PropertiesHaveExpectedAttributeValues() { // Call - var properties = new ClosingStructuresCalculationsProperties( - new ClosingStructuresFailureMechanism - { - IsRelevant = true - }); + var properties = new ClosingStructuresCalculationsProperties(new ClosingStructuresFailureMechanism()); // Assert const string generalCategory = "Algemeen"; const string lengthEffectCategory = "Lengte-effect parameters"; const string modelSettingsCategory = "Modelinstellingen"; PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(13, dynamicProperties.Count); + Assert.AreEqual(12, dynamicProperties.Count); PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, @@ -150,13 +139,6 @@ "Procentuele bijdrage van dit toetsspoor aan de totale overstromingskans van het traject.", true); - PropertyDescriptor isRelevantProperty = dynamicProperties[isRelevantPropertyIndex]; - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isRelevantProperty, - generalCategory, - "Is relevant", - "Geeft aan of dit toetsspoor relevant is of niet.", - true); - PropertyDescriptor gravitationalAccelerationProperty = dynamicProperties[gravitationalAccelerationPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(gravitationalAccelerationProperty, generalCategory, @@ -217,51 +199,6 @@ } [Test] - public void Constructor_IsRelevantFalse_PropertiesHaveExpectedAttributesValues() - { - // Call - var properties = new ClosingStructuresCalculationsProperties( - new ClosingStructuresFailureMechanism - { - IsRelevant = false - }); - - // Assert - const string generalCategory = "Algemeen"; - - PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(4, 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 groupProperty = dynamicProperties[groupPropertyIndex]; - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(groupProperty, - generalCategory, - "Groep", - "De groep waar het toetsspoor toe behoort.", - true); - - PropertyDescriptor isRelevantProperty = dynamicProperties[isRelevantPropertyIndex - 1]; - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isRelevantProperty, - generalCategory, - "Is relevant", - "Geeft aan of dit toetsspoor relevant is of niet.", - true); - } - - [Test] [TestCase(-10)] [TestCase(-1)] [TestCase(41)] @@ -312,36 +249,5 @@ Assert.AreEqual(value, failureMechanism.GeneralInput.N2A); mockRepository.VerifyAll(); } - - [Test] - [TestCase(true)] - [TestCase(false)] - public void DynamicVisibleValidationMethod_DependingOnRelevancy_ReturnExpectedVisibility(bool isRelevant) - { - // Setup - var properties = new ClosingStructuresCalculationsProperties( - new ClosingStructuresFailureMechanism - { - IsRelevant = isRelevant - }); - - // Call & Assert - Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Name))); - Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Code))); - Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Group))); - Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.IsRelevant))); - - Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.Contribution))); - Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.C))); - Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.N2A))); - Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.N))); - Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.GravitationalAcceleration))); - Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.ModelFactorOvertoppingFlow))); - Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.ModelFactorStorageVolume))); - Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.ModelFactorLongThreshold))); - Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.ModelFactorInflowVolume))); - - Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); - } } } \ No newline at end of file