Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsCalculationsProperties.cs =================================================================== diff -u -ra0a47e24c45537d82a6d1c7c3b402b1554b90b76 -rc651311c5ef3b1c5fe904e3c40e278634fc2b982 --- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsCalculationsProperties.cs (.../GrassCoverErosionInwardsCalculationsProperties.cs) (revision a0a47e24c45537d82a6d1c7c3b402b1554b90b76) +++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsCalculationsProperties.cs (.../GrassCoverErosionInwardsCalculationsProperties.cs) (revision c651311c5ef3b1c5fe904e3c40e278634fc2b982) @@ -20,10 +20,7 @@ // All rights reserved. using System; -using System.Collections.Generic; using System.ComponentModel; -using Core.Common.Base; -using Core.Common.Base.Data; using Core.Common.Util.Attributes; using Core.Gui.Attributes; using Riskeer.Common.Forms.PropertyClasses; @@ -65,55 +62,6 @@ NPropertyIndex = nPropertyIndex }, handler) {} - #region General - - [PropertyOrder(contributionPropertyIndex)] - [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] - [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Contribution_DisplayName))] - [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Contribution_Description))] - public override double Contribution - { - get - { - return data.Contribution; - } - } - - #endregion - - #region Length effect parameters - - [PropertyOrder(nPropertyIndex)] - [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] - [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Rounded_DisplayName))] - [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Rounded_Description))] - public override RoundedDouble N - { - get - { - return data.GeneralInput.N; - } - set - { - IEnumerable affectedObjects = PropertyChangeHandler.SetPropertyValueAfterConfirmation( - data, - value, - (f, v) => f.GeneralInput.N = v); - - NotifyAffectedObjects(affectedObjects); - } - } - - #endregion - - private static void NotifyAffectedObjects(IEnumerable affectedObjects) - { - foreach (IObservable affectedObject in affectedObjects) - { - affectedObject.NotifyObservers(); - } - } - #region Model settings [PropertyOrder(frunupModelFactorPropertyIndex)] Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismProperties.cs =================================================================== diff -u -r76ca607ca231c957521cadea351327f39152c51a -rc651311c5ef3b1c5fe904e3c40e278634fc2b982 --- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismProperties.cs (.../GrassCoverErosionInwardsFailureMechanismProperties.cs) (revision 76ca607ca231c957521cadea351327f39152c51a) +++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismProperties.cs (.../GrassCoverErosionInwardsFailureMechanismProperties.cs) (revision c651311c5ef3b1c5fe904e3c40e278634fc2b982) @@ -95,7 +95,7 @@ [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Rounded_DisplayName))] [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Rounded_Description))] - public virtual RoundedDouble N + public RoundedDouble N { get { @@ -216,7 +216,7 @@ [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Contribution_DisplayName))] [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Contribution_Description))] - public virtual double Contribution + public double Contribution { get { Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailurePathProperties.cs =================================================================== diff -u -r0ee601b1ff879629bf44d12397d43c9cae8353a8 -rc651311c5ef3b1c5fe904e3c40e278634fc2b982 --- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailurePathProperties.cs (.../GrassCoverErosionInwardsFailurePathProperties.cs) (revision 0ee601b1ff879629bf44d12397d43c9cae8353a8) +++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailurePathProperties.cs (.../GrassCoverErosionInwardsFailurePathProperties.cs) (revision c651311c5ef3b1c5fe904e3c40e278634fc2b982) @@ -20,11 +20,6 @@ // All rights reserved. using System; -using System.Collections.Generic; -using Core.Common.Base; -using Core.Common.Base.Data; -using Core.Common.Util.Attributes; -using Core.Gui.Attributes; using Riskeer.Common.Forms.PropertyClasses; using Riskeer.GrassCoverErosionInwards.Data; using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; @@ -40,8 +35,7 @@ private const int codePropertyIndex = 2; private const int groupPropertyIndex = 3; private const int contributionPropertyIndex = 4; - private const int isRelevantPropertyIndex = 5; - private const int nPropertyIndex = 6; + private const int nPropertyIndex = 5; /// /// Creates a new instance of . @@ -60,85 +54,5 @@ ContributionPropertyIndex = contributionPropertyIndex, NPropertyIndex = nPropertyIndex }, handler) {} - - #region Length effect parameters - - [DynamicVisible] - [PropertyOrder(nPropertyIndex)] - [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] - [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Rounded_DisplayName))] - [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Rounded_Description))] - public override RoundedDouble N - { - get - { - return data.GeneralInput.N; - } - set - { - IEnumerable affectedObjects = PropertyChangeHandler.SetPropertyValueAfterConfirmation( - data, - value, - (f, v) => f.GeneralInput.N = v); - - NotifyAffectedObjects(affectedObjects); - } - } - - #endregion - - [DynamicVisibleValidationMethod] - public bool DynamicVisibleValidationMethod(string propertyName) - { - if (!data.IsRelevant && ShouldHidePropertyWhenFailureMechanismIrrelevant(propertyName)) - { - return false; - } - - return true; - } - - private static void NotifyAffectedObjects(IEnumerable affectedObjects) - { - foreach (IObservable affectedObject in affectedObjects) - { - affectedObject.NotifyObservers(); - } - } - - private bool ShouldHidePropertyWhenFailureMechanismIrrelevant(string propertyName) - { - return nameof(Contribution).Equals(propertyName) - || nameof(N).Equals(propertyName); - } - - #region General - - [DynamicVisible] - [PropertyOrder(contributionPropertyIndex)] - [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] - [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Contribution_DisplayName))] - [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Contribution_Description))] - public override double Contribution - { - get - { - return data.Contribution; - } - } - - [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; - } - } - - #endregion } } \ No newline at end of file Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailurePathPropertiesTest.cs =================================================================== diff -u -r84cafd0cedf35bd50dbe6fbc2b376e7217fa3fce -rc651311c5ef3b1c5fe904e3c40e278634fc2b982 --- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailurePathPropertiesTest.cs (.../GrassCoverErosionInwardsFailurePathPropertiesTest.cs) (revision 84cafd0cedf35bd50dbe6fbc2b376e7217fa3fce) +++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailurePathPropertiesTest.cs (.../GrassCoverErosionInwardsFailurePathPropertiesTest.cs) (revision c651311c5ef3b1c5fe904e3c40e278634fc2b982) @@ -42,8 +42,7 @@ private const int codePropertyIndex = 1; private const int groupPropertyIndex = 2; private const int contributionPropertyIndex = 3; - private const int isRelevantPropertyIndex = 4; - private const int nPropertyIndex = 5; + private const int nPropertyIndex = 4; private MockRepository mocks; [SetUp] @@ -59,19 +58,14 @@ } [Test] - [TestCase(true)] - [TestCase(false)] - public void Constructor_ExpectedValues(bool isRelevant) + public void Constructor_ExpectedValues() { // Setup var handler = mocks.Stub>(); mocks.ReplayAll(); - - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism - { - IsRelevant = isRelevant - }; + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + // Call var properties = new GrassCoverErosionInwardsFailurePathProperties(failureMechanism, handler); @@ -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); GeneralGrassCoverErosionInwardsInput generalInput = failureMechanism.GeneralInput; Assert.AreEqual(2, properties.N.NumberOfDecimalPlaces); @@ -91,13 +84,10 @@ } [Test] - public void Constructor_IsRelevantTrue_PropertiesHaveExpectedAttributesValues() + public void Constructor_Always_PropertiesHaveExpectedAttributesValues() { // Setup - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism - { - IsRelevant = true - }; + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var handler = mocks.Stub>(); mocks.ReplayAll(); @@ -107,7 +97,7 @@ // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(6, dynamicProperties.Count); + Assert.AreEqual(5, dynamicProperties.Count); const string generalCategory = "Algemeen"; const string lengthEffectCategory = "Lengte-effect parameters"; @@ -140,13 +130,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 nProperty = dynamicProperties[nPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nProperty, lengthEffectCategory, @@ -155,56 +138,6 @@ } [Test] - public void Constructor_IsRelevantFalse_PropertiesHaveExpectedAttributesValues() - { - // Setup - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism - { - IsRelevant = false - }; - - var handler = mocks.Stub>(); - mocks.ReplayAll(); - - // Call - var properties = new GrassCoverErosionInwardsFailurePathProperties(failureMechanism, handler); - - // Assert - PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(4, dynamicProperties.Count); - - const string generalCategory = "Algemeen"; - - PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, - generalCategory, - "Naam", - "De naam van het toetsspoor.", - true); - - PropertyDescriptor labelProperty = dynamicProperties[codePropertyIndex]; - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(labelProperty, - 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)] @@ -264,32 +197,5 @@ Assert.AreEqual(newN, failureMechanism.GeneralInput.N, failureMechanism.GeneralInput.N.GetAccuracy()); Assert.IsTrue(handler.Called); } - - [Test] - [TestCase(true)] - [TestCase(false)] - public void DynamicVisibleValidationMethod_DependingOnRelevancy_ReturnExpectedVisibility(bool isRelevant) - { - // Setup - var handler = mocks.Stub>(); - mocks.ReplayAll(); - - var grassCoverErosionInwardsFailureMechanism = new GrassCoverErosionInwardsFailureMechanism - { - IsRelevant = isRelevant - }; - var properties = new GrassCoverErosionInwardsFailurePathProperties(grassCoverErosionInwardsFailureMechanism, handler); - - // 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.IsTrue(properties.DynamicVisibleValidationMethod(null)); - } } } \ No newline at end of file