Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsCalculationsProperties.cs
===================================================================
diff -u -rc651311c5ef3b1c5fe904e3c40e278634fc2b982 -rf8f5e16d7d085078980f65e5966cb35d4b4017b1
--- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsCalculationsProperties.cs (.../GrassCoverErosionInwardsCalculationsProperties.cs) (revision c651311c5ef3b1c5fe904e3c40e278634fc2b982)
+++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsCalculationsProperties.cs (.../GrassCoverErosionInwardsCalculationsProperties.cs) (revision f8f5e16d7d085078980f65e5966cb35d4b4017b1)
@@ -38,29 +38,23 @@
private const int namePropertyIndex = 1;
private const int codePropertyIndex = 2;
private const int groupPropertyIndex = 3;
- private const int contributionPropertyIndex = 4;
- private const int nPropertyIndex = 5;
- private const int frunupModelFactorPropertyIndex = 6;
- private const int fbFactorPropertyIndex = 7;
- private const int fnFactorPropertyIndex = 8;
- private const int fshallowModelFactorPropertyIndex = 9;
+ private const int frunupModelFactorPropertyIndex = 4;
+ private const int fbFactorPropertyIndex = 5;
+ private const int fnFactorPropertyIndex = 6;
+ private const int fshallowModelFactorPropertyIndex = 7;
///
/// Creates a new instance of .
///
/// The instance to show the properties of.
- /// Handler responsible for handling effects of a property change.
/// Thrown when any parameter is null.
public GrassCoverErosionInwardsCalculationsProperties(
- GrassCoverErosionInwardsFailureMechanism data,
- IFailureMechanismPropertyChangeHandler handler) : base(data, new ConstructionProperties
+ GrassCoverErosionInwardsFailureMechanism data) : base(data, new ConstructionProperties
{
NamePropertyIndex = namePropertyIndex,
CodePropertyIndex = codePropertyIndex,
- GroupPropertyIndex = groupPropertyIndex,
- ContributionPropertyIndex = contributionPropertyIndex,
- NPropertyIndex = nPropertyIndex
- }, handler) {}
+ GroupPropertyIndex = groupPropertyIndex
+ }) {}
#region Model settings
Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismProperties.cs
===================================================================
diff -u -ra6b25485107819b4f25c58cf768fd647b67fcb5d -rf8f5e16d7d085078980f65e5966cb35d4b4017b1
--- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismProperties.cs (.../GrassCoverErosionInwardsFailureMechanismProperties.cs) (revision a6b25485107819b4f25c58cf768fd647b67fcb5d)
+++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismProperties.cs (.../GrassCoverErosionInwardsFailureMechanismProperties.cs) (revision f8f5e16d7d085078980f65e5966cb35d4b4017b1)
@@ -21,12 +21,9 @@
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 Core.Gui.PropertyBag;
-using Riskeer.Common.Forms.PropertyClasses;
using Riskeer.GrassCoverErosionInwards.Data;
using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources;
@@ -38,19 +35,16 @@
public class GrassCoverErosionInwardsFailureMechanismProperties : ObjectProperties
{
private readonly Dictionary propertyIndexLookup;
- private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler;
///
/// Creates a new instance of .
///
/// The instance to show the properties of.
/// The property values required to create an instance of .
- /// Handler responsible for handling effects of a property change.
/// Thrown when any parameter is null.
public GrassCoverErosionInwardsFailureMechanismProperties(
GrassCoverErosionInwardsFailureMechanism data,
- ConstructionProperties constructionProperties,
- IFailureMechanismPropertyChangeHandler handler)
+ ConstructionProperties constructionProperties)
{
if (data == null)
{
@@ -62,13 +56,7 @@
throw new ArgumentNullException(nameof(constructionProperties));
}
- if (handler == null)
- {
- throw new ArgumentNullException(nameof(handler));
- }
-
Data = data;
- propertyChangeHandler = handler;
propertyIndexLookup = new Dictionary
{
@@ -80,41 +68,10 @@
},
{
nameof(Group), constructionProperties.GroupPropertyIndex
- },
- {
- nameof(Contribution), constructionProperties.ContributionPropertyIndex
- },
- {
- nameof(N), constructionProperties.NPropertyIndex
}
};
}
- #region Length effect parameters
-
- [DynamicPropertyOrder]
- [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))]
- [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_DisplayName))]
- [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Description))]
- public RoundedDouble N
- {
- get
- {
- return data.GeneralInput.N;
- }
- set
- {
- IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation(
- data,
- value,
- (f, v) => f.GeneralInput.N = v);
-
- NotifyAffectedObjects(affectedObjects);
- }
- }
-
- #endregion
-
[DynamicPropertyOrderEvaluationMethod]
public int DynamicPropertyOrderEvaluationMethod(string propertyName)
{
@@ -123,28 +80,11 @@
return propertyIndex;
}
- private static void NotifyAffectedObjects(IEnumerable affectedObjects)
- {
- foreach (IObservable affectedObject in affectedObjects)
- {
- affectedObject.NotifyObservers();
- }
- }
-
///
/// Class holding the various construction parameters for .
///
public class ConstructionProperties
{
- #region Length effect parameters
-
- ///
- /// Gets or sets the property index for .
- ///
- public int NPropertyIndex { get; set; }
-
- #endregion
-
#region General
///
@@ -162,11 +102,6 @@
///
public int GroupPropertyIndex { get; set; }
- ///
- /// Gets or sets the property index for .
- ///
- public int ContributionPropertyIndex { get; set; }
-
#endregion
}
@@ -208,18 +143,6 @@
}
}
- [DynamicPropertyOrder]
- [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))]
- [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Contribution_DisplayName))]
- [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Contribution_Description))]
- public double Contribution
- {
- get
- {
- return data.Contribution;
- }
- }
-
#endregion
}
}
\ No newline at end of file
Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailurePathProperties.cs
===================================================================
diff -u -r0c8a4bf7e725ad5c811357e384b95b5f474a2d2e -rf8f5e16d7d085078980f65e5966cb35d4b4017b1
--- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailurePathProperties.cs (.../GrassCoverErosionInwardsFailurePathProperties.cs) (revision 0c8a4bf7e725ad5c811357e384b95b5f474a2d2e)
+++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailurePathProperties.cs (.../GrassCoverErosionInwardsFailurePathProperties.cs) (revision f8f5e16d7d085078980f65e5966cb35d4b4017b1)
@@ -20,6 +20,11 @@
// 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;
@@ -36,6 +41,7 @@
private const int groupPropertyIndex = 3;
private const int contributionPropertyIndex = 4;
private const int nPropertyIndex = 5;
+ private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler;
///
/// Creates a new instance of .
@@ -50,9 +56,64 @@
{
NamePropertyIndex = namePropertyIndex,
CodePropertyIndex = codePropertyIndex,
- GroupPropertyIndex = groupPropertyIndex,
- ContributionPropertyIndex = contributionPropertyIndex,
- NPropertyIndex = nPropertyIndex
- }, handler) {}
+ GroupPropertyIndex = groupPropertyIndex
+ })
+ {
+ if (handler == null)
+ {
+ throw new ArgumentNullException(nameof(handler));
+ }
+
+ propertyChangeHandler = 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 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_DisplayName))]
+ [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Description))]
+ public 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();
+ }
+ }
}
}
\ No newline at end of file
Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs
===================================================================
diff -u -rb19e3e1a5ccd0526b80b9a40d51c90e617a44a4d -rf8f5e16d7d085078980f65e5966cb35d4b4017b1
--- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision b19e3e1a5ccd0526b80b9a40d51c90e617a44a4d)
+++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision f8f5e16d7d085078980f65e5966cb35d4b4017b1)
@@ -72,8 +72,7 @@
yield return new PropertyInfo
{
CreateInstance = context => new GrassCoverErosionInwardsCalculationsProperties(
- context.WrappedData,
- new FailureMechanismPropertyChangeHandler())
+ context.WrappedData)
};
yield return new PropertyInfo
{
Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsCalculationsPropertiesTest.cs
===================================================================
diff -u -r0c8a4bf7e725ad5c811357e384b95b5f474a2d2e -rf8f5e16d7d085078980f65e5966cb35d4b4017b1
--- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsCalculationsPropertiesTest.cs (.../GrassCoverErosionInwardsCalculationsPropertiesTest.cs) (revision 0c8a4bf7e725ad5c811357e384b95b5f474a2d2e)
+++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsCalculationsPropertiesTest.cs (.../GrassCoverErosionInwardsCalculationsPropertiesTest.cs) (revision f8f5e16d7d085078980f65e5966cb35d4b4017b1)
@@ -22,9 +22,6 @@
using System.ComponentModel;
using Core.Gui.TestUtil;
using NUnit.Framework;
-using Rhino.Mocks;
-using Riskeer.Common.Data.TestUtil;
-using Riskeer.Common.Forms.PropertyClasses;
using Riskeer.GrassCoverErosionInwards.Data;
using Riskeer.GrassCoverErosionInwards.Forms.PropertyClasses;
@@ -36,52 +33,29 @@
private const int namePropertyIndex = 0;
private const int codePropertyIndex = 1;
private const int groupPropertyIndex = 2;
- private const int contributionPropertyIndex = 3;
- private const int nPropertyIndex = 4;
- private const int frunupModelFactorPropertyIndex = 5;
- private const int fbFactorPropertyIndex = 6;
- private const int fnFactorPropertyIndex = 7;
- private const int fshallowModelFactorPropertyIndex = 8;
- private MockRepository mocks;
+ private const int frunupModelFactorPropertyIndex = 3;
+ private const int fbFactorPropertyIndex = 4;
+ private const int fnFactorPropertyIndex = 5;
+ private const int fshallowModelFactorPropertyIndex = 6;
- [SetUp]
- public void SetUp()
- {
- mocks = new MockRepository();
- }
-
- [TearDown]
- public void TearDown()
- {
- mocks.VerifyAll();
- }
-
[Test]
public void Constructor_ExpectedValues()
{
// Setup
- var handler = mocks.Stub>();
- mocks.ReplayAll();
-
var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
// Call
var properties = new GrassCoverErosionInwardsCalculationsProperties(
- failureMechanism,
- handler);
+ failureMechanism);
// Assert
Assert.IsInstanceOf(properties);
Assert.AreEqual(failureMechanism.Name, properties.Name);
Assert.AreEqual(failureMechanism.Code, properties.Code);
Assert.AreEqual(failureMechanism.Group, properties.Group);
- Assert.AreEqual(failureMechanism.Contribution, properties.Contribution);
GeneralGrassCoverErosionInwardsInput generalInput = failureMechanism.GeneralInput;
- Assert.AreEqual(2, properties.N.NumberOfDecimalPlaces);
- Assert.AreEqual(generalInput.N, properties.N, properties.N.GetAccuracy());
-
Assert.AreEqual(generalInput.FbFactor.Mean, properties.FbFactor.Mean);
Assert.AreEqual(generalInput.FbFactor.StandardDeviation, properties.FbFactor.StandardDeviation);
@@ -99,23 +73,18 @@
public void Constructor_Always_PropertiesHaveExpectedAttributeValues()
{
// Setup
- var handler = mocks.Stub>();
- mocks.ReplayAll();
-
var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
// Call
var properties = new GrassCoverErosionInwardsCalculationsProperties(
- failureMechanism,
- handler);
+ failureMechanism);
// Assert
const string generalCategory = "Algemeen";
- const string lengthEffectCategory = "Lengte-effect parameters";
const string modelSettingsCategory = "Modelinstellingen";
PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);
- Assert.AreEqual(9, dynamicProperties.Count);
+ Assert.AreEqual(7, dynamicProperties.Count);
PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex];
PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty,
@@ -138,19 +107,6 @@
"De groep waar het toetsspoor toe behoort.",
true);
- PropertyDescriptor contributionProperty = dynamicProperties[contributionPropertyIndex];
- PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(contributionProperty,
- generalCategory,
- "Faalkansbijdrage [%]",
- "Procentuele bijdrage van dit toetsspoor aan de totale overstromingskans van het traject.",
- true);
-
- PropertyDescriptor nProperty = dynamicProperties[nPropertyIndex];
- PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nProperty,
- lengthEffectCategory,
- "N [-]",
- "De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in de beoordeling.");
-
PropertyDescriptor frunupModelFactorProperty = dynamicProperties[frunupModelFactorPropertyIndex];
Assert.IsInstanceOf(frunupModelFactorProperty.Converter);
PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(frunupModelFactorProperty,
Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailureMechanismPropertiesTest.cs
===================================================================
diff -u -rc44732002616533479567b2bbacf37431344309f -rf8f5e16d7d085078980f65e5966cb35d4b4017b1
--- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailureMechanismPropertiesTest.cs (.../GrassCoverErosionInwardsFailureMechanismPropertiesTest.cs) (revision c44732002616533479567b2bbacf37431344309f)
+++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailureMechanismPropertiesTest.cs (.../GrassCoverErosionInwardsFailureMechanismPropertiesTest.cs) (revision f8f5e16d7d085078980f65e5966cb35d4b4017b1)
@@ -21,16 +21,9 @@
using System;
using System.ComponentModel;
-using Core.Common.Base;
-using Core.Common.Base.Data;
-using Core.Common.TestUtil;
using Core.Gui.PropertyBag;
using Core.Gui.TestUtil;
using NUnit.Framework;
-using Rhino.Mocks;
-using Riskeer.Common.Data.TestUtil;
-using Riskeer.Common.Forms.PropertyClasses;
-using Riskeer.Common.Forms.TestUtil;
using Riskeer.GrassCoverErosionInwards.Data;
using Riskeer.GrassCoverErosionInwards.Forms.PropertyClasses;
@@ -39,34 +32,15 @@
[TestFixture]
public class GrassCoverErosionInwardsFailureMechanismPropertiesTest
{
- private const int namePropertyIndex = 4;
- private const int codePropertyIndex = 3;
- private const int groupPropertyIndex = 2;
- private const int contributionPropertyIndex = 1;
- private const int nPropertyIndex = 0;
- private MockRepository mocks;
+ private const int namePropertyIndex = 2;
+ private const int codePropertyIndex = 1;
+ private const int groupPropertyIndex = 0;
- [SetUp]
- public void SetUp()
- {
- mocks = new MockRepository();
- }
-
- [TearDown]
- public void TearDown()
- {
- mocks.VerifyAll();
- }
-
[Test]
public void Constructor_DataNull_ThrowArgumentNullException()
{
- // Setup
- var handler = mocks.Stub>();
- mocks.ReplayAll();
-
// Call
- void Call() => new GrassCoverErosionInwardsFailureMechanismProperties(null, new GrassCoverErosionInwardsFailureMechanismProperties.ConstructionProperties(), handler);
+ void Call() => new GrassCoverErosionInwardsFailureMechanismProperties(null, new GrassCoverErosionInwardsFailureMechanismProperties.ConstructionProperties());
// Assert
var exception = Assert.Throws(Call);
@@ -76,79 +50,49 @@
[Test]
public void Constructor_ConstructionPropertiesNull_ThrowsArgumentNullException()
{
- // Setup
- var handler = mocks.Stub>();
- mocks.ReplayAll();
-
// Call
- void Call() => new GrassCoverErosionInwardsFailureMechanismProperties(new GrassCoverErosionInwardsFailureMechanism(), null, handler);
+ void Call() => new GrassCoverErosionInwardsFailureMechanismProperties(new GrassCoverErosionInwardsFailureMechanism(), null);
// Assert
var exception = Assert.Throws(Call);
Assert.AreEqual("constructionProperties", exception.ParamName);
}
[Test]
- public void Constructor_ChangeHandlerNull_ThrowsArgumentNullException()
- {
- // Call
- void Call() => new GrassCoverErosionInwardsFailureMechanismProperties(new GrassCoverErosionInwardsFailureMechanism(), new GrassCoverErosionInwardsFailureMechanismProperties.ConstructionProperties(), null);
-
- // Assert
- var exception = Assert.Throws(Call);
- Assert.AreEqual("handler", exception.ParamName);
- }
-
- [Test]
public void Constructor_ExpectedValues()
{
// Setup
- var handler = mocks.Stub>();
- mocks.ReplayAll();
-
var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
// Call
- var properties = new GrassCoverErosionInwardsFailureMechanismProperties(failureMechanism, new GrassCoverErosionInwardsFailureMechanismProperties.ConstructionProperties(), handler);
+ var properties = new GrassCoverErosionInwardsFailureMechanismProperties(failureMechanism, new GrassCoverErosionInwardsFailureMechanismProperties.ConstructionProperties());
// Assert
Assert.IsInstanceOf>(properties);
Assert.AreEqual(failureMechanism.Name, properties.Name);
Assert.AreEqual(failureMechanism.Code, properties.Code);
Assert.AreEqual(failureMechanism.Group, properties.Group);
- Assert.AreEqual(failureMechanism.Contribution, properties.Contribution);
-
- Assert.AreEqual(2, properties.N.NumberOfDecimalPlaces);
- Assert.AreEqual(failureMechanism.GeneralInput.N,
- properties.N,
- properties.N.GetAccuracy());
}
[Test]
public void Constructor_Always_PropertiesHaveExpectedAttributeValues()
{
// Setup
- var handler = mocks.Stub>();
- mocks.ReplayAll();
-
var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
// Call
var properties = new GrassCoverErosionInwardsFailureMechanismProperties(failureMechanism, new GrassCoverErosionInwardsFailureMechanismProperties.ConstructionProperties
{
NamePropertyIndex = namePropertyIndex,
CodePropertyIndex = codePropertyIndex,
- GroupPropertyIndex = groupPropertyIndex,
- ContributionPropertyIndex = contributionPropertyIndex,
- NPropertyIndex = nPropertyIndex
- }, handler);
+ GroupPropertyIndex = groupPropertyIndex
+ });
// Assert
PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);
- Assert.AreEqual(5, dynamicProperties.Count);
+ Assert.AreEqual(3, dynamicProperties.Count);
const string generalCategory = "Algemeen";
- const string lengthEffectCategory = "Lengte-effect parameters";
PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex];
PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty,
@@ -170,84 +114,6 @@
"Groep",
"De groep waar het toetsspoor toe behoort.",
true);
-
- PropertyDescriptor contributionProperty = dynamicProperties[contributionPropertyIndex];
- PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(contributionProperty,
- generalCategory,
- "Faalkansbijdrage [%]",
- "Procentuele bijdrage van dit toetsspoor aan de totale overstromingskans van het traject.",
- true);
-
- PropertyDescriptor nProperty = dynamicProperties[nPropertyIndex];
- PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nProperty,
- lengthEffectCategory,
- "N [-]",
- "De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in de beoordeling.");
}
-
- [Test]
- [SetCulture("nl-NL")]
- [TestCase(0.0)]
- [TestCase(-1.0)]
- [TestCase(-20.0)]
- public void N_SetInvalidValue_ThrowsArgumentOutOfRangeExceptionNoNotifications(double newN)
- {
- // Setup
- var observable = mocks.StrictMock();
- mocks.ReplayAll();
-
- var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
- var changeHandler = new FailureMechanismSetPropertyValueAfterConfirmationParameterTester(
- failureMechanism,
- newN,
- new[]
- {
- observable
- });
-
- var properties = new GrassCoverErosionInwardsCalculationsProperties(
- failureMechanism,
- changeHandler);
-
- // Call
- void Call() => properties.N = (RoundedDouble) newN;
-
- // Assert
- const string expectedMessage = "De waarde voor 'N' moet in het bereik [1,00, 20,00] liggen.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage);
- Assert.IsTrue(changeHandler.Called);
- }
-
- [Test]
- [TestCase(1.0)]
- [TestCase(10.0)]
- [TestCase(20.0)]
- public void N_SetValidValue_UpdateDataAndNotifyObservers(double newN)
- {
- // Setup
- var observable = mocks.StrictMock();
- observable.Expect(o => o.NotifyObservers());
- mocks.ReplayAll();
-
- var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
- var changeHandler = new FailureMechanismSetPropertyValueAfterConfirmationParameterTester(
- failureMechanism,
- newN,
- new[]
- {
- observable
- });
-
- var properties = new GrassCoverErosionInwardsCalculationsProperties(
- failureMechanism,
- changeHandler);
-
- // Call
- properties.N = (RoundedDouble) newN;
-
- // Assert
- Assert.AreEqual(newN, failureMechanism.GeneralInput.N);
- Assert.IsTrue(changeHandler.Called);
- }
}
}
\ No newline at end of file
Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailurePathPropertiesTest.cs
===================================================================
diff -u -r0c8a4bf7e725ad5c811357e384b95b5f474a2d2e -rf8f5e16d7d085078980f65e5966cb35d4b4017b1
--- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailurePathPropertiesTest.cs (.../GrassCoverErosionInwardsFailurePathPropertiesTest.cs) (revision 0c8a4bf7e725ad5c811357e384b95b5f474a2d2e)
+++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailurePathPropertiesTest.cs (.../GrassCoverErosionInwardsFailurePathPropertiesTest.cs) (revision f8f5e16d7d085078980f65e5966cb35d4b4017b1)
@@ -19,12 +19,17 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.ComponentModel;
+using Core.Common.Base;
+using Core.Common.Base.Data;
+using Core.Common.TestUtil;
using Core.Gui.TestUtil;
using NUnit.Framework;
using Rhino.Mocks;
using Riskeer.Common.Data.TestUtil;
using Riskeer.Common.Forms.PropertyClasses;
+using Riskeer.Common.Forms.TestUtil;
using Riskeer.GrassCoverErosionInwards.Data;
using Riskeer.GrassCoverErosionInwards.Forms.PropertyClasses;
@@ -38,24 +43,23 @@
private const int groupPropertyIndex = 2;
private const int contributionPropertyIndex = 3;
private const int nPropertyIndex = 4;
- private MockRepository mocks;
- [SetUp]
- public void SetUp()
+ [Test]
+ public void Constructor_ChangeHandlerNull_ThrowsArgumentNullException()
{
- mocks = new MockRepository();
- }
+ // Call
+ void Call() => new GrassCoverErosionInwardsFailurePathProperties(new GrassCoverErosionInwardsFailureMechanism(), null);
- [TearDown]
- public void TearDown()
- {
- mocks.VerifyAll();
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("handler", exception.ParamName);
}
[Test]
public void Constructor_ExpectedValues()
{
// Setup
+ var mocks = new MockRepository();
var handler = mocks.Stub>();
mocks.ReplayAll();
@@ -76,12 +80,15 @@
Assert.AreEqual(generalInput.N,
properties.N,
properties.N.GetAccuracy());
+
+ mocks.VerifyAll();
}
[Test]
public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
{
// Setup
+ var mocks = new MockRepository();
var handler = mocks.Stub>();
mocks.ReplayAll();
@@ -130,6 +137,78 @@
lengthEffectCategory,
"N [-]",
"De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in de beoordeling.");
+ mocks.VerifyAll();
}
+
+ [Test]
+ [SetCulture("nl-NL")]
+ [TestCase(0.0)]
+ [TestCase(-1.0)]
+ [TestCase(-20.0)]
+ public void N_SetInvalidValue_ThrowsArgumentOutOfRangeExceptionNoNotifications(double newN)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var observable = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ var changeHandler = new FailureMechanismSetPropertyValueAfterConfirmationParameterTester(
+ failureMechanism,
+ newN,
+ new[]
+ {
+ observable
+ });
+
+ var properties = new GrassCoverErosionInwardsFailurePathProperties(
+ failureMechanism,
+ changeHandler);
+
+ // Call
+ void Call() => properties.N = (RoundedDouble) newN;
+
+ // Assert
+ const string expectedMessage = "De waarde voor 'N' moet in het bereik [1,00, 20,00] liggen.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage);
+ Assert.IsTrue(changeHandler.Called);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(1.0)]
+ [TestCase(10.0)]
+ [TestCase(20.0)]
+ public void N_SetValidValue_UpdateDataAndNotifyObservers(double newN)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var observable = mocks.StrictMock();
+ observable.Expect(o => o.NotifyObservers());
+ mocks.ReplayAll();
+
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ var changeHandler = new FailureMechanismSetPropertyValueAfterConfirmationParameterTester(
+ failureMechanism,
+ newN,
+ new[]
+ {
+ observable
+ });
+
+ var properties = new GrassCoverErosionInwardsFailurePathProperties(
+ failureMechanism,
+ changeHandler);
+
+ // Call
+ properties.N = (RoundedDouble) newN;
+
+ // Assert
+ Assert.AreEqual(newN, failureMechanism.GeneralInput.N);
+ Assert.IsTrue(changeHandler.Called);
+
+ mocks.VerifyAll();
+ }
}
}
\ No newline at end of file