Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionFailureMechanismView.cs =================================================================== diff -u -rf1f94637a6b45b394493bf16a078b317c02d329b -ra0c67b5cae9f7bb451b51cdb20d6f343d12acf39 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionFailureMechanismView.cs (.../DuneErosionFailureMechanismView.cs) (revision f1f94637a6b45b394493bf16a078b317c02d329b) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionFailureMechanismView.cs (.../DuneErosionFailureMechanismView.cs) (revision a0c67b5cae9f7bb451b51cdb20d6f343d12acf39) @@ -42,6 +42,7 @@ private readonly Observer failureMechanismObserver; private readonly Observer assessmentSectionObserver; private readonly Observer duneLocationsObserver; + private readonly RecursiveObserver, DuneLocation> duneLocationObserver; private readonly MapDataCollection mapDataCollection; private readonly MapLineData referenceLineMapData; @@ -62,6 +63,7 @@ failureMechanismObserver = new Observer(UpdateMapData); assessmentSectionObserver = new Observer(UpdateMapData); duneLocationsObserver = new Observer(UpdateMapData); + duneLocationObserver = new RecursiveObserver, DuneLocation>(UpdateMapData, list => list); mapDataCollection = new MapDataCollection(DuneErosionDataResources.DuneErosionFailureMechanism_DisplayName); referenceLineMapData = RingtoetsMapDataFactory.CreateReferenceLineMapData(); @@ -92,6 +94,7 @@ failureMechanismObserver.Observable = null; assessmentSectionObserver.Observable = null; duneLocationsObserver.Observable = null; + duneLocationObserver.Observable = null; ringtoetsMapControl.RemoveAllData(); } @@ -102,6 +105,7 @@ mapDataCollection.Name = data.WrappedData.Name; duneLocationsObserver.Observable = data.WrappedData.DuneLocations; + duneLocationObserver.Observable = data.WrappedData.DuneLocations; SetMapDataFeatures(); @@ -123,6 +127,7 @@ failureMechanismObserver.Dispose(); assessmentSectionObserver.Dispose(); duneLocationsObserver.Dispose(); + duneLocationObserver.Dispose(); if (disposing) { Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Views/DuneErosionFailureMechanismViewTest.cs =================================================================== diff -u -r66964d0c53eb0d904f7ada3e3bbc1e9604e241e7 -ra0c67b5cae9f7bb451b51cdb20d6f343d12acf39 --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Views/DuneErosionFailureMechanismViewTest.cs (.../DuneErosionFailureMechanismViewTest.cs) (revision 66964d0c53eb0d904f7ada3e3bbc1e9604e241e7) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Views/DuneErosionFailureMechanismViewTest.cs (.../DuneErosionFailureMechanismViewTest.cs) (revision a0c67b5cae9f7bb451b51cdb20d6f343d12acf39) @@ -24,6 +24,7 @@ using System.Windows.Forms; using Core.Common.Base.Geometry; using Core.Components.Gis.Data; +using Core.Components.Gis.Features; using Core.Components.Gis.Forms; using NUnit.Framework; using Ringtoets.Common.Data.AssessmentSection; @@ -310,6 +311,48 @@ } [Test] + public void UpdateObserver_SingleDuneLocationUpdated_MapDataUpdated() + { + // Setup + using (var view = new DuneErosionFailureMechanismView()) + { + IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; + + var assessmentSection = new ObservableTestAssessmentSectionStub(); + var duneLocation = new TestDuneLocation(); + + var failureMechanism = new DuneErosionFailureMechanism + { + DuneLocations = + { + duneLocation + } + }; + var failureMechanismContext = new DuneErosionFailureMechanismContext(failureMechanism, assessmentSection); + + view.Data = failureMechanismContext; + + var duneLocationsMapData = map.Data.Collection.ElementAt(duneLocationsIndex) as MapPointData; + + // Precondition + MapFeature duneLocationFeature = duneLocationsMapData.Features.First(); + Assert.IsNaN((double) duneLocationFeature.MetaData["Rekenwaarde Tp"]); + Assert.IsNaN((double) duneLocationFeature.MetaData["Rekenwaarde Hs"]); + Assert.IsNaN((double) duneLocationFeature.MetaData["Rekenwaarde waterstand"]); + + // Call + duneLocation.Output = new TestDuneLocationOutput(); + duneLocation.NotifyObservers(); + + // Assert + MapFeature duneLocationFeatureUpdated = duneLocationsMapData.Features.First(); + Assert.AreEqual(duneLocation.Output.WavePeriod, (double) duneLocationFeatureUpdated.MetaData["Rekenwaarde Tp"]); + Assert.AreEqual(duneLocation.Output.WaveHeight, (double) duneLocationFeatureUpdated.MetaData["Rekenwaarde Hs"]); + Assert.AreEqual(duneLocation.Output.WaterLevel, (double) duneLocationFeatureUpdated.MetaData["Rekenwaarde waterstand"]); + } + } + + [Test] public void GivenAssessmentSectionWithDuneLocations_WhenNewDuneLocationsAreSetAndNotified_ThenMapDataUpdated() { // Given @@ -566,7 +609,7 @@ DuneLocation[] duneLocationsArray = duneLocations.ToArray(); Assert.AreEqual(duneLocationsArray.Length, duneLocationsMapData.Features.Count()); - CollectionAssert.AreEqual(duneLocationsArray.Select(hrp => hrp.Location), + CollectionAssert.AreEqual(duneLocationsArray.Select(duneLocation => duneLocation.Location), duneLocationsMapData.Features.SelectMany(f => f.MapGeometries.First().PointCollections.First())); } Assert.AreEqual("Hydraulische randvoorwaarden", mapData.Name); Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismViewTest.cs =================================================================== diff -u -rd7c8467b162e547048341f28cada904aaabdcf5a -ra0c67b5cae9f7bb451b51cdb20d6f343d12acf39 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismViewTest.cs) (revision d7c8467b162e547048341f28cada904aaabdcf5a) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismViewTest.cs) (revision a0c67b5cae9f7bb451b51cdb20d6f343d12acf39) @@ -764,10 +764,10 @@ MapData mapData) { var hydraulicLocationsMapData = (MapPointData) mapData; - IEnumerable hydraulocationBoundaryLocationsArray = hydraulicBoundaryLocations.ToArray(); - CollectionAssert.AreEqual(hydraulocationBoundaryLocationsArray.Select(hbl => hbl.DesignWaterLevel), + IEnumerable hydraulicBoundaryLocationsArray = hydraulicBoundaryLocations.ToArray(); + CollectionAssert.AreEqual(hydraulicBoundaryLocationsArray.Select(hbl => hbl.DesignWaterLevel), hydraulicLocationsMapData.Features.Select(ft => (RoundedDouble) ft.MetaData["Waterstand bij doorsnede-eis"])); - CollectionAssert.AreEqual(hydraulocationBoundaryLocationsArray.Select(hbl => hbl.WaveHeight), + CollectionAssert.AreEqual(hydraulicBoundaryLocationsArray.Select(hbl => hbl.WaveHeight), hydraulicLocationsMapData.Features.Select(ft => (RoundedDouble) ft.MetaData["Golfhoogte bij doorsnede-eis"])); }