Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismView.cs =================================================================== diff -u -r16559315c0a64fffd05827d249200c62e353231f -rd7c8467b162e547048341f28cada904aaabdcf5a --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismView.cs (.../GrassCoverErosionOutwardsFailureMechanismView.cs) (revision 16559315c0a64fffd05827d249200c62e353231f) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismView.cs (.../GrassCoverErosionOutwardsFailureMechanismView.cs) (revision d7c8467b162e547048341f28cada904aaabdcf5a) @@ -49,6 +49,7 @@ 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; @@ -77,6 +78,8 @@ 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))); @@ -117,6 +120,7 @@ failureMechanismObserver.Observable = null; assessmentSectionObserver.Observable = null; hydraulicBoundaryLocationsObserver.Observable = null; + hydraulicBoundaryLocationObserver.Observable = null; foreshoreProfilesObserver.Observable = null; foreshoreProfileObserver.Observable = null; calculationInputObserver.Observable = null; @@ -130,6 +134,7 @@ failureMechanismObserver.Observable = data.WrappedData; assessmentSectionObserver.Observable = data.Parent; hydraulicBoundaryLocationsObserver.Observable = data.WrappedData.HydraulicBoundaryLocations; + hydraulicBoundaryLocationObserver.Observable = data.WrappedData.HydraulicBoundaryLocations; foreshoreProfilesObserver.Observable = data.WrappedData.ForeshoreProfiles; foreshoreProfileObserver.Observable = data.WrappedData.ForeshoreProfiles; calculationInputObserver.Observable = data.WrappedData.WaveConditionsCalculationGroup; @@ -156,6 +161,7 @@ failureMechanismObserver.Dispose(); assessmentSectionObserver.Dispose(); hydraulicBoundaryLocationsObserver.Dispose(); + hydraulicBoundaryLocationObserver.Dispose(); foreshoreProfilesObserver.Dispose(); foreshoreProfileObserver.Dispose(); calculationInputObserver.Dispose(); Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismViewTest.cs =================================================================== diff -u -r69ba77aac3b14ca0060f5788121f36f5fd19c83f -rd7c8467b162e547048341f28cada904aaabdcf5a --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismViewTest.cs) (revision 69ba77aac3b14ca0060f5788121f36f5fd19c83f) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismViewTest.cs) (revision d7c8467b162e547048341f28cada904aaabdcf5a) @@ -19,9 +19,11 @@ // 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; +using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Components.Gis.Data; using Core.Components.Gis.Features; @@ -279,7 +281,7 @@ } [Test] - public void GivenViewWithHydraulicBoundaryDatabaseData_WhenHydraulicBoundaryDatabaseUpdatedAndNotified_ThenMapDataUpdated() + public void GivenViewWithHydraulicBoundaryLocationsData_WhenHydraulicBoundaryDatabaseUpdatedAndNotified_ThenMapDataUpdated() { // Given using (var view = new GrassCoverErosionOutwardsFailureMechanismView()) @@ -313,6 +315,44 @@ } [Test] + public void GivenViewWithHydraulicBoundaryLocationsData_WhenLocationUpdatedAndNotified_ThenMapDataUpdated() + { + // Given + var random = new Random(21); + using (var view = new GrassCoverErosionOutwardsFailureMechanismView()) + { + IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; + + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test1", 1.0, 2.0); + var assessmentSection = new ObservableTestAssessmentSectionStub(); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { + HydraulicBoundaryLocations = + { + hydraulicBoundaryLocation + } + }; + + var failureMechanismContext = new GrassCoverErosionOutwardsFailureMechanismContext(failureMechanism, assessmentSection); + + view.Data = failureMechanismContext; + + MapData hydraulicBoundaryLocationsMapData = map.Data.Collection.ElementAt(hydraulicBoundaryLocationsIndex); + + // Precondition + AssertHydraulicBoundaryLocationOutputsMapData(failureMechanism.HydraulicBoundaryLocations, hydraulicBoundaryLocationsMapData); + + // When + hydraulicBoundaryLocation.DesignWaterLevelCalculation.Output = new TestHydraulicBoundaryLocationOutput(random.NextDouble()); + hydraulicBoundaryLocation.WaveHeightCalculation.Output = new TestHydraulicBoundaryLocationOutput(random.NextDouble()); + hydraulicBoundaryLocation.NotifyObservers(); + + // Then + AssertHydraulicBoundaryLocationOutputsMapData(failureMechanism.HydraulicBoundaryLocations, hydraulicBoundaryLocationsMapData); + } + } + + [Test] public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_ThenMapDataUpdated() { // Given @@ -720,6 +760,17 @@ } } + private static void AssertHydraulicBoundaryLocationOutputsMapData(IEnumerable hydraulicBoundaryLocations, + MapData mapData) + { + var hydraulicLocationsMapData = (MapPointData) mapData; + IEnumerable hydraulocationBoundaryLocationsArray = hydraulicBoundaryLocations.ToArray(); + CollectionAssert.AreEqual(hydraulocationBoundaryLocationsArray.Select(hbl => hbl.DesignWaterLevel), + hydraulicLocationsMapData.Features.Select(ft => (RoundedDouble) ft.MetaData["Waterstand bij doorsnede-eis"])); + CollectionAssert.AreEqual(hydraulocationBoundaryLocationsArray.Select(hbl => hbl.WaveHeight), + hydraulicLocationsMapData.Features.Select(ft => (RoundedDouble) ft.MetaData["Golfhoogte bij doorsnede-eis"])); + } + private static void AssertCalculationsMapData(IEnumerable calculations, MapData mapData) { Assert.IsInstanceOf(mapData);