Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ConfirmingUseBreakWaterProperties.cs =================================================================== diff -u -rf8998df0ea8c1228216bbb00ed9178058af4af67 -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ConfirmingUseBreakWaterProperties.cs (.../ConfirmingUseBreakWaterProperties.cs) (revision f8998df0ea8c1228216bbb00ed9178058af4af67) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ConfirmingUseBreakWaterProperties.cs (.../ConfirmingUseBreakWaterProperties.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -38,25 +38,24 @@ /// /// ViewModel of . /// - public class ConfirmingUseBreakWaterProperties - where TCalculation : ICalculation + public class ConfirmingUseBreakWaterProperties where TCalculationInput : ICalculationInput, IUseBreakWater { private const int useBreakWaterPropertyIndex = 1; private const int breakWaterTypePropertyIndex = 2; private const int breakWaterHeightPropertyIndex = 3; private readonly TCalculationInput data; - private readonly TCalculation calculation; + private readonly ICalculation calculation; private readonly ICalculationInputPropertyChangeHandler changeHandler; /// - /// Creates a new instance of , in which + /// Creates a new instance of , in which /// all the properties are read only. /// public ConfirmingUseBreakWaterProperties() { } /// - /// Creates a new instance of in which the + /// Creates a new instance of in which the /// properties are editable. /// /// The data to use for the properties. @@ -65,7 +64,7 @@ /// Thrown when any input parameter is null. public ConfirmingUseBreakWaterProperties( TCalculationInput useBreakWaterData, - TCalculation calculation, + ICalculation calculation, ICalculationInputPropertyChangeHandler handler) { if (useBreakWaterData == null) Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/ConfirmingUseBreakWaterPropertiesTest.cs =================================================================== diff -u -rf8998df0ea8c1228216bbb00ed9178058af4af67 -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/ConfirmingUseBreakWaterPropertiesTest.cs (.../ConfirmingUseBreakWaterPropertiesTest.cs) (revision f8998df0ea8c1228216bbb00ed9178058af4af67) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/ConfirmingUseBreakWaterPropertiesTest.cs (.../ConfirmingUseBreakWaterPropertiesTest.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -44,7 +44,7 @@ public void DefaultConstructor_ExpectedValues() { // Call - var properties = new ConfirmingUseBreakWaterProperties(); + var properties = new ConfirmingUseBreakWaterProperties(); // Assert Assert.IsFalse(properties.UseBreakWater); @@ -57,7 +57,7 @@ public void DefaultConstructor_Always_ReadOnlyProperties() { // Call - var properties = new ConfirmingUseBreakWaterProperties(); + var properties = new ConfirmingUseBreakWaterProperties(); // Assert var dynamicPropertyBag = new DynamicPropertyBag(properties); @@ -108,7 +108,7 @@ }; // Call - var properties = new ConfirmingUseBreakWaterProperties(testUseBreakWater, calculation, handler); + var properties = new ConfirmingUseBreakWaterProperties(testUseBreakWater, calculation, handler); // Assert var dynamicPropertyBag = new DynamicPropertyBag(properties); @@ -152,7 +152,7 @@ mocks.ReplayAll(); // Call - TestDelegate test = () => new ConfirmingUseBreakWaterProperties(null, calculation, handler); + TestDelegate test = () => new ConfirmingUseBreakWaterProperties(null, calculation, handler); // Assert string paramName = Assert.Throws(test).ParamName; @@ -171,7 +171,7 @@ mocks.ReplayAll(); // Call - TestDelegate test = () => new ConfirmingUseBreakWaterProperties(testUseBreakWater, null, handler); + TestDelegate test = () => new ConfirmingUseBreakWaterProperties(testUseBreakWater, null, handler); // Assert string paramName = Assert.Throws(test).ParamName; @@ -190,7 +190,7 @@ mocks.ReplayAll(); // Call - TestDelegate test = () => new ConfirmingUseBreakWaterProperties(testUseBreakWater, calculation, null); + TestDelegate test = () => new ConfirmingUseBreakWaterProperties(testUseBreakWater, calculation, null); // Assert string paramName = Assert.Throws(test).ParamName; @@ -214,7 +214,7 @@ }; // Call - var properties = new ConfirmingUseBreakWaterProperties(useBreakWaterData, calculation, handler); + var properties = new ConfirmingUseBreakWaterProperties(useBreakWaterData, calculation, handler); // Assert Assert.IsTrue(properties.UseBreakWater); @@ -263,7 +263,7 @@ } private void SetPropertyAndVerifyNotifcationsAndOutputForCalculation( - Action> setProperty, + Action> setProperty, TPropertyValue expectedValueSet, TestUseBreakWater input) { @@ -283,7 +283,7 @@ observable }); - var properties = new ConfirmingUseBreakWaterProperties(input, calculation, handler); + var properties = new ConfirmingUseBreakWaterProperties(input, calculation, handler); // Call setProperty(properties); Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs =================================================================== diff -u -rf8998df0ea8c1228216bbb00ed9178058af4af67 -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs (.../GrassCoverErosionInwardsInputContextProperties.cs) (revision f8998df0ea8c1228216bbb00ed9178058af4af67) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs (.../GrassCoverErosionInwardsInputContextProperties.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -64,6 +64,12 @@ private readonly ICalculationInputPropertyChangeHandler propertyChangeHandler; + /// + /// Creates a new instance of . + /// + /// The instance to show the properties for. + /// The handler responsible for handling effects of a property change. + /// Thrown when any parameter is null. public GrassCoverErosionInwardsInputContextProperties(GrassCoverErosionInwardsInputContext data, ICalculationInputPropertyChangeHandler handler) { if (data == null) @@ -139,13 +145,13 @@ [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.BreakWaterProperties_DisplayName))] [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.BreakWaterProperties_Description))] - public ConfirmingUseBreakWaterProperties BreakWater + public ConfirmingUseBreakWaterProperties BreakWater { get { return data.WrappedData.DikeProfile == null ? - new ConfirmingUseBreakWaterProperties() : - new ConfirmingUseBreakWaterProperties( + new ConfirmingUseBreakWaterProperties() : + new ConfirmingUseBreakWaterProperties( data.WrappedData, data.Calculation, propertyChangeHandler); } } Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs =================================================================== diff -u -rf8998df0ea8c1228216bbb00ed9178058af4af67 -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesTest.cs) (revision f8998df0ea8c1228216bbb00ed9178058af4af67) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesTest.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -157,7 +157,7 @@ Assert.AreEqual(2, properties.Orientation.NumberOfDecimalPlaces); Assert.IsNull(properties.DikeProfile); Assert.IsNaN(properties.Orientation.Value); - Assert.IsInstanceOf>( + Assert.IsInstanceOf>( properties.BreakWater); Assert.IsInstanceOf>( properties.Foreshore); @@ -196,7 +196,7 @@ Assert.AreEqual(2, properties.Orientation.NumberOfDecimalPlaces); Assert.AreSame(input.DikeProfile, properties.DikeProfile); Assert.AreEqual(0.0, properties.Orientation.Value); - Assert.IsInstanceOf>( + Assert.IsInstanceOf>( properties.BreakWater); Assert.IsInstanceOf>( properties.Foreshore); Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsWaveConditionsInputContextProperties.cs =================================================================== diff -u -r69eb8c7057601ce45297368b9281ea1e60980f28 -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsWaveConditionsInputContextProperties.cs (.../GrassCoverErosionOutwardsWaveConditionsInputContextProperties.cs) (revision 69eb8c7057601ce45297368b9281ea1e60980f28) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsWaveConditionsInputContextProperties.cs (.../GrassCoverErosionOutwardsWaveConditionsInputContextProperties.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -22,6 +22,7 @@ using System; using Core.Common.Base.Data; using Core.Common.Utils.Attributes; +using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; using Ringtoets.GrassCoverErosionOutwards.Forms.Properties; using Ringtoets.Revetment.Forms.PropertyClasses; @@ -39,8 +40,10 @@ /// /// The for which /// the properties are shown. - public GrassCoverErosionOutwardsWaveConditionsInputContextProperties(GrassCoverErosionOutwardsWaveConditionsInputContext context) - : base(context) { } + /// The handler responsible for handling effects of a property change. + /// Thrown when any parameter is null. + public GrassCoverErosionOutwardsWaveConditionsInputContextProperties(GrassCoverErosionOutwardsWaveConditionsInputContext context, ICalculationInputPropertyChangeHandler handler) + : base(context, handler) { } [ResourcesDisplayName(typeof(Resources), nameof(Resources.GrassCoverErosionOutwardsHydraulicBoundaryLocation_DesignWaterLevel_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.GrassCoverErosionOutwardsWaveConditionsInputContextProperties_DesignWaterLevel_Description))] Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -r8eb717ca45b6518cccfef85e481e0da52ce1df4e -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 8eb717ca45b6518cccfef85e481e0da52ce1df4e) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -36,6 +36,7 @@ using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Forms; +using Ringtoets.Common.Forms.ChangeHandlers; using Ringtoets.Common.Forms.GuiServices; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PresentationObjects; @@ -86,7 +87,7 @@ yield return new PropertyInfo { - CreateInstance = context => new GrassCoverErosionOutwardsWaveConditionsInputContextProperties(context) + CreateInstance = context => new GrassCoverErosionOutwardsWaveConditionsInputContextProperties(context, new CalculationInputPropertyChangeHandler()) }; yield return new PropertyInfo(); Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsWaveConditionsInputContextPropertiesTest.cs =================================================================== diff -u -rec3281e9d98baa572ca092f702b942947a44dbfa -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsWaveConditionsInputContextPropertiesTest.cs (.../GrassCoverErosionOutwardsWaveConditionsInputContextPropertiesTest.cs) (revision ec3281e9d98baa572ca092f702b942947a44dbfa) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsWaveConditionsInputContextPropertiesTest.cs (.../GrassCoverErosionOutwardsWaveConditionsInputContextPropertiesTest.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -23,6 +23,8 @@ using System.ComponentModel; using Core.Common.TestUtil; using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Forms.TestUtil; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; @@ -35,18 +37,51 @@ [TestFixture] public class GrassCoverErosionOutwardsWaveConditionsInputContextPropertiesTest { + private MockRepository mockRepository; + private ICalculationInputPropertyChangeHandler handler; + + [SetUp] + public void SetUp() + { + mockRepository = new MockRepository(); + handler = mockRepository.Stub(); + } + [Test] public void Constructor_WithoutContext_ThrowsArgumentNullException() { + // Setup + mockRepository.ReplayAll(); + // Call - TestDelegate test = () => new GrassCoverErosionOutwardsWaveConditionsInputContextProperties(null); + TestDelegate test = () => new GrassCoverErosionOutwardsWaveConditionsInputContextProperties(null, handler); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("context", paramName); } [Test] + public void Constructor_WithoutHandler_ThrowArgumentNullException() + { + // Setup + mockRepository.ReplayAll(); + + var context = new GrassCoverErosionOutwardsWaveConditionsInputContext( + new WaveConditionsInput(), + new TestCalculation(), + new GrassCoverErosionOutwardsFailureMechanism()); + + // Call + TestDelegate test = () => new GrassCoverErosionOutwardsWaveConditionsInputContextProperties(context, null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("handler", exception.ParamName); + mockRepository.VerifyAll(); + } + + [Test] public void Constructor_ExpectedValues() { // Setup @@ -56,7 +91,7 @@ new GrassCoverErosionOutwardsFailureMechanism()); // Call - var properties = new GrassCoverErosionOutwardsWaveConditionsInputContextProperties(context); + var properties = new GrassCoverErosionOutwardsWaveConditionsInputContextProperties(context, handler); // Assert Assert.IsInstanceOf>(properties); @@ -74,7 +109,7 @@ new GrassCoverErosionOutwardsFailureMechanism()); // Call - var properties = new GrassCoverErosionOutwardsWaveConditionsInputContextProperties(context); + var properties = new GrassCoverErosionOutwardsWaveConditionsInputContextProperties(context, handler); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Fisheye: Tag 86bb01b9f86d6a742c8d057187cc246a8d9e2c54 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsWaveConditionsInputContextPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsWaveConditionsInputContextPropertyInfoTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsWaveConditionsInputContextPropertyInfoTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsWaveConditionsInputContextPropertyInfoTest.cs (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -0,0 +1,78 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Linq; +using Core.Common.Gui.Plugin; +using NUnit.Framework; +using Ringtoets.GrassCoverErosionOutwards.Data; +using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; +using Ringtoets.GrassCoverErosionOutwards.Forms.PropertyClasses; + +namespace Ringtoets.GrassCoverErosionOutwards.Plugin.Test.PropertyInfos +{ + [TestFixture] + public class GrassCoverErosionOutwardsWaveConditionsInputContextPropertyInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + // Call + PropertyInfo info = GetInfo(plugin); + + // Assert + Assert.AreEqual(typeof(GrassCoverErosionOutwardsWaveConditionsInputContext), info.DataType); + Assert.AreEqual(typeof(GrassCoverErosionOutwardsWaveConditionsInputContextProperties), info.PropertyObjectType); + } + } + + [Test] + public void CreateInstance_Always_SetsFailureMechanismAsData() + { + // Setup + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation(); + var context = new GrassCoverErosionOutwardsWaveConditionsInputContext( + calculation.InputParameters, + calculation, + failureMechanism); + + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + PropertyInfo info = GetInfo(plugin); + + // Call + var objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(context, objectProperties.Data); + } + } + + private static PropertyInfo GetInfo(GrassCoverErosionOutwardsPlugin plugin) + { + return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(GrassCoverErosionOutwardsWaveConditionsInputContext)); + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test.csproj =================================================================== diff -u -ref5c2aa8dc9888d9864ed3a9278b0bdcb7ebd648 -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Plugin.Test.csproj) (revision ef5c2aa8dc9888d9864ed3a9278b0bdcb7ebd648) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Plugin.Test.csproj) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -66,7 +66,7 @@ - + Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs =================================================================== diff -u -r69eb8c7057601ce45297368b9281ea1e60980f28 -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs (.../WaveConditionsInputContextProperties.cs) (revision 69eb8c7057601ce45297368b9281ea1e60980f28) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs (.../WaveConditionsInputContextProperties.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -71,16 +71,25 @@ private const int foreshoreGeometryPropertyIndex = 13; private const int revetmentTypePropertyIndex = 14; + private readonly ICalculationInputPropertyChangeHandler handler; + /// /// Creates a new instance of . /// /// The for which the properties are shown. - protected WaveConditionsInputContextProperties(T context) + /// The handler responsible for handling effects of a property change. + /// Thrown when any parameter is null. + protected WaveConditionsInputContextProperties(T context, ICalculationInputPropertyChangeHandler handler) { if (context == null) { throw new ArgumentNullException(nameof(context)); } + if (handler == null) + { + throw new ArgumentNullException(nameof(handler)); + } + this.handler = handler; Data = context; } Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs =================================================================== diff -u -rcbffe2add483469b6066863b70d9044ca9d14564 -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs (.../WaveConditionsInputContextPropertiesTest.cs) (revision cbffe2add483469b6066863b70d9044ca9d14564) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs (.../WaveConditionsInputContextPropertiesTest.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -66,27 +66,57 @@ private const int foreshoreGeometryPropertyIndex = 13; private const int revetmentTypePropertyIndex = 14; + private MockRepository mockRepository; + private ICalculationInputPropertyChangeHandler handler; + + [SetUp] + public void SetUp() + { + mockRepository = new MockRepository(); + handler = mockRepository.Stub(); + } + [Test] public void Constructor_WithoutContext_ThrowsArgumentNullException() { // Call - TestDelegate test = () => new TestWaveConditionsInputContextProperties(null); + TestDelegate test = () => new TestWaveConditionsInputContextProperties(null, handler); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("context", paramName); } [Test] + public void Constructor_WithoutHandler_ThrowsArgumentNullException() + { + // Setup + mockRepository.ReplayAll(); + + var context = new TestWaveConditionsInputContext( + new WaveConditionsInput(), + Enumerable.Empty(), + Enumerable.Empty()); + + // Call + TestDelegate test = () => new TestWaveConditionsInputContextProperties(context, null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("handler", exception.ParamName); + mockRepository.VerifyAll(); + } + + [Test] public void Constructor_WithContext_ExpectedValues() { // Setup var random = new Random(21); var assessmentLevel = (RoundedDouble) random.NextDouble(); var lowerBoundaryRevetment = (RoundedDouble) random.NextDouble(); var lowerBoundaryWaterLevels = (RoundedDouble) random.NextDouble(); - var upperBoundaryRevetment = lowerBoundaryRevetment + (RoundedDouble) random.NextDouble(); - var upperBoundaryWaterLevels = lowerBoundaryWaterLevels + (RoundedDouble) random.NextDouble(); + RoundedDouble upperBoundaryRevetment = lowerBoundaryRevetment + (RoundedDouble) random.NextDouble(); + RoundedDouble upperBoundaryWaterLevels = lowerBoundaryWaterLevels + (RoundedDouble) random.NextDouble(); var stepSize = WaveConditionsInputStepSize.Half; var worldX = (RoundedDouble) random.NextDouble(); @@ -104,7 +134,7 @@ Orientation = foreshoreProfileOrientation, X0 = -3 }); - var hydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(assessmentLevel); + TestHydraulicBoundaryLocation hydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(assessmentLevel); var input = new WaveConditionsInput { ForeshoreProfile = foreshoreProfile, @@ -118,7 +148,7 @@ var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], new HydraulicBoundaryLocation[0]); // Call - var properties = new TestWaveConditionsInputContextProperties(inputContext); + var properties = new TestWaveConditionsInputContextProperties(inputContext, handler); // Assert Assert.IsInstanceOf>(properties); @@ -175,7 +205,7 @@ }, new HydraulicBoundaryLocation[0]); // Call - var properties = new TestWaveConditionsInputContextProperties(inputContext); + var properties = new TestWaveConditionsInputContextProperties(inputContext, handler); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -300,7 +330,7 @@ public void SelectedHydraulicBoundaryLocation_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) { SetPropertyAndVerifyNotifcationsAndOutput(hasOutput, properties => properties.SelectedHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation( - new TestHydraulicBoundaryLocation(), new Point2D(0, 0))); + new TestHydraulicBoundaryLocation(), new Point2D(0, 0))); } [Test] @@ -385,7 +415,7 @@ var input = new WaveConditionsInput(); var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], new HydraulicBoundaryLocation[0]); - var properties = new TestWaveConditionsInputContextProperties(inputContext); + var properties = new TestWaveConditionsInputContextProperties(inputContext, handler); SelectableHydraulicBoundaryLocation selectedHydraulicBoundaryLocation = null; @@ -413,7 +443,7 @@ }; var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations); - var properties = new TestWaveConditionsInputContextProperties(inputContext); + var properties = new TestWaveConditionsInputContextProperties(inputContext, handler); // Call IEnumerable availableHydraulicBoundaryLocations = @@ -427,7 +457,7 @@ Assert.AreEqual(59, distanceToPropertiesWorldReferencePoint, 1); Assert.AreEqual(60, distanceToForeshoreProfileReferencePoint, 1); - var hydraulicBoundaryLocationItem = availableHydraulicBoundaryLocations.ToArray()[0]; + SelectableHydraulicBoundaryLocation hydraulicBoundaryLocationItem = availableHydraulicBoundaryLocations.ToArray()[0]; RoundedDouble itemDistance = hydraulicBoundaryLocationItem.Distance; Assert.AreEqual(distanceToForeshoreProfileReferencePoint, itemDistance, itemDistance.GetAccuracy()); } @@ -443,10 +473,10 @@ ForeshoreProfile = new TestForeshoreProfile(new Point2D(200620.173572981, 503401.652985217)) }; var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], new HydraulicBoundaryLocation[0]); - var properties = new TestWaveConditionsInputContextProperties(inputContext); + var properties = new TestWaveConditionsInputContextProperties(inputContext, handler); // Call - var selectedHydraulicBoundaryLocation = properties.SelectedHydraulicBoundaryLocation; + SelectableHydraulicBoundaryLocation selectedHydraulicBoundaryLocation = properties.SelectedHydraulicBoundaryLocation; // Assert double distanceToPropertiesWorldReferencePoint = @@ -477,15 +507,15 @@ }; var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations); - var properties = new TestWaveConditionsInputContextProperties(inputContext); + var properties = new TestWaveConditionsInputContextProperties(inputContext, handler); // When IEnumerable availableHydraulicBoundaryLocations = properties.GetSelectableHydraulicBoundaryLocations(); SelectableHydraulicBoundaryLocation selectedLocation = properties.SelectedHydraulicBoundaryLocation; // Then - var hydraulicBoundaryLocationItem = availableHydraulicBoundaryLocations.ToArray()[0]; + SelectableHydraulicBoundaryLocation hydraulicBoundaryLocationItem = availableHydraulicBoundaryLocations.ToArray()[0]; Assert.AreEqual(selectedLocation.Distance, hydraulicBoundaryLocationItem.Distance, hydraulicBoundaryLocationItem.Distance.GetAccuracy()); } @@ -505,10 +535,10 @@ var input = new WaveConditionsInput(); var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations); - var properties = new TestWaveConditionsInputContextProperties(inputContext); + var properties = new TestWaveConditionsInputContextProperties(inputContext, handler); // Call - var availableHydraulicBoundaryLocations = properties.GetSelectableHydraulicBoundaryLocations(); + IEnumerable availableHydraulicBoundaryLocations = properties.GetSelectableHydraulicBoundaryLocations(); // Assert IEnumerable expectedList = @@ -537,10 +567,10 @@ }; var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations); - var properties = new TestWaveConditionsInputContextProperties(inputContext); + var properties = new TestWaveConditionsInputContextProperties(inputContext, handler); // Call - var availableHydraulicBoundaryLocations = properties.GetSelectableHydraulicBoundaryLocations(); + IEnumerable availableHydraulicBoundaryLocations = properties.GetSelectableHydraulicBoundaryLocations(); // Assert IEnumerable expectedList = @@ -570,7 +600,7 @@ }; var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations); - var properties = new TestWaveConditionsInputContextProperties(inputContext); + var properties = new TestWaveConditionsInputContextProperties(inputContext, handler); IEnumerable originalList = properties.GetSelectableHydraulicBoundaryLocations() .ToList(); @@ -585,8 +615,8 @@ IEnumerable expectedList = locations.Select(hbl => - new SelectableHydraulicBoundaryLocation(hbl, - properties.ForeshoreProfile.WorldReferencePoint)) + new SelectableHydraulicBoundaryLocation(hbl, + properties.ForeshoreProfile.WorldReferencePoint)) .OrderBy(hbl => hbl.Distance) .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Id); CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); @@ -604,10 +634,10 @@ var input = new WaveConditionsInput(); var inputContext = new TestWaveConditionsInputContext(input, locations, new HydraulicBoundaryLocation[0]); - var properties = new TestWaveConditionsInputContextProperties(inputContext); + var properties = new TestWaveConditionsInputContextProperties(inputContext, handler); // Call - var availableForeshoreProfiles = properties.GetAvailableForeshoreProfiles(); + IEnumerable availableForeshoreProfiles = properties.GetAvailableForeshoreProfiles(); // Assert Assert.AreSame(locations, availableForeshoreProfiles); @@ -640,7 +670,8 @@ input.Attach(inputObserver); var properties = new TestWaveConditionsInputContextProperties( - new TestWaveConditionsInputContext(input, calculation, new ForeshoreProfile[0], new HydraulicBoundaryLocation[0])); + new TestWaveConditionsInputContext(input, calculation, new ForeshoreProfile[0], new HydraulicBoundaryLocation[0]), + handler); // Call setProperty(properties); @@ -675,7 +706,7 @@ private class TestWaveConditionsInputContextProperties : WaveConditionsInputContextProperties { - public TestWaveConditionsInputContextProperties(WaveConditionsInputContext context) : base(context) {} + public TestWaveConditionsInputContextProperties(WaveConditionsInputContext context, ICalculationInputPropertyChangeHandler handler) : base(context, handler) {} public override string RevetmentType { Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/PropertyClasses/StabilityStoneCoverWaveConditionsInputContextProperties.cs =================================================================== diff -u -rc48f16746209f799f93c6fc79a5202a9e3fd419f -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/PropertyClasses/StabilityStoneCoverWaveConditionsInputContextProperties.cs (.../StabilityStoneCoverWaveConditionsInputContextProperties.cs) (revision c48f16746209f799f93c6fc79a5202a9e3fd419f) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/PropertyClasses/StabilityStoneCoverWaveConditionsInputContextProperties.cs (.../StabilityStoneCoverWaveConditionsInputContextProperties.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -19,6 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Ringtoets.Common.Forms.ChangeHandlers; using Ringtoets.Revetment.Forms.PropertyClasses; using Ringtoets.StabilityStoneCover.Forms.PresentationObjects; using Ringtoets.StabilityStoneCover.Forms.Properties; @@ -36,8 +38,10 @@ /// /// The for which /// the properties are shown. - public StabilityStoneCoverWaveConditionsInputContextProperties(StabilityStoneCoverWaveConditionsInputContext context) - : base(context) { } + /// The handler responsible for handling effects of a property change. + /// Thrown when any parameter is null. + public StabilityStoneCoverWaveConditionsInputContextProperties(StabilityStoneCoverWaveConditionsInputContext context, CalculationInputPropertyChangeHandler handler) + : base(context, handler) { } public override string RevetmentType { Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs =================================================================== diff -u -r8eb717ca45b6518cccfef85e481e0da52ce1df4e -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision 8eb717ca45b6518cccfef85e481e0da52ce1df4e) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -33,6 +33,7 @@ using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Forms; +using Ringtoets.Common.Forms.ChangeHandlers; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.TreeNodeInfos; @@ -66,7 +67,7 @@ yield return new PropertyInfo(); yield return new PropertyInfo { - CreateInstance = context => new StabilityStoneCoverWaveConditionsInputContextProperties(context) + CreateInstance = context => new StabilityStoneCoverWaveConditionsInputContextProperties(context, new CalculationInputPropertyChangeHandler()) }; } Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/PropertyClasses/StabilityStoneCoverWaveConditionsInputContextPropertiesTest.cs =================================================================== diff -u -r545b105a213ed85564861b4bcf6d2d6425dbde50 -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/PropertyClasses/StabilityStoneCoverWaveConditionsInputContextPropertiesTest.cs (.../StabilityStoneCoverWaveConditionsInputContextPropertiesTest.cs) (revision 545b105a213ed85564861b4bcf6d2d6425dbde50) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/PropertyClasses/StabilityStoneCoverWaveConditionsInputContextPropertiesTest.cs (.../StabilityStoneCoverWaveConditionsInputContextPropertiesTest.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -25,6 +25,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Forms.ChangeHandlers; using Ringtoets.Common.Forms.TestUtil; using Ringtoets.Revetment.Data; using Ringtoets.Revetment.Forms.PropertyClasses; @@ -40,7 +41,7 @@ public void Constructor_WithoutContext_ThrowsArgumentNullException() { // Call - TestDelegate test = () => new StabilityStoneCoverWaveConditionsInputContextProperties(null); + TestDelegate test = () => new StabilityStoneCoverWaveConditionsInputContextProperties(null, new CalculationInputPropertyChangeHandler()); // Assert string paramName = Assert.Throws(test).ParamName; @@ -62,7 +63,7 @@ assessmentSection); // Call - var properties = new StabilityStoneCoverWaveConditionsInputContextProperties(context); + var properties = new StabilityStoneCoverWaveConditionsInputContextProperties(context, new CalculationInputPropertyChangeHandler()); // Assert Assert.IsInstanceOf>(properties); Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/PropertyClasses/WaveImpactAsphaltCoverWaveConditionsInputContextProperties.cs =================================================================== diff -u -rc48f16746209f799f93c6fc79a5202a9e3fd419f -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/PropertyClasses/WaveImpactAsphaltCoverWaveConditionsInputContextProperties.cs (.../WaveImpactAsphaltCoverWaveConditionsInputContextProperties.cs) (revision c48f16746209f799f93c6fc79a5202a9e3fd419f) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/PropertyClasses/WaveImpactAsphaltCoverWaveConditionsInputContextProperties.cs (.../WaveImpactAsphaltCoverWaveConditionsInputContextProperties.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -19,6 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Ringtoets.Common.Forms.ChangeHandlers; using Ringtoets.Revetment.Forms.PropertyClasses; using Ringtoets.WaveImpactAsphaltCover.Forms.PresentationObjects; using Ringtoets.WaveImpactAsphaltCover.Forms.Properties; @@ -36,8 +38,10 @@ /// /// The for which /// the properties are shown. - public WaveImpactAsphaltCoverWaveConditionsInputContextProperties(WaveImpactAsphaltCoverWaveConditionsInputContext context) - : base(context) { } + /// The handler responsible for handling effects of a property change. + /// Thrown when any parameter is null. + public WaveImpactAsphaltCoverWaveConditionsInputContextProperties(WaveImpactAsphaltCoverWaveConditionsInputContext context, CalculationInputPropertyChangeHandler handler) + : base(context, handler) { } public override string RevetmentType { Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs =================================================================== diff -u -r8eb717ca45b6518cccfef85e481e0da52ce1df4e -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision 8eb717ca45b6518cccfef85e481e0da52ce1df4e) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -33,6 +33,7 @@ using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Forms; +using Ringtoets.Common.Forms.ChangeHandlers; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.TreeNodeInfos; @@ -66,7 +67,7 @@ yield return new PropertyInfo(); yield return new PropertyInfo { - CreateInstance = context => new WaveImpactAsphaltCoverWaveConditionsInputContextProperties(context) + CreateInstance = context => new WaveImpactAsphaltCoverWaveConditionsInputContextProperties(context, new CalculationInputPropertyChangeHandler()) }; } Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/WaveImpactAsphaltCoverWaveConditionsInputContextPropertiesTest.cs =================================================================== diff -u -r545b105a213ed85564861b4bcf6d2d6425dbde50 -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/WaveImpactAsphaltCoverWaveConditionsInputContextPropertiesTest.cs (.../WaveImpactAsphaltCoverWaveConditionsInputContextPropertiesTest.cs) (revision 545b105a213ed85564861b4bcf6d2d6425dbde50) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/WaveImpactAsphaltCoverWaveConditionsInputContextPropertiesTest.cs (.../WaveImpactAsphaltCoverWaveConditionsInputContextPropertiesTest.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) @@ -25,6 +25,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Forms.ChangeHandlers; using Ringtoets.Common.Forms.TestUtil; using Ringtoets.Revetment.Data; using Ringtoets.Revetment.Forms.PropertyClasses; @@ -40,7 +41,7 @@ public void Constructor_WithoutContext_ThrowsArgumentNullException() { // Call - TestDelegate test = () => new WaveImpactAsphaltCoverWaveConditionsInputContextProperties(null); + TestDelegate test = () => new WaveImpactAsphaltCoverWaveConditionsInputContextProperties(null, new CalculationInputPropertyChangeHandler()); // Assert string paramName = Assert.Throws(test).ParamName; @@ -62,7 +63,7 @@ assessmentSection); // Call - var properties = new WaveImpactAsphaltCoverWaveConditionsInputContextProperties(context); + var properties = new WaveImpactAsphaltCoverWaveConditionsInputContextProperties(context, new CalculationInputPropertyChangeHandler()); // Assert Assert.IsInstanceOf>(properties);