Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismView.cs =================================================================== diff -u -r638081278e33e132e3ffedd52fff0d6c00ab4728 -r61702582a3dce7f9e122b9404fa5bcfc70756f1d --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismView.cs (.../StabilityPointStructuresFailureMechanismView.cs) (revision 638081278e33e132e3ffedd52fff0d6c00ab4728) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismView.cs (.../StabilityPointStructuresFailureMechanismView.cs) (revision 61702582a3dce7f9e122b9404fa5bcfc70756f1d) @@ -46,10 +46,11 @@ { private readonly Observer failureMechanismObserver; private readonly Observer assessmentSectionObserver; - private readonly Observer hydraulicBoundaryDatabaseObserver; + private readonly Observer hydraulicBoundaryLocationsObserver; private readonly Observer foreshoreProfilesObserver; private readonly Observer structuresObserver; + private readonly RecursiveObserver, HydraulicBoundaryLocation> hydraulicBoundaryLocationObserver; private readonly RecursiveObserver calculationInputObserver; private readonly RecursiveObserver calculationGroupObserver; private readonly RecursiveObserver> calculationObserver; @@ -76,19 +77,13 @@ 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); structuresObserver = 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); @@ -130,7 +125,8 @@ { failureMechanismObserver.Observable = null; assessmentSectionObserver.Observable = null; - hydraulicBoundaryDatabaseObserver.Observable = null; + hydraulicBoundaryLocationsObserver.Observable = null; + hydraulicBoundaryLocationObserver.Observable = null; foreshoreProfilesObserver.Observable = null; foreshoreProfileObserver.Observable = null; structuresObserver.Observable = null; @@ -145,7 +141,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; structuresObserver.Observable = data.WrappedData.StabilityPointStructures; @@ -173,7 +170,8 @@ { failureMechanismObserver.Dispose(); assessmentSectionObserver.Dispose(); - hydraulicBoundaryDatabaseObserver.Dispose(); + hydraulicBoundaryLocationsObserver.Dispose(); + hydraulicBoundaryLocationObserver.Dispose(); foreshoreProfilesObserver.Dispose(); foreshoreProfileObserver.Dispose(); calculationInputObserver.Dispose(); Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismViewTest.cs =================================================================== diff -u -rcd55f2dbdbd5bffff7d2417eb6d3e4f54ba66a47 -r61702582a3dce7f9e122b9404fa5bcfc70756f1d --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismViewTest.cs (.../StabilityPointStructuresFailureMechanismViewTest.cs) (revision cd55f2dbdbd5bffff7d2417eb6d3e4f54ba66a47) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismViewTest.cs (.../StabilityPointStructuresFailureMechanismViewTest.cs) (revision 61702582a3dce7f9e122b9404fa5bcfc70756f1d) @@ -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; @@ -295,7 +296,7 @@ } [Test] - public void GivenViewWithAssessmentSectionData_WhenAssessmentSectionUpdatedAndNotified_ThenMapDataUpdated() + public void GivenViewWithHydraulicBoundaryLocationsData_WhenHydraulicBoundaryLocationsUpdatedAndNotified_ThenMapDataUpdated() { // Given using (var view = new StabilityPointStructuresFailureMechanismView()) @@ -323,30 +324,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 StabilityPointStructuresFailureMechanismView()) { 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 } } }; @@ -358,14 +360,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); } }