Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/PropertyClasses/DuneLocationsProperties.cs =================================================================== diff -u -ra65b035e6c859fc9a6c8e92becb7f9643d18d243 -r27d409ea2f4b5e37e14cc057512f37e69b5e77c5 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/PropertyClasses/DuneLocationsProperties.cs (.../DuneLocationsProperties.cs) (revision a65b035e6c859fc9a6c8e92becb7f9643d18d243) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/PropertyClasses/DuneLocationsProperties.cs (.../DuneLocationsProperties.cs) (revision 27d409ea2f4b5e37e14cc057512f37e69b5e77c5) @@ -36,22 +36,33 @@ /// public class DuneLocationsProperties : ObjectProperties> { + private readonly Func getCalculationFunc; private readonly RecursiveObserver, DuneLocation> locationObserver; /// /// Creates a new instance of . /// - /// The locations to show the properties for. - /// Thrown when is null. - public DuneLocationsProperties(ObservableList locations) + /// The list of dune locations to set as data. + /// for obtaining a + /// based on . + /// Thrown when any input parameter is null. + public DuneLocationsProperties(ObservableList locations, + Func getCalculationFunc) { if (locations == null) { throw new ArgumentNullException(nameof(locations)); } + if (getCalculationFunc == null) + { + throw new ArgumentNullException(nameof(getCalculationFunc)); + } + locationObserver = new RecursiveObserver, DuneLocation>(OnRefreshRequired, list => list); + this.getCalculationFunc = getCalculationFunc; + Data = locations; } @@ -77,7 +88,7 @@ { get { - return data.Select(loc => new DuneLocationProperties(loc, loc.Calculation)).ToArray(); + return data.Select(loc => new DuneLocationProperties(loc, getCalculationFunc(loc))).ToArray(); } } Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Plugin/DuneErosionPlugin.cs =================================================================== diff -u -ra65b035e6c859fc9a6c8e92becb7f9643d18d243 -r27d409ea2f4b5e37e14cc057512f37e69b5e77c5 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Plugin/DuneErosionPlugin.cs (.../DuneErosionPlugin.cs) (revision a65b035e6c859fc9a6c8e92becb7f9643d18d243) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Plugin/DuneErosionPlugin.cs (.../DuneErosionPlugin.cs) (revision 27d409ea2f4b5e37e14cc057512f37e69b5e77c5) @@ -62,7 +62,7 @@ }; yield return new PropertyInfo { - CreateInstance = context => new DuneLocationsProperties(context.WrappedData) + CreateInstance = context => new DuneLocationsProperties(context.WrappedData, l => l.Calculation) }; yield return new PropertyInfo Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/PropertyClasses/DuneLocationsPropertiesTest.cs =================================================================== diff -u -ref5144459680cc600c8b6f349fd3774eb4511c24 -r27d409ea2f4b5e37e14cc057512f37e69b5e77c5 --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/PropertyClasses/DuneLocationsPropertiesTest.cs (.../DuneLocationsPropertiesTest.cs) (revision ef5144459680cc600c8b6f349fd3774eb4511c24) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/PropertyClasses/DuneLocationsPropertiesTest.cs (.../DuneLocationsPropertiesTest.cs) (revision 27d409ea2f4b5e37e14cc057512f37e69b5e77c5) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.ComponentModel; using System.Globalization; using System.Linq; @@ -40,6 +41,17 @@ private const int requiredLocationsPropertyIndex = 0; [Test] + public void Constructor_GetCalculationFuncNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new DuneLocationsProperties(new ObservableList(), null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("getCalculationFunc", exception.ParamName); + } + + [Test] public void GetProperties_WithData_ReturnExpectedValues() { // Setup @@ -50,7 +62,7 @@ }; // Call - var properties = new DuneLocationsProperties(locations); + var properties = new DuneLocationsProperties(locations, l => new DuneLocationCalculation()); // Assert CollectionAssert.AllItemsAreInstancesOfType(properties.Locations, typeof(DuneLocationProperties)); @@ -90,7 +102,7 @@ }; // Call - var properties = new DuneLocationsProperties(locations); + var properties = new DuneLocationsProperties(locations, l => new DuneLocationCalculation()); // Assert TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); @@ -118,7 +130,7 @@ location }; - var properties = new DuneLocationsProperties(duneLocations); + var properties = new DuneLocationsProperties(duneLocations, l => new DuneLocationCalculation()); var refreshRequiredRaised = 0; properties.RefreshRequired += (sender, args) => refreshRequiredRaised++; @@ -140,7 +152,7 @@ location }; - var properties = new DuneLocationsProperties(duneLocations); + var properties = new DuneLocationsProperties(duneLocations, l => new DuneLocationCalculation()); var refreshRequiredRaised = 0; properties.RefreshRequired += (sender, args) => refreshRequiredRaised++; @@ -169,7 +181,7 @@ location2 }; - var properties = new DuneLocationsProperties(duneLocations1) + var properties = new DuneLocationsProperties(duneLocations1, l => new DuneLocationCalculation()) { Data = duneLocations2 }; @@ -199,7 +211,7 @@ location2 }; - var properties = new DuneLocationsProperties(duneLocations1) + var properties = new DuneLocationsProperties(duneLocations1, l => new DuneLocationCalculation()) { Data = duneLocations2 };