Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverFailureMechanismView.cs =================================================================== diff -u -rcc16af254f77623b35c173044f937cebd3e442a2 -rab44ffd44a9c83fb7947e86ea93d8a4e6d6643f4 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverFailureMechanismView.cs (.../StabilityStoneCoverFailureMechanismView.cs) (revision cc16af254f77623b35c173044f937cebd3e442a2) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverFailureMechanismView.cs (.../StabilityStoneCoverFailureMechanismView.cs) (revision ab44ffd44a9c83fb7947e86ea93d8a4e6d6643f4) @@ -46,9 +46,10 @@ { private readonly Observer failureMechanismObserver; private readonly Observer assessmentSectionObserver; - private readonly Observer hydraulicBoundaryDatabaseObserver; + private readonly Observer hydraulicBoundaryLocationsObserver; private readonly Observer foreshoreProfilesObserver; + private readonly RecursiveObserver, HydraulicBoundaryLocation> hydraulicBoundaryLocationObserver; private readonly RecursiveObserver calculationInputObserver; private readonly RecursiveObserver calculationGroupObserver; private readonly RecursiveObserver calculationObserver; @@ -73,18 +74,12 @@ InitializeComponent(); failureMechanismObserver = new Observer(UpdateMapData); - assessmentSectionObserver = new Observer(() => - { - if (!ReferenceEquals(hydraulicBoundaryDatabaseObserver.Observable, data.Parent.HydraulicBoundaryDatabase)) - { - hydraulicBoundaryDatabaseObserver.Observable = data.Parent.HydraulicBoundaryDatabase; - } - - UpdateMapData(); - }); - hydraulicBoundaryDatabaseObserver = new Observer(UpdateMapData); + assessmentSectionObserver = new Observer(UpdateMapData); + hydraulicBoundaryLocationsObserver = new Observer(UpdateMapData); foreshoreProfilesObserver = new Observer(UpdateMapData); + hydraulicBoundaryLocationObserver = new RecursiveObserver, HydraulicBoundaryLocation>( + UpdateMapData, hbl => hbl); calculationInputObserver = new RecursiveObserver( UpdateMapData, pcg => pcg.Children.Concat(pcg.Children.OfType().Select(pc => pc.InputParameters))); calculationGroupObserver = new RecursiveObserver(UpdateMapData, pcg => pcg.Children); @@ -123,7 +118,8 @@ { failureMechanismObserver.Observable = null; assessmentSectionObserver.Observable = null; - hydraulicBoundaryDatabaseObserver.Observable = null; + hydraulicBoundaryLocationsObserver.Observable = null; + hydraulicBoundaryLocationObserver.Observable = null; foreshoreProfilesObserver.Observable = null; foreshoreProfileObserver.Observable = null; calculationInputObserver.Observable = null; @@ -136,7 +132,8 @@ { failureMechanismObserver.Observable = data.WrappedData; assessmentSectionObserver.Observable = data.Parent; - hydraulicBoundaryDatabaseObserver.Observable = data.Parent.HydraulicBoundaryDatabase; + hydraulicBoundaryLocationsObserver.Observable = data.Parent.HydraulicBoundaryDatabase.Locations; + hydraulicBoundaryLocationObserver.Observable = data.Parent.HydraulicBoundaryDatabase.Locations; foreshoreProfilesObserver.Observable = data.WrappedData.ForeshoreProfiles; foreshoreProfileObserver.Observable = data.WrappedData.ForeshoreProfiles; calculationInputObserver.Observable = data.WrappedData.WaveConditionsCalculationGroup; @@ -162,7 +159,8 @@ { failureMechanismObserver.Dispose(); assessmentSectionObserver.Dispose(); - hydraulicBoundaryDatabaseObserver.Dispose(); + hydraulicBoundaryLocationsObserver.Dispose(); + hydraulicBoundaryLocationObserver.Dispose(); foreshoreProfilesObserver.Dispose(); foreshoreProfileObserver.Dispose(); calculationInputObserver.Dispose(); Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Views/StabilityStoneCoverFailureMechanismViewTest.cs =================================================================== diff -u -r0c8034a02e85308561f835dad6cdb8440617d622 -rab44ffd44a9c83fb7947e86ea93d8a4e6d6643f4 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Views/StabilityStoneCoverFailureMechanismViewTest.cs (.../StabilityStoneCoverFailureMechanismViewTest.cs) (revision 0c8034a02e85308561f835dad6cdb8440617d622) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Views/StabilityStoneCoverFailureMechanismViewTest.cs (.../StabilityStoneCoverFailureMechanismViewTest.cs) (revision ab44ffd44a9c83fb7947e86ea93d8a4e6d6643f4) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; @@ -285,7 +286,7 @@ } [Test] - public void GivenViewWithAssessmentSectionData_WhenAssessmentSectionUpdatedAndNotified_ThenMapDataUpdated() + public void GivenViewWithHydraulicBoundaryLocationsData_WhenHydraulicBoundaryLocationsUpdatedAndNotified_ThenMapDataUpdated() { // Given using (var view = new StabilityStoneCoverFailureMechanismView()) @@ -313,30 +314,31 @@ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(assessmentSection.HydraulicBoundaryDatabase.Locations, hydraulicBoundaryLocationsMapData); // When - assessmentSection.HydraulicBoundaryDatabase.Locations.Clear(); - assessmentSection.HydraulicBoundaryDatabase.Locations.Add(new HydraulicBoundaryLocation(2, "test2", 2.0, 3.0)); - assessmentSection.NotifyObservers(); + assessmentSection.HydraulicBoundaryDatabase.Locations.Add(new HydraulicBoundaryLocation(2, "test2", 3.0, 4.0)); + assessmentSection.HydraulicBoundaryDatabase.Locations.NotifyObservers(); // Then MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(assessmentSection.HydraulicBoundaryDatabase.Locations, hydraulicBoundaryLocationsMapData); } } [Test] - public void GivenViewWithHydraulicBoundaryDatabaseData_WhenHydraulicBoundaryDatabaseUpdatedAndNotified_ThenMapDataUpdated() + public void GivenViewWithHydraulicBoundaryLocationsData_WhenLocationUpdatedAndNotified_ThenMapDataUpdated() { // Given + var random = new Random(21); using (var view = new StabilityStoneCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test1", 1.0, 2.0); var assessmentSection = new ObservableTestAssessmentSectionStub { HydraulicBoundaryDatabase = { Locations = { - new HydraulicBoundaryLocation(1, "test1", 1.0, 2.0) + hydraulicBoundaryLocation } } }; @@ -348,14 +350,17 @@ MapData hydraulicBoundaryLocationsMapData = map.Data.Collection.ElementAt(hydraulicBoundaryLocationsIndex); // Precondition - MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(assessmentSection.HydraulicBoundaryDatabase.Locations, hydraulicBoundaryLocationsMapData); + MapDataTestHelper.AssertHydraulicBoundaryLocationOutputsMapData(assessmentSection.HydraulicBoundaryDatabase.Locations, + hydraulicBoundaryLocationsMapData); // When - assessmentSection.HydraulicBoundaryDatabase.Locations.Add(new HydraulicBoundaryLocation(2, "test2", 3.0, 4.0)); - assessmentSection.HydraulicBoundaryDatabase.NotifyObservers(); + hydraulicBoundaryLocation.DesignWaterLevelCalculation.Output = new TestHydraulicBoundaryLocationOutput(random.NextDouble()); + hydraulicBoundaryLocation.WaveHeightCalculation.Output = new TestHydraulicBoundaryLocationOutput(random.NextDouble()); + hydraulicBoundaryLocation.NotifyObservers(); // Then - MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(assessmentSection.HydraulicBoundaryDatabase.Locations, hydraulicBoundaryLocationsMapData); + MapDataTestHelper.AssertHydraulicBoundaryLocationOutputsMapData(assessmentSection.HydraulicBoundaryDatabase.Locations, + hydraulicBoundaryLocationsMapData); } }