Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/PropertyClasses/DuneLocationsProperties.cs =================================================================== diff -u -r2bca78cdfd4e336f16bf2abfffb3f5ba4d46277d -r5cd1ac2b1438ea93461625d699a5377739c5abbf --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/PropertyClasses/DuneLocationsProperties.cs (.../DuneLocationsProperties.cs) (revision 2bca78cdfd4e336f16bf2abfffb3f5ba4d46277d) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/PropertyClasses/DuneLocationsProperties.cs (.../DuneLocationsProperties.cs) (revision 5cd1ac2b1438ea93461625d699a5377739c5abbf) @@ -34,39 +34,28 @@ /// /// ViewModel of an enumeration of for the properties panel. /// - public class DuneLocationsProperties : ObjectProperties>, IDisposable + public class DuneLocationsProperties : ObjectProperties>, IDisposable { - private readonly Func getCalculationFunc; - private readonly RecursiveObserver, DuneLocation> locationObserver; + private readonly RecursiveObserver, DuneLocationCalculation> calculationsObserver; /// /// Creates a new instance of . /// - /// 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) + /// The collection of dune location calculations to set as data. + /// Thrown when is null. + public DuneLocationsProperties(ObservableList calculations) { - if (locations == null) + if (calculations == null) { - throw new ArgumentNullException(nameof(locations)); + throw new ArgumentNullException(nameof(calculations)); } - if (getCalculationFunc == null) + calculationsObserver = new RecursiveObserver, DuneLocationCalculation>(OnRefreshRequired, list => list) { - throw new ArgumentNullException(nameof(getCalculationFunc)); - } - - locationObserver = new RecursiveObserver, DuneLocation>(OnRefreshRequired, list => list) - { - Observable = locations + Observable = calculations }; - this.getCalculationFunc = getCalculationFunc; - - Data = locations; + Data = calculations; } [TypeConverter(typeof(ExpandableArrayConverter))] @@ -77,13 +66,13 @@ { get { - return data.Select(loc => new DuneLocationProperties(loc, getCalculationFunc(loc))).ToArray(); + return data.Select(calculation => new DuneLocationProperties(calculation.DuneLocation, calculation)).ToArray(); } } public void Dispose() { - locationObserver.Dispose(); + calculationsObserver.Dispose(); } } } \ No newline at end of file Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Plugin/DuneErosionPlugin.cs =================================================================== diff -u -rf74c65d0ad7a4658f8a87a0beace37735b3ce749 -r5cd1ac2b1438ea93461625d699a5377739c5abbf --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Plugin/DuneErosionPlugin.cs (.../DuneErosionPlugin.cs) (revision f74c65d0ad7a4658f8a87a0beace37735b3ce749) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Plugin/DuneErosionPlugin.cs (.../DuneErosionPlugin.cs) (revision 5cd1ac2b1438ea93461625d699a5377739c5abbf) @@ -63,7 +63,7 @@ }; yield return new PropertyInfo { - CreateInstance = context => new DuneLocationsProperties(context.WrappedData, l => l.Calculation) + CreateInstance = context => new DuneLocationsProperties(context.WrappedData) }; yield return new PropertyInfo Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/PropertyClasses/DuneLocationsPropertiesTest.cs =================================================================== diff -u -rc743d1f229ff553fff9a05964c1adac6e510df4a -r5cd1ac2b1438ea93461625d699a5377739c5abbf --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/PropertyClasses/DuneLocationsPropertiesTest.cs (.../DuneLocationsPropertiesTest.cs) (revision c743d1f229ff553fff9a05964c1adac6e510df4a) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/PropertyClasses/DuneLocationsPropertiesTest.cs (.../DuneLocationsPropertiesTest.cs) (revision 5cd1ac2b1438ea93461625d699a5377739c5abbf) @@ -38,64 +38,53 @@ private const int requiredLocationsPropertyIndex = 0; [Test] - public void Constructor_LocationsNull_ThrowsArgumentNullException() + public void Constructor_CalculationsNull_ThrowsArgumentNullException() { // Call - TestDelegate call = () => new DuneLocationsProperties(null, dl => new DuneLocationCalculation(new TestDuneLocation())); + TestDelegate call = () => new DuneLocationsProperties(null); // Assert var exception = Assert.Throws(call); - Assert.AreEqual("locations", exception.ParamName); + Assert.AreEqual("calculations", exception.ParamName); } [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 Constructor_WithData_ReturnExpectedValues() { // Setup - var location = new TestDuneLocation(); - var locations = new ObservableList + var calculation = new DuneLocationCalculation(new TestDuneLocation()); + var duneLocationCalculations = new ObservableList { - location + calculation }; // Call - using (var properties = new DuneLocationsProperties(locations, dl => new DuneLocationCalculation(new TestDuneLocation()))) + using (var properties = new DuneLocationsProperties(duneLocationCalculations)) { // Assert - Assert.IsInstanceOf>>(properties); + Assert.IsInstanceOf>>(properties); Assert.IsInstanceOf(properties); Assert.AreEqual(1, properties.Locations.Length); - Assert.AreSame(location, properties.Locations[0].Data); + Assert.AreSame(calculation.DuneLocation, properties.Locations[0].Data); } } [Test] public void Constructor_Always_PropertiesHaveExpectedAttributesValues() { // Setup - var location = new TestDuneLocation(); - var locations = new ObservableList + var calculation = new DuneLocationCalculation(new TestDuneLocation()); + var duneLocationCalculations = new ObservableList { - location + calculation }; // Call - using (var properties = new DuneLocationsProperties(locations, dl => new DuneLocationCalculation(new TestDuneLocation()))) + using (var properties = new DuneLocationsProperties(duneLocationCalculations)) { // Assert - Assert.AreSame(locations, properties.Data); + Assert.AreSame(duneLocationCalculations, properties.Data); PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(1, dynamicProperties.Count); @@ -111,40 +100,40 @@ } [Test] - public void GivenPropertyControlWithData_WhenSingleLocationUpdated_RefreshRequiredEventRaised() + public void GivenPropertyControlWithData_WhenSingleCalculationUpdated_RefreshRequiredEventRaised() { // Given - DuneLocation location = new TestDuneLocation(); - var duneLocations = new ObservableList + var calculation = new DuneLocationCalculation(new TestDuneLocation()); + var duneLocationCalculations = new ObservableList { - location + calculation }; - using (var properties = new DuneLocationsProperties(duneLocations, dl => new DuneLocationCalculation(new TestDuneLocation()))) + using (var properties = new DuneLocationsProperties(duneLocationCalculations)) { var refreshRequiredRaised = 0; properties.RefreshRequired += (sender, args) => refreshRequiredRaised++; // When - location.NotifyObservers(); + calculation.NotifyObservers(); // Then Assert.AreEqual(1, refreshRequiredRaised); } } [Test] - public void GivenDisposedPropertyControlWithData_WhenSingleLocationUpdated_RefreshRequiredEventNotRaised() + public void GivenDisposedPropertyControlWithData_WhenSingleCalculationUpdated_RefreshRequiredEventNotRaised() { // Given - DuneLocation location = new TestDuneLocation(); - var duneLocations = new ObservableList + var calculation = new DuneLocationCalculation(new TestDuneLocation()); + var duneLocationCalculations = new ObservableList { - location + calculation }; - using (var properties = new DuneLocationsProperties(duneLocations, dl => new DuneLocationCalculation(new TestDuneLocation()))) + using (var properties = new DuneLocationsProperties(duneLocationCalculations)) { var refreshRequiredRaised = 0; @@ -153,7 +142,7 @@ properties.Dispose(); // When - location.NotifyObservers(); + calculation.NotifyObservers(); // Then Assert.AreEqual(0, refreshRequiredRaised);