Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ConfirmingUseForeshoreProperties.cs
===================================================================
diff -u -rf8998df0ea8c1228216bbb00ed9178058af4af67 -r662e55f5b46d01f77a977ab0ea92acbbaddf2365
--- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ConfirmingUseForeshoreProperties.cs (.../ConfirmingUseForeshoreProperties.cs) (revision f8998df0ea8c1228216bbb00ed9178058af4af67)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ConfirmingUseForeshoreProperties.cs (.../ConfirmingUseForeshoreProperties.cs) (revision 662e55f5b46d01f77a977ab0ea92acbbaddf2365)
@@ -37,32 +37,30 @@
///
/// ViewModel of .
///
- public class ConfirmingUseForeshoreProperties
- where TCalculation : ICalculation
- where TCalculationInput : ICalculationInput, IUseForeshore
+ public class ConfirmingUseForeshoreProperties where TCalculationInput : ICalculationInput, IUseForeshore
{
private const int useForeshorePropertyIndex = 1;
private const int coordinatesPropertyIndex = 2;
private readonly TCalculationInput data;
private readonly ICalculationInputPropertyChangeHandler changeHandler;
- private readonly TCalculation calculation;
+ private readonly ICalculation calculation;
///
- /// Creates a new instance of , in which
+ /// Creates a new instance of , in which
/// all the properties are read only.
///
public ConfirmingUseForeshoreProperties() { }
///
- /// Creates a new instance of .
+ /// Creates a new instance of .
///
/// The data to use for the properties.
/// The calculation to which the belongs.
/// Optional handler that is used to handle property changes.
/// Thrown when any input parameter is null.
public ConfirmingUseForeshoreProperties(
TCalculationInput useForeshoreData,
- TCalculation calculation,
+ ICalculation calculation,
ICalculationInputPropertyChangeHandler handler)
{
if (useForeshoreData == null)
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/ConfirmingUseForeshorePropertiesTest.cs
===================================================================
diff -u -rf8998df0ea8c1228216bbb00ed9178058af4af67 -r662e55f5b46d01f77a977ab0ea92acbbaddf2365
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/ConfirmingUseForeshorePropertiesTest.cs (.../ConfirmingUseForeshorePropertiesTest.cs) (revision f8998df0ea8c1228216bbb00ed9178058af4af67)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/ConfirmingUseForeshorePropertiesTest.cs (.../ConfirmingUseForeshorePropertiesTest.cs) (revision 662e55f5b46d01f77a977ab0ea92acbbaddf2365)
@@ -49,7 +49,7 @@
mocks.ReplayAll();
// Call
- TestDelegate test = () => new ConfirmingUseForeshoreProperties(null, calculation, handler);
+ TestDelegate test = () => new ConfirmingUseForeshoreProperties(null, calculation, handler);
// Assert
string paramName = Assert.Throws(test).ParamName;
@@ -68,7 +68,7 @@
mocks.ReplayAll();
// Call
- TestDelegate test = () => new ConfirmingUseForeshoreProperties(testUseForeshore, null, handler);
+ TestDelegate test = () => new ConfirmingUseForeshoreProperties(testUseForeshore, null, handler);
// Assert
string paramName = Assert.Throws(test).ParamName;
@@ -86,7 +86,7 @@
mocks.ReplayAll();
// Call
- TestDelegate test = () => new ConfirmingUseForeshoreProperties(testUseForeshore, calculation, null);
+ TestDelegate test = () => new ConfirmingUseForeshoreProperties(testUseForeshore, calculation, null);
// Assert
string paramName = Assert.Throws(test).ParamName;
@@ -111,7 +111,7 @@
};
// Call
- var properties = new ConfirmingUseForeshoreProperties(useForeshoreData, calculation, handler);
+ var properties = new ConfirmingUseForeshoreProperties(useForeshoreData, calculation, handler);
// Assert
PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);
@@ -143,7 +143,7 @@
var useForeshoreData = new TestUseForeshore();
// Call
- var properties = new ConfirmingUseForeshoreProperties(useForeshoreData, calculation, handler);
+ var properties = new ConfirmingUseForeshoreProperties(useForeshoreData, calculation, handler);
// Assert
Assert.IsFalse(properties.UseForeshore);
@@ -165,7 +165,7 @@
};
// Call
- var properties = new ConfirmingUseForeshoreProperties(useForeshoreData, calculation, handler);
+ var properties = new ConfirmingUseForeshoreProperties(useForeshoreData, calculation, handler);
// Assert
Assert.IsTrue(properties.UseForeshore);
@@ -193,7 +193,7 @@
};
// Call
- var properties = new ConfirmingUseForeshoreProperties(useForeshoreData, calculation, handler);
+ var properties = new ConfirmingUseForeshoreProperties(useForeshoreData, calculation, handler);
// Assert
Assert.IsTrue(properties.UseForeshore);
@@ -210,7 +210,7 @@
}
private void SetPropertyAndVerifyNotifcationsAndOutputForCalculation(
- Action> setProperty,
+ Action> setProperty,
TPropertyValue expectedValueSet,
TestUseForeshore input)
{
@@ -230,7 +230,7 @@
observable
});
- var properties = new ConfirmingUseForeshoreProperties(input, calculation, handler);
+ var properties = new ConfirmingUseForeshoreProperties(input, calculation, handler);
// Call
setProperty(properties);
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs
===================================================================
diff -u -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 -r662e55f5b46d01f77a977ab0ea92acbbaddf2365
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs (.../GrassCoverErosionInwardsInputContextProperties.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs (.../GrassCoverErosionInwardsInputContextProperties.cs) (revision 662e55f5b46d01f77a977ab0ea92acbbaddf2365)
@@ -161,11 +161,11 @@
[ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))]
[ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.ForeshoreProperties_DisplayName))]
[ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.ForeshoreProperties_Description))]
- public ConfirmingUseForeshoreProperties Foreshore
+ public ConfirmingUseForeshoreProperties Foreshore
{
get
{
- return new ConfirmingUseForeshoreProperties(
+ return new ConfirmingUseForeshoreProperties(
data.WrappedData,
data.Calculation,
propertyChangeHandler);
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs
===================================================================
diff -u -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 -r662e55f5b46d01f77a977ab0ea92acbbaddf2365
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesTest.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesTest.cs) (revision 662e55f5b46d01f77a977ab0ea92acbbaddf2365)
@@ -159,7 +159,7 @@
Assert.IsNaN(properties.Orientation.Value);
Assert.IsInstanceOf>(
properties.BreakWater);
- Assert.IsInstanceOf>(
+ Assert.IsInstanceOf>(
properties.Foreshore);
Assert.AreSame(inputContext, properties.DikeGeometry.Data);
Assert.AreEqual(2, properties.DikeHeight.NumberOfDecimalPlaces);
@@ -198,7 +198,7 @@
Assert.AreEqual(0.0, properties.Orientation.Value);
Assert.IsInstanceOf>(
properties.BreakWater);
- Assert.IsInstanceOf>(
+ Assert.IsInstanceOf>(
properties.Foreshore);
Assert.AreSame(inputContext, properties.DikeGeometry.Data);
Assert.AreEqual(2, properties.DikeHeight.NumberOfDecimalPlaces);
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsHydraulicBoundaryLocationContextPropertiesTest.cs
===================================================================
diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r662e55f5b46d01f77a977ab0ea92acbbaddf2365
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsHydraulicBoundaryLocationContextPropertiesTest.cs (.../GrassCoverErosionOutwardsHydraulicBoundaryLocationContextPropertiesTest.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsHydraulicBoundaryLocationContextPropertiesTest.cs (.../GrassCoverErosionOutwardsHydraulicBoundaryLocationContextPropertiesTest.cs) (revision 662e55f5b46d01f77a977ab0ea92acbbaddf2365)
@@ -116,7 +116,7 @@
};
// Assert
- var expectedString = string.Format("{0} {1}", name, new Point2D(x, y));
+ var expectedString = $"{name} {new Point2D(x, y)}";
Assert.AreEqual(expectedString, locationProperties.ToString());
}
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs
===================================================================
diff -u -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 -r662e55f5b46d01f77a977ab0ea92acbbaddf2365
--- Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs (.../WaveConditionsInputContextProperties.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs (.../WaveConditionsInputContextProperties.cs) (revision 662e55f5b46d01f77a977ab0ea92acbbaddf2365)
@@ -37,7 +37,6 @@
using Ringtoets.Common.Forms.PresentationObjects;
using Ringtoets.Common.Forms.PropertyClasses;
using Ringtoets.Common.Forms.UITypeEditors;
-using Ringtoets.Common.Service;
using Ringtoets.Revetment.Data;
using Ringtoets.Revetment.Forms.PresentationObjects;
using Ringtoets.Revetment.Forms.Properties;
@@ -50,8 +49,7 @@
///
public abstract class WaveConditionsInputContextProperties : ObjectProperties,
IHasHydraulicBoundaryLocationProperty,
- IHasForeshoreProfileProperty,
- IPropertyChangeHandler
+ IHasForeshoreProfileProperty
where T : WaveConditionsInputContext
{
private const int hydraulicBoundaryLocationPropertyIndex = 0;
@@ -71,7 +69,7 @@
private const int foreshoreGeometryPropertyIndex = 13;
private const int revetmentTypePropertyIndex = 14;
- private readonly ICalculationInputPropertyChangeHandler handler;
+ private readonly ICalculationInputPropertyChangeHandler propertyChangeHandler;
///
/// Creates a new instance of .
@@ -89,7 +87,7 @@
{
throw new ArgumentNullException(nameof(handler));
}
- this.handler = handler;
+ propertyChangeHandler = handler;
Data = context;
}
@@ -129,8 +127,7 @@
}
set
{
- data.WrappedData.UpperBoundaryRevetment = value;
- ClearOutputAndNotifyPropertyChanged();
+ ChangePropertyValueAndNotifyAffectedObjects((input, d) => input.UpperBoundaryRevetment = d, value);
}
}
@@ -146,8 +143,7 @@
}
set
{
- data.WrappedData.LowerBoundaryRevetment = value;
- ClearOutputAndNotifyPropertyChanged();
+ ChangePropertyValueAndNotifyAffectedObjects((input, d) => input.LowerBoundaryRevetment = d, value);
}
}
@@ -163,8 +159,7 @@
}
set
{
- data.WrappedData.UpperBoundaryWaterLevels = value;
- ClearOutputAndNotifyPropertyChanged();
+ ChangePropertyValueAndNotifyAffectedObjects((input, d) => input.UpperBoundaryWaterLevels = d, value);
}
}
@@ -180,8 +175,7 @@
}
set
{
- data.WrappedData.LowerBoundaryWaterLevels = value;
- ClearOutputAndNotifyPropertyChanged();
+ ChangePropertyValueAndNotifyAffectedObjects((input, d) => input.LowerBoundaryWaterLevels = d, value);
}
}
@@ -198,8 +192,7 @@
}
set
{
- data.WrappedData.StepSize = value;
- ClearOutputAndNotifyPropertyChanged();
+ ChangePropertyValueAndNotifyAffectedObjects((input, d) => input.StepSize = d, value);
}
}
@@ -243,8 +236,7 @@
}
set
{
- data.WrappedData.Orientation = value;
- ClearOutputAndNotifyPropertyChanged();
+ ChangePropertyValueAndNotifyAffectedObjects((input, d) => input.Orientation = d, value);
}
}
@@ -253,13 +245,13 @@
[ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))]
[ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.BreakWaterProperties_DisplayName))]
[ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.BreakWaterProperties_Description))]
- public UseBreakWaterProperties BreakWater
+ public ConfirmingUseBreakWaterProperties BreakWater
{
get
{
return data.WrappedData.ForeshoreProfile == null ?
- new UseBreakWaterProperties() :
- new UseBreakWaterProperties(data.WrappedData, this);
+ new ConfirmingUseBreakWaterProperties() :
+ new ConfirmingUseBreakWaterProperties(data.WrappedData, data.Calculation, propertyChangeHandler);
}
}
@@ -268,11 +260,11 @@
[ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))]
[ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.ForeshoreProperties_DisplayName))]
[ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.ForeshoreProperties_Description))]
- public UseForeshoreProperties ForeshoreGeometry
+ public ConfirmingUseForeshoreProperties ForeshoreGeometry
{
get
{
- return new UseForeshoreProperties(data.WrappedData, this);
+ return new ConfirmingUseForeshoreProperties(data.WrappedData, data.Calculation, propertyChangeHandler);
}
}
@@ -295,8 +287,7 @@
}
set
{
- data.WrappedData.ForeshoreProfile = value;
- ClearOutputAndNotifyPropertyChanged();
+ ChangePropertyValueAndNotifyAffectedObjects((input, d) => input.ForeshoreProfile = d, value);
}
}
@@ -317,16 +308,10 @@
}
set
{
- data.WrappedData.HydraulicBoundaryLocation = value.HydraulicBoundaryLocation;
- ClearOutputAndNotifyPropertyChanged();
+ ChangePropertyValueAndNotifyAffectedObjects((input, d) => input.HydraulicBoundaryLocation = d.HydraulicBoundaryLocation, value);
}
}
- public void PropertyChanged()
- {
- ClearCalculationOutput();
- }
-
public virtual IEnumerable GetAvailableForeshoreProfiles()
{
return data.ForeshoreProfiles;
@@ -339,18 +324,24 @@
data.HydraulicBoundaryLocations, referenceLocation);
}
- private void ClearOutputAndNotifyPropertyChanged()
+ private void ChangePropertyValueAndNotifyAffectedObjects(
+ SetCalculationInputPropertyValueDelegate setPropertyValue,
+ TValue value)
{
- ClearCalculationOutput();
- data.WrappedData.NotifyObservers();
+ IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation(
+ data.WrappedData,
+ data.Calculation,
+ value,
+ setPropertyValue);
+
+ NotifyAffectedObjects(affectedObjects);
}
- private void ClearCalculationOutput()
+ private static void NotifyAffectedObjects(IEnumerable affectedObjects)
{
- IEnumerable affectedCalculation = RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(data.Calculation);
- foreach (var calculation in affectedCalculation)
+ foreach (var affectedObject in affectedObjects)
{
- calculation.NotifyObservers();
+ affectedObject.NotifyObservers();
}
}
}
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs
===================================================================
diff -u -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 -r662e55f5b46d01f77a977ab0ea92acbbaddf2365
--- Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs (.../WaveConditionsInputContextPropertiesTest.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs (.../WaveConditionsInputContextPropertiesTest.cs) (revision 662e55f5b46d01f77a977ab0ea92acbbaddf2365)
@@ -167,8 +167,8 @@
Assert.AreEqual(2, properties.LowerBoundaryWaterLevels.NumberOfDecimalPlaces);
Assert.AreEqual(0.5, properties.StepSize.AsValue());
CollectionAssert.AreEqual(input.WaterLevels, properties.WaterLevels);
- Assert.IsInstanceOf(properties.BreakWater);
- Assert.IsInstanceOf(properties.ForeshoreGeometry);
+ Assert.IsInstanceOf>(properties.BreakWater);
+ Assert.IsInstanceOf>(properties.ForeshoreGeometry);
Assert.AreEqual("Test", properties.RevetmentType);
Assert.AreSame(hydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation.HydraulicBoundaryLocation);
@@ -325,88 +325,94 @@
}
[Test]
- [TestCase(true)]
- [TestCase(false)]
- public void SelectedHydraulicBoundaryLocation_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput)
+ public void SelectedHydraulicBoundaryLocation_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput()
{
- SetPropertyAndVerifyNotifcationsAndOutput(hasOutput, properties => properties.SelectedHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation(
- new TestHydraulicBoundaryLocation(), new Point2D(0, 0)));
+ var propertiesSelectedHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation(
+ new TestHydraulicBoundaryLocation(), new Point2D(0, 0));
+ SetPropertyAndVerifyNotifcationsAndOutputForCalculation(
+ properties => properties.SelectedHydraulicBoundaryLocation = propertiesSelectedHydraulicBoundaryLocation,
+ propertiesSelectedHydraulicBoundaryLocation);
}
[Test]
- [TestCase(true)]
- [TestCase(false)]
- public void ForeshoreProfile_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput)
+ public void ForeshoreProfile_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput()
{
- SetPropertyAndVerifyNotifcationsAndOutput(hasOutput, properties => properties.ForeshoreProfile = new TestForeshoreProfile());
+ var foreshoreProfile = new TestForeshoreProfile();
+ SetPropertyAndVerifyNotifcationsAndOutputForCalculation(
+ properties => properties.ForeshoreProfile = foreshoreProfile,
+ foreshoreProfile);
}
[Test]
- [TestCase(true)]
- [TestCase(false)]
- public void LowerBoundaryRevetment_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput)
+ public void LowerBoundaryRevetment_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput()
{
- SetPropertyAndVerifyNotifcationsAndOutput(hasOutput, properties => properties.LowerBoundaryRevetment = new Random(21).NextRoundedDouble());
+ RoundedDouble lowerBoundaryRevetment = new Random(21).NextRoundedDouble();
+ SetPropertyAndVerifyNotifcationsAndOutputForCalculation(
+ properties => properties.LowerBoundaryRevetment = lowerBoundaryRevetment,
+ lowerBoundaryRevetment);
}
[Test]
- [TestCase(true)]
- [TestCase(false)]
- public void UpperBoundaryRevetment_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput)
+ public void UpperBoundaryRevetment_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput()
{
- SetPropertyAndVerifyNotifcationsAndOutput(hasOutput, properties => properties.UpperBoundaryRevetment = new Random(21).NextRoundedDouble());
+ RoundedDouble upperBoundaryRevetment = new Random(21).NextRoundedDouble();
+ SetPropertyAndVerifyNotifcationsAndOutputForCalculation(
+ properties => properties.UpperBoundaryRevetment = upperBoundaryRevetment,
+ upperBoundaryRevetment);
}
[Test]
- [TestCase(true)]
- [TestCase(false)]
- public void LowerBoundaryWaterLevels_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput)
+ public void LowerBoundaryWaterLevels_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput()
{
- SetPropertyAndVerifyNotifcationsAndOutput(hasOutput, properties => properties.LowerBoundaryWaterLevels = new Random(21).NextRoundedDouble());
+ RoundedDouble lowerBoundaryWaterLevels = new Random(21).NextRoundedDouble();
+ SetPropertyAndVerifyNotifcationsAndOutputForCalculation(
+ properties => properties.LowerBoundaryWaterLevels = lowerBoundaryWaterLevels,
+ lowerBoundaryWaterLevels);
}
[Test]
- [TestCase(true)]
- [TestCase(false)]
- public void UpperBoundaryWaterLevels_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput)
+ public void UpperBoundaryWaterLevels_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput()
{
- SetPropertyAndVerifyNotifcationsAndOutput(hasOutput, properties => properties.UpperBoundaryWaterLevels = new Random(21).NextRoundedDouble());
+ RoundedDouble upperBoundaryWaterLevels = new Random(21).NextRoundedDouble();
+ SetPropertyAndVerifyNotifcationsAndOutputForCalculation(
+ properties => properties.UpperBoundaryWaterLevels = upperBoundaryWaterLevels,
+ upperBoundaryWaterLevels);
}
[Test]
- [TestCase(true)]
- [TestCase(false)]
- public void StepSize_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput)
+ public void StepSize_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput()
{
- SetPropertyAndVerifyNotifcationsAndOutput(hasOutput, properties => properties.StepSize = new Random(21).NextEnumValue());
+ var waveConditionsInputStepSize = new Random(21).NextEnumValue();
+ SetPropertyAndVerifyNotifcationsAndOutputForCalculation(
+ properties => properties.StepSize = waveConditionsInputStepSize,
+ waveConditionsInputStepSize);
}
[Test]
- [TestCase(true)]
- [TestCase(false)]
- public void UpperBoundaryDesignWaterLevel_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput)
+ public void Orientation_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput()
{
- SetPropertyAndVerifyNotifcationsAndOutput(hasOutput, properties => properties.Orientation = new Random(21).NextRoundedDouble());
+ RoundedDouble upperBoundaryDesignWaterLevel = new Random(21).NextRoundedDouble();
+ SetPropertyAndVerifyNotifcationsAndOutputForCalculation(
+ properties => properties.Orientation = upperBoundaryDesignWaterLevel,
+ upperBoundaryDesignWaterLevel);
}
[Test]
- [TestCase(true)]
- [TestCase(false)]
- public void UseBreakWater_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput)
+ public void UseBreakWater_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput()
{
- SetPropertyAndVerifyNotifcationsAndOutput(
- hasOutput,
- properties => properties.BreakWater.UseBreakWater = new Random(21).NextBoolean());
+ bool breakWaterUseBreakWater = new Random(21).NextBoolean();
+ SetPropertyAndVerifyNotifcationsAndOutputForCalculation(
+ properties => properties.BreakWater.UseBreakWater = breakWaterUseBreakWater,
+ breakWaterUseBreakWater);
}
[Test]
- [TestCase(true)]
- [TestCase(false)]
- public void UseForeshore_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput)
+ public void UseForeshore_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput()
{
- SetPropertyAndVerifyNotifcationsAndOutput(
- hasOutput,
- properties => properties.ForeshoreGeometry.UseForeshore = true);
+ bool foreshoreGeometryUseForeshore = new Random(21).NextBoolean();
+ SetPropertyAndVerifyNotifcationsAndOutputForCalculation(
+ properties => properties.ForeshoreGeometry.UseForeshore = foreshoreGeometryUseForeshore,
+ foreshoreGeometryUseForeshore);
}
[Test]
@@ -598,15 +604,19 @@
{
ForeshoreProfile = new TestForeshoreProfile(string.Empty)
};
- var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations);
- var properties = new TestWaveConditionsInputContextProperties(inputContext, handler);
+ var calculation = new TestCalculation();
+ var inputContext = new TestWaveConditionsInputContext(input, calculation, new ForeshoreProfile[0], locations);
+ var otherProfile = new TestForeshoreProfile(new Point2D(0, 190));
+ var customHandler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(input, calculation, otherProfile, Enumerable.Empty());
+ var properties = new TestWaveConditionsInputContextProperties(inputContext, customHandler);
+
IEnumerable originalList = properties.GetSelectableHydraulicBoundaryLocations()
.ToList();
// When
- properties.ForeshoreProfile = new TestForeshoreProfile(new Point2D(0, 190));
+ properties.ForeshoreProfile = otherProfile;
// Then
IEnumerable availableHydraulicBoundaryLocations =
@@ -642,43 +652,42 @@
// Assert
Assert.AreSame(locations, availableForeshoreProfiles);
}
-
- private void SetPropertyAndVerifyNotifcationsAndOutput(bool hasOutput, Action setProperty)
+
+ private void SetPropertyAndVerifyNotifcationsAndOutputForCalculation(
+ Action setProperty,
+ TPropertyValue expectedValueSet)
{
// Setup
var mocks = new MockRepository();
-
- var calculationObserver = mocks.StrictMock();
- int numberOfChangedProperties = hasOutput ? 1 : 0;
- calculationObserver.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties);
-
- var inputObserver = mocks.StrictMock();
- inputObserver.Expect(o => o.UpdateObserver());
-
+ var observable = mocks.StrictMock();
+ observable.Expect(o => o.NotifyObservers());
mocks.ReplayAll();
var calculation = new TestCalculation();
-
- if (hasOutput)
- {
- calculation.Output = new object();
- }
- calculation.Attach(calculationObserver);
-
var input = new WaveConditionsInput();
input.ForeshoreProfile = new TestForeshoreProfile();
- input.Attach(inputObserver);
- var properties = new TestWaveConditionsInputContextProperties(
- new TestWaveConditionsInputContext(input, calculation, new ForeshoreProfile[0], new HydraulicBoundaryLocation[0]),
- handler);
+ var context = new TestWaveConditionsInputContext(input,
+ calculation,
+ new ForeshoreProfile[0],
+ new HydraulicBoundaryLocation[0]);
+ var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(
+ input,
+ calculation,
+ expectedValueSet,
+ new[]
+ {
+ observable
+ });
+
+ var properties = new TestWaveConditionsInputContextProperties(context, handler);
+
// Call
setProperty(properties);
// Assert
- Assert.IsFalse(calculation.HasOutput);
-
+ Assert.IsTrue(handler.Called);
mocks.VerifyAll();
}