Index: Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresCalculationsProperties.cs =================================================================== diff -u -rb3ce5277a93d67703d2821469ce5871fdf7b53fc -r3d113e20211791ee77497b915bf4f32ad8d4cedd --- Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresCalculationsProperties.cs (.../StabilityPointStructuresCalculationsProperties.cs) (revision b3ce5277a93d67703d2821469ce5871fdf7b53fc) +++ Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresCalculationsProperties.cs (.../StabilityPointStructuresCalculationsProperties.cs) (revision 3d113e20211791ee77497b915bf4f32ad8d4cedd) @@ -41,13 +41,12 @@ 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 nPropertyIndex = 7; - private const int modelFactorStorageVolumePropertyIndex = 8; - private const int modelFactorCollisionLoadPropertyIndex = 9; - private const int modelFactorLoadEffectPropertyIndex = 10; - private const int modelFactorLongThresholdPropertyIndex = 11; + private const int gravitationalAccelerationPropertyIndex = 5; + private const int nPropertyIndex = 6; + private const int modelFactorStorageVolumePropertyIndex = 7; + private const int modelFactorCollisionLoadPropertyIndex = 8; + private const int modelFactorLoadEffectPropertyIndex = 9; + private const int modelFactorLongThresholdPropertyIndex = 10; /// /// Creates a new instance of . @@ -67,7 +66,6 @@ #region Length effect parameters - [DynamicVisible] [PropertyOrder(nPropertyIndex)] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_DisplayName))] @@ -87,23 +85,6 @@ #endregion - [DynamicVisibleValidationMethod] - public bool DynamicVisibleValidationMethod(string propertyName) - { - return data.IsRelevant || !ShouldHidePropertyWhenFailureMechanismIrrelevant(propertyName); - } - - private bool ShouldHidePropertyWhenFailureMechanismIrrelevant(string propertyName) - { - return nameof(Contribution).Equals(propertyName) - || nameof(N).Equals(propertyName) - || nameof(GravitationalAcceleration).Equals(propertyName) - || nameof(ModelFactorStorageVolume).Equals(propertyName) - || nameof(ModelFactorCollisionLoad).Equals(propertyName) - || nameof(ModelFactorLoadEffect).Equals(propertyName) - || nameof(ModelFactorLongThreshold).Equals(propertyName); - } - #region General [PropertyOrder(namePropertyIndex)] @@ -142,7 +123,6 @@ } } - [DynamicVisible] [PropertyOrder(contributionPropertyIndex)] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Contribution_DisplayName))] @@ -155,19 +135,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))] @@ -184,7 +151,6 @@ #region Model settings - [DynamicVisible] [PropertyOrder(modelFactorStorageVolumePropertyIndex)] [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] @@ -198,7 +164,6 @@ } } - [DynamicVisible] [PropertyOrder(modelFactorCollisionLoadPropertyIndex)] [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] @@ -212,7 +177,6 @@ } } - [DynamicVisible] [PropertyOrder(modelFactorLoadEffectPropertyIndex)] [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] @@ -226,7 +190,6 @@ } } - [DynamicVisible] [PropertyOrder(modelFactorLongThresholdPropertyIndex)] [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] Index: Riskeer/StabilityPointStructures/test/Riskeer.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresCalculationsPropertiesTest.cs =================================================================== diff -u -rb3ce5277a93d67703d2821469ce5871fdf7b53fc -r3d113e20211791ee77497b915bf4f32ad8d4cedd --- Riskeer/StabilityPointStructures/test/Riskeer.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresCalculationsPropertiesTest.cs (.../StabilityPointStructuresCalculationsPropertiesTest.cs) (revision b3ce5277a93d67703d2821469ce5871fdf7b53fc) +++ Riskeer/StabilityPointStructures/test/Riskeer.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresCalculationsPropertiesTest.cs (.../StabilityPointStructuresCalculationsPropertiesTest.cs) (revision 3d113e20211791ee77497b915bf4f32ad8d4cedd) @@ -41,35 +41,29 @@ 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 nPropertyIndex = 6; - private const int modelFactorStorageVolumePropertyIndex = 7; - private const int modelFactorCollisionLoadPropertyIndex = 8; - private const int modelFactorLoadEffectPropertyIndex = 9; - private const int modelFactorLongThresholdPropertyIndex = 10; + private const int gravitationalAccelerationPropertyIndex = 4; + private const int nPropertyIndex = 5; + private const int modelFactorStorageVolumePropertyIndex = 6; + private const int modelFactorCollisionLoadPropertyIndex = 7; + private const int modelFactorLoadEffectPropertyIndex = 8; + private const int modelFactorLongThresholdPropertyIndex = 9; [Test] public void Constructor_DataIsNull_ThrowArgumentNullException() { // Call - TestDelegate test = () => new StabilityPointStructuresCalculationsProperties(null); + void Call() => new StabilityPointStructuresCalculationsProperties(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 StabilityPointStructuresFailureMechanism - { - IsRelevant = isRelevant - }; + var failureMechanism = new StabilityPointStructuresFailureMechanism(); // Call var properties = new StabilityPointStructuresCalculationsProperties(failureMechanism); @@ -81,7 +75,6 @@ Assert.AreEqual(failureMechanism.Code, properties.Code); Assert.AreEqual(failureMechanism.Group, properties.Group); Assert.AreEqual(failureMechanism.Contribution, properties.Contribution); - Assert.AreEqual(isRelevant, properties.IsRelevant); GeneralStabilityPointStructuresInput generalInput = failureMechanism.GeneralInput; Assert.AreEqual(generalInput.N, properties.N); @@ -97,13 +90,10 @@ } [Test] - public void Constructor_IsRelevantTrue_PropertiesHaveExpectedAttributesValues() + public void Constructor_Always_PropertiesHaveExpectedAttributeValues() { // Setup - var failureMechanism = new StabilityPointStructuresFailureMechanism - { - IsRelevant = true - }; + var failureMechanism = new StabilityPointStructuresFailureMechanism(); // Call var properties = new StabilityPointStructuresCalculationsProperties(failureMechanism); @@ -114,7 +104,7 @@ const string modelSettingsCategory = "Modelinstellingen"; PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(11, dynamicProperties.Count); + Assert.AreEqual(10, dynamicProperties.Count); PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, @@ -144,13 +134,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, @@ -198,53 +181,6 @@ } [Test] - public void Constructor_IsRelevantFalse_PropertiesHaveExpectedAttributesValues() - { - // Setup - var failureMechanism = new StabilityPointStructuresFailureMechanism - { - IsRelevant = false - }; - - // Call - var properties = new StabilityPointStructuresCalculationsProperties(failureMechanism); - - // 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] [SetCulture("nl-NL")] [TestCase(0.0)] [TestCase(-1.0)] @@ -262,11 +198,11 @@ var properties = new StabilityPointStructuresCalculationsProperties(failureMechanism); // Call - TestDelegate test = () => properties.N = (RoundedDouble) value; + void Call() => properties.N = (RoundedDouble) value; // Assert const string expectedMessage = "De waarde voor 'N' moet in het bereik [1,00, 20,00] liggen."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage); mockRepository.VerifyAll(); } @@ -294,34 +230,5 @@ Assert.AreEqual(value, failureMechanism.GeneralInput.N, failureMechanism.GeneralInput.N.GetAccuracy()); mockRepository.VerifyAll(); } - - [Test] - [TestCase(true)] - [TestCase(false)] - public void DynamicVisibleValidationMethod_DependingOnRelevancy_ReturnExpectedVisibility(bool isRelevant) - { - // Setup - var properties = new StabilityPointStructuresCalculationsProperties( - new StabilityPointStructuresFailureMechanism - { - 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.N))); - Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.GravitationalAcceleration))); - Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.ModelFactorStorageVolume))); - Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.ModelFactorCollisionLoad))); - Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.ModelFactorLoadEffect))); - Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.ModelFactorLongThreshold))); - - Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); - } } } \ No newline at end of file