Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismView.cs =================================================================== diff -u -r07e54440666b51d4a93039da2f8b5fa031fe4fe2 -radddff4153e676955aceeb958276c710a731cec4 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismView.cs (.../ClosingStructuresFailureMechanismView.cs) (revision 07e54440666b51d4a93039da2f8b5fa031fe4fe2) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismView.cs (.../ClosingStructuresFailureMechanismView.cs) (revision adddff4153e676955aceeb958276c710a731cec4) @@ -20,6 +20,7 @@ // All rights reserved. using System.Collections.Generic; +using System.Linq; using System.Windows.Forms; using Core.Common.Base; using Core.Components.Gis.Data; @@ -30,6 +31,8 @@ using Ringtoets.Common.Forms.Views; using Ringtoets.ClosingStructures.Data; using Ringtoets.ClosingStructures.Forms.PresentationObjects; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.Structures; using Ringtoets.HydraRing.Data; using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; using ClosingStructuresDataResources = Ringtoets.ClosingStructures.Data.Properties.Resources; @@ -46,13 +49,18 @@ private readonly Observer foreshoreProfilesObserver; private readonly Observer structuresObserver; + private readonly RecursiveObserver calculationInputObserver; + private readonly RecursiveObserver calculationGroupObserver; + private readonly RecursiveObserver> calculationObserver; + private readonly MapLineData referenceLineMapData; private readonly MapLineData sectionsMapData; private readonly MapPointData sectionsStartPointMapData; private readonly MapPointData sectionsEndPointMapData; private readonly MapPointData hydraulicBoundaryDatabaseMapData; private readonly MapLineData foreshoreProfilesMapData; private readonly MapPointData structuresMapData; + private readonly MapLineData calculationsMapData; private ClosingStructuresFailureMechanismContext data; @@ -68,6 +76,11 @@ foreshoreProfilesObserver = new Observer(UpdateMapData); structuresObserver = new Observer(UpdateMapData); + calculationInputObserver = new RecursiveObserver( + UpdateMapData, pcg => pcg.Children.Concat(pcg.Children.OfType>().Select(pc => pc.InputParameters))); + calculationGroupObserver = new RecursiveObserver(UpdateMapData, pcg => pcg.Children); + calculationObserver = new RecursiveObserver>(UpdateMapData, pcg => pcg.Children); + referenceLineMapData = RingtoetsMapDataFactory.CreateReferenceLineMapData(); hydraulicBoundaryDatabaseMapData = RingtoetsMapDataFactory.CreateHydraulicBoundaryDatabaseMapData(); foreshoreProfilesMapData = RingtoetsMapDataFactory.CreateForeshoreProfileMapData(); @@ -76,6 +89,7 @@ sectionsMapData = RingtoetsMapDataFactory.CreateFailureMechanismSectionsMapData(); sectionsStartPointMapData = RingtoetsMapDataFactory.CreateFailureMechanismSectionsStartPointMapData(); sectionsEndPointMapData = RingtoetsMapDataFactory.CreateFailureMechanismSectionsEndPointMapData(); + calculationsMapData = RingtoetsMapDataFactory.CreateCalculationsMapData(); mapControl.Data.Add(referenceLineMapData); mapControl.Data.Add(sectionsMapData); @@ -84,6 +98,7 @@ mapControl.Data.Add(hydraulicBoundaryDatabaseMapData); mapControl.Data.Add(foreshoreProfilesMapData); mapControl.Data.Add(structuresMapData); + mapControl.Data.Add(calculationsMapData); mapControl.Data.Name = ClosingStructuresDataResources.ClosingStructuresFailureMechanism_DisplayName; mapControl.Data.NotifyObservers(); @@ -105,6 +120,9 @@ assessmentSectionObserver.Observable = null; foreshoreProfilesObserver.Observable = null; structuresObserver.Observable = null; + calculationInputObserver.Observable = null; + calculationGroupObserver.Observable = null; + calculationObserver.Observable = null; Map.ResetMapData(); return; @@ -114,6 +132,9 @@ assessmentSectionObserver.Observable = data.Parent; foreshoreProfilesObserver.Observable = data.WrappedData.ForeshoreProfiles; structuresObserver.Observable = data.WrappedData.ClosingStructures; + calculationInputObserver.Observable = data.WrappedData.CalculationsGroup; + calculationGroupObserver.Observable = data.WrappedData.CalculationsGroup; + calculationObserver.Observable = data.WrappedData.CalculationsGroup; UpdateMapData(); } @@ -132,6 +153,9 @@ failureMechanismObserver.Dispose(); assessmentSectionObserver.Dispose(); foreshoreProfilesObserver.Dispose(); + calculationInputObserver.Dispose(); + calculationGroupObserver.Dispose(); + calculationObserver.Dispose(); if (disposing && (components != null)) { @@ -147,6 +171,7 @@ HydraulicBoundaryDatabase hydraulicBoundaryDatabase = null; IEnumerable foreshoreProfiles = null; IEnumerable structures = null; + CalculationGroup calculationGroup = null; if (data != null) { @@ -155,6 +180,7 @@ hydraulicBoundaryDatabase = data.Parent.HydraulicBoundaryDatabase; foreshoreProfiles = data.WrappedData.ForeshoreProfiles; structures = data.WrappedData.ClosingStructures; + calculationGroup = data.WrappedData.CalculationsGroup; } referenceLineMapData.Features = RingtoetsMapDataFeaturesFactory.CreateReferenceLineFeatures(referenceLine, data.Parent.Id, data.Parent.Name); @@ -164,6 +190,8 @@ hydraulicBoundaryDatabaseMapData.Features = RingtoetsMapDataFeaturesFactory.CreateHydraulicBoundaryDatabaseFeaturesWithDefaultLabels(hydraulicBoundaryDatabase); foreshoreProfilesMapData.Features = RingtoetsMapDataFeaturesFactory.CreateForeshoreProfilesFeatures(foreshoreProfiles); structuresMapData.Features = RingtoetsMapDataFeaturesFactory.CreateStructuresFeatures(structures); + calculationsMapData.Features = RingtoetsMapDataFeaturesFactory.CreateStructureCalculationsFeatures + (calculationGroup.GetCalculations().Cast>()); mapControl.Data.NotifyObservers(); } Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismViewTest.cs =================================================================== diff -u -r52289b39d16efbf1ea1cd2980d62a8541527d23c -radddff4153e676955aceeb958276c710a731cec4 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismViewTest.cs (.../ClosingStructuresFailureMechanismViewTest.cs) (revision 52289b39d16efbf1ea1cd2980d62a8541527d23c) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismViewTest.cs (.../ClosingStructuresFailureMechanismViewTest.cs) (revision adddff4153e676955aceeb958276c710a731cec4) @@ -30,18 +30,19 @@ using Core.Components.Gis.Forms; using Core.Components.Gis.Geometries; using NUnit.Framework; +using Ringtoets.ClosingStructures.Data; +using Ringtoets.ClosingStructures.Data.TestUtil; +using Ringtoets.ClosingStructures.Forms.PresentationObjects; +using Ringtoets.ClosingStructures.Forms.Views; using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Contribution; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Data.TestUtil; -using Ringtoets.HydraRing.Data; -using Ringtoets.ClosingStructures.Data; -using Ringtoets.ClosingStructures.Data.TestUtil; -using Ringtoets.ClosingStructures.Forms.PresentationObjects; -using Ringtoets.ClosingStructures.Forms.Views; using Ringtoets.Common.Forms.TestUtil; +using Ringtoets.HydraRing.Data; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; using ClosingStructuresDataResources = Ringtoets.ClosingStructures.Data.Properties.Resources; @@ -58,6 +59,7 @@ private const int hydraulicBoundaryDatabaseIndex = 4; private const int foreshoreProfilesIndex = 5; private const int structuresIndex = 6; + private const int calculationsIndex = 7; [Test] public void DefaultConstructor_DefaultValues() @@ -82,7 +84,7 @@ // Assert Assert.AreEqual(1, view.Controls.Count); Assert.AreSame(view.Map, view.Controls[0]); - Assert.AreEqual(DockStyle.Fill, ((Control)view.Map).Dock); + Assert.AreEqual(DockStyle.Fill, ((Control) view.Map).Dock); Assert.AreEqual(ClosingStructuresDataResources.ClosingStructuresFailureMechanism_DisplayName, view.Map.Data.Name); AssertEmptyMapData(view.Map.Data); } @@ -131,7 +133,7 @@ view.Data = failureMechanismContext; // Precondition - Assert.AreEqual(7, view.Map.Data.Collection.Count()); + Assert.AreEqual(8, view.Map.Data.Collection.Count()); // Call view.Data = null; @@ -165,7 +167,7 @@ // Setup using (var view = new ClosingStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var geometryPoints = new[] { @@ -211,7 +213,7 @@ Assert.IsInstanceOf(mapData); var mapDataList = mapData.Collection.ToList(); - Assert.AreEqual(7, mapDataList.Count); + Assert.AreEqual(8, mapDataList.Count); AssertReferenceLineMapData(assessmentSection.ReferenceLine, mapDataList[referenceLineIndex]); MapDataTestHelper.AssertFailureMechanismSectionsMapData(failureMechanism.Sections, mapDataList[sectionsIndex]); AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, mapDataList[sectionsStartPointIndex]); @@ -227,7 +229,7 @@ // Setup using (var view = new ClosingStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var hydraulicBoundaryDatabase1 = new HydraulicBoundaryDatabase { @@ -273,7 +275,7 @@ // Setup using (var view = new ClosingStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var points1 = new List { @@ -317,16 +319,16 @@ // Setup using (var view = new ClosingStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var failureMechanism = new ClosingStructuresFailureMechanism(); var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); view.Data = failureMechanismContext; - var sectionMapData = (MapLineData)map.Data.Collection.ElementAt(sectionsIndex); - var sectionStartsMapData = (MapPointData)map.Data.Collection.ElementAt(sectionsStartPointIndex); - var sectionsEndsMapData = (MapPointData)map.Data.Collection.ElementAt(sectionsEndPointIndex); + var sectionMapData = (MapLineData) map.Data.Collection.ElementAt(sectionsIndex); + var sectionStartsMapData = (MapPointData) map.Data.Collection.ElementAt(sectionsStartPointIndex); + var sectionsEndsMapData = (MapPointData) map.Data.Collection.ElementAt(sectionsEndPointIndex); // Call failureMechanism.AddSection(new FailureMechanismSection(string.Empty, new[] @@ -349,7 +351,7 @@ // Setup using (var view = new ClosingStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var failureMechanism = new ClosingStructuresFailureMechanism(); var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); @@ -378,7 +380,7 @@ // Setup using (var view = new ClosingStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var failureMechanism = new ClosingStructuresFailureMechanism(); var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); @@ -402,20 +404,149 @@ } [Test] + public void UpdateObserver_CalculationGroupUpdated_MapDataUpdated() + { + // Setup + using (var view = new ClosingStructuresFailureMechanismView()) + { + var map = (MapControl) view.Controls[0]; + + var failureMechanism = new ClosingStructuresFailureMechanism(); + var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); + + var calculationLocationA = new Point2D(1.2, 2.3); + var calculationLocationB = new Point2D(2.7, 2.0); + + var hydraulicBoundaryLocationA = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3); + var hydraulicBoundaryLocationB = new HydraulicBoundaryLocation(1, string.Empty, 7.7, 12.6); + + var calculationA = new StructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocationA, + Structure = new TestClosingStructure(calculationLocationA) + } + }; + + var calculationB = new StructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocationB, + Structure = new TestClosingStructure(calculationLocationB) + } + }; + + failureMechanism.CalculationsGroup.Children.Add(calculationA); + + view.Data = failureMechanismContext; + + var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); + + failureMechanism.CalculationsGroup.Children.Add(calculationB); + + // Call + failureMechanism.CalculationsGroup.NotifyObservers(); + + // Assert + AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); + } + } + + [Test] + public void UpdateObserver_CalculationInputUpdated_MapDataUpdated() + { + // Setup + using (var view = new ClosingStructuresFailureMechanismView()) + { + var map = (MapControl) view.Controls[0]; + + var failureMechanism = new ClosingStructuresFailureMechanism(); + var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); + + var calculationLocationA = new Point2D(1.2, 2.3); + var calculationLocationB = new Point2D(2.7, 2.0); + + var hydraulicBoundaryLocationA = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3); + + var calculationA = new StructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocationA, + Structure = new TestClosingStructure(calculationLocationA) + } + }; + + view.Data = failureMechanismContext; + + var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); + + calculationA.InputParameters.Structure = new TestClosingStructure(calculationLocationB); + + // Call + calculationA.InputParameters.NotifyObservers(); + + // Assert + AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); + } + } + + [Test] + public void UpdateObserver_CalculationUpdated_MapDataUpdated() + { + // Setup + using (var view = new ClosingStructuresFailureMechanismView()) + { + var map = (MapControl) view.Controls[0]; + + var failureMechanism = new ClosingStructuresFailureMechanism(); + var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); + + var calculationLocationA = new Point2D(1.2, 2.3); + + var hydraulicBoundaryLocationA = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3); + + var calculationA = new StructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocationA, + Structure = new TestClosingStructure(calculationLocationA) + } + }; + + view.Data = failureMechanismContext; + + var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); + + calculationA.Name = "new name"; + + // Call + calculationA.NotifyObservers(); + + // Assert + AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); + } + } + + [Test] public void UpdateObserver_DataUpdated_MapLayersSameOrder() { // Setup - const int updatedRefenceLineLayerIndex = referenceLineIndex + 6; + const int updatedRefenceLineLayerIndex = referenceLineIndex + 7; const int updatedSectionsLayerIndex = sectionsIndex - 1; const int updateSectionStartLayerIndex = sectionsStartPointIndex - 1; const int updatedSectionEndLayerIndex = sectionsEndPointIndex - 1; const int updatedHydraulicLocationsLayerIndex = hydraulicBoundaryDatabaseIndex - 1; const int updatedForeshoreProfilesLayerIndex = foreshoreProfilesIndex - 1; - const int updatedStructuresLayerIndex = structuresIndex- 1; + const int updatedStructuresLayerIndex = structuresIndex - 1; + const int updatedCalculationsIndex = calculationsIndex - 1; using (var view = new ClosingStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var assessmentSection = new TestAssessmentSection(); var failureMechanism = new ClosingStructuresFailureMechanism(); @@ -425,34 +556,37 @@ var mapData = map.Data; - var dataToMove = (MapLineData)map.Data.Collection.ElementAt(referenceLineIndex); + var dataToMove = (MapLineData) map.Data.Collection.ElementAt(referenceLineIndex); mapData.Remove(dataToMove); mapData.Add(dataToMove); var mapDataList = mapData.Collection.ToList(); // Precondition - var referenceLineData = (MapLineData)mapDataList[updatedRefenceLineLayerIndex]; + var referenceLineData = (MapLineData) mapDataList[updatedRefenceLineLayerIndex]; Assert.AreEqual("Referentielijn", referenceLineData.Name); - var sectionsData = (MapLineData)mapDataList[updatedSectionsLayerIndex]; + var sectionsData = (MapLineData) mapDataList[updatedSectionsLayerIndex]; Assert.AreEqual("Vakindeling", sectionsData.Name); - var sectionStartsData = (MapPointData)mapDataList[updateSectionStartLayerIndex]; + var sectionStartsData = (MapPointData) mapDataList[updateSectionStartLayerIndex]; Assert.AreEqual("Vakindeling (startpunten)", sectionStartsData.Name); - var sectionEndsData = (MapPointData)mapDataList[updatedSectionEndLayerIndex]; + var sectionEndsData = (MapPointData) mapDataList[updatedSectionEndLayerIndex]; Assert.AreEqual("Vakindeling (eindpunten)", sectionEndsData.Name); - var hydraulicLocationsData = (MapPointData)mapDataList[updatedHydraulicLocationsLayerIndex]; + var hydraulicLocationsData = (MapPointData) mapDataList[updatedHydraulicLocationsLayerIndex]; Assert.AreEqual("Hydraulische randvoorwaarden", hydraulicLocationsData.Name); - var foreshoreProfilesData = (MapLineData)mapDataList[updatedForeshoreProfilesLayerIndex]; + var foreshoreProfilesData = (MapLineData) mapDataList[updatedForeshoreProfilesLayerIndex]; Assert.AreEqual("Voorlandprofielen", foreshoreProfilesData.Name); - var structuresData = (MapPointData)mapDataList[updatedStructuresLayerIndex]; + var structuresData = (MapPointData) mapDataList[updatedStructuresLayerIndex]; Assert.AreEqual("Kunstwerken", structuresData.Name); + var calculationsData = (MapLineData) mapDataList[updatedCalculationsIndex]; + Assert.AreEqual("Berekeningen", calculationsData.Name); + var points = new List { new Point2D(2.0, 5.0), @@ -466,26 +600,29 @@ assessmentSection.NotifyObservers(); // Call - var actualReferenceLineData = (MapLineData)mapDataList[updatedRefenceLineLayerIndex]; + var actualReferenceLineData = (MapLineData) mapDataList[updatedRefenceLineLayerIndex]; Assert.AreEqual("Referentielijn", actualReferenceLineData.Name); - var actualSectionsData = (MapLineData)mapDataList[updatedSectionsLayerIndex]; + var actualSectionsData = (MapLineData) mapDataList[updatedSectionsLayerIndex]; Assert.AreEqual("Vakindeling", actualSectionsData.Name); - var actualSectionStartsData = (MapPointData)mapDataList[updateSectionStartLayerIndex]; + var actualSectionStartsData = (MapPointData) mapDataList[updateSectionStartLayerIndex]; Assert.AreEqual("Vakindeling (startpunten)", actualSectionStartsData.Name); - var actualSectionEndsData = (MapPointData)mapDataList[updatedSectionEndLayerIndex]; + var actualSectionEndsData = (MapPointData) mapDataList[updatedSectionEndLayerIndex]; Assert.AreEqual("Vakindeling (eindpunten)", actualSectionEndsData.Name); - var actualHydraulicLocationsData = (MapPointData)mapDataList[updatedHydraulicLocationsLayerIndex]; + var actualHydraulicLocationsData = (MapPointData) mapDataList[updatedHydraulicLocationsLayerIndex]; Assert.AreEqual("Hydraulische randvoorwaarden", actualHydraulicLocationsData.Name); - var actualForeshoreProfilesData = (MapLineData)mapDataList[updatedForeshoreProfilesLayerIndex]; + var actualForeshoreProfilesData = (MapLineData) mapDataList[updatedForeshoreProfilesLayerIndex]; Assert.AreEqual("Voorlandprofielen", actualForeshoreProfilesData.Name); - var actualStructuresData = (MapPointData)mapDataList[updatedStructuresLayerIndex]; + var actualStructuresData = (MapPointData) mapDataList[updatedStructuresLayerIndex]; Assert.AreEqual("Kunstwerken", actualStructuresData.Name); + + var actualCalculationsData = (MapLineData) mapDataList[updatedCalculationsIndex]; + Assert.AreEqual("Berekeningen", actualCalculationsData.Name); } } @@ -507,7 +644,7 @@ var newClosingStructuresFailureMechanismContext = new ClosingStructuresFailureMechanismContext(new ClosingStructuresFailureMechanism(), newAssessmentSection); using (var view = new ClosingStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; view.Data = oldClosingStructuresFailureMechanismContext; view.Data = newClosingStructuresFailureMechanismContext; @@ -526,7 +663,7 @@ private static void AssertReferenceLineMapData(ReferenceLine referenceLine, MapData mapData) { Assert.IsInstanceOf(mapData); - var referenceLineData = (MapLineData)mapData; + var referenceLineData = (MapLineData) mapData; if (referenceLine == null) { CollectionAssert.IsEmpty(referenceLineData.Features.First().MapGeometries.First().PointCollections.First()); @@ -542,7 +679,7 @@ { Assert.NotNull(foreshoreProfiles, "foreshoreProfiles should never be null."); - var foreshoreProfilesData = (MapLineData)mapData; + var foreshoreProfilesData = (MapLineData) mapData; var foreshoreProfileArray = foreshoreProfiles.ToArray(); Assert.AreEqual(foreshoreProfileArray.Length, foreshoreProfilesData.Features.Length); @@ -560,7 +697,7 @@ { Assert.NotNull(structures, "structures should never be null."); - var structuresData = (MapPointData)mapData; + var structuresData = (MapPointData) mapData; var structuresArray = structures.ToArray(); Assert.AreEqual(structuresArray.Length, structuresData.Features.Length); @@ -577,7 +714,7 @@ private static void AssertHydraulicBoundaryLocationsMapData(HydraulicBoundaryDatabase database, MapData mapData) { Assert.IsInstanceOf(mapData); - var hydraulicLocationsMapData = (MapPointData)mapData; + var hydraulicLocationsMapData = (MapPointData) mapData; if (database == null) { CollectionAssert.IsEmpty(hydraulicLocationsMapData.Features.First().MapGeometries.First().PointCollections.First()); @@ -592,34 +729,59 @@ private static void AssertFailureMechanismSectionsStartPointMapData(IEnumerable sections, MapData mapData) { Assert.IsInstanceOf(mapData); - var sectionsStartPointData = (MapPointData)mapData; + var sectionsStartPointData = (MapPointData) mapData; CollectionAssert.AreEqual(sections.Select(s => s.GetStart()), sectionsStartPointData.Features.First().MapGeometries.First().PointCollections.First()); Assert.AreEqual("Vakindeling (startpunten)", mapData.Name); } private static void AssertFailureMechanismSectionsEndPointMapData(IEnumerable sections, MapData mapData) { Assert.IsInstanceOf(mapData); - var sectionsStartPointData = (MapPointData)mapData; + var sectionsStartPointData = (MapPointData) mapData; CollectionAssert.AreEqual(sections.Select(s => s.GetLast()), sectionsStartPointData.Features.First().MapGeometries.First().PointCollections.First()); Assert.AreEqual("Vakindeling (eindpunten)", mapData.Name); } + private static void AssertCalculationsMapData(IEnumerable> calculations, MapData mapData) + { + Assert.IsInstanceOf(mapData); + var calculationsMapData = (MapLineData) mapData; + var calculationsArray = calculations.ToArray(); + var calculationsFeatures = calculationsMapData.Features.ToArray(); + Assert.AreEqual(calculationsArray.Length, calculationsFeatures.Length); + + for (int index = 0; index < calculationsArray.Length; index++) + { + var geometries = calculationsFeatures[index].MapGeometries.ToArray(); + Assert.AreEqual(1, geometries.Length); + + StructuresCalculation calculation = calculationsArray[index]; + CollectionAssert.AreEquivalent(new[] + { + calculation.InputParameters.Structure.Location, + calculation.InputParameters.HydraulicBoundaryLocation.Location + }, + geometries[0].PointCollections.First()); + } + Assert.AreEqual("Berekeningen", mapData.Name); + } + private static void AssertEmptyMapData(MapDataCollection mapData) { Assert.IsInstanceOf(mapData); var mapDataList = mapData.Collection.ToList(); - Assert.AreEqual(7, mapDataList.Count); + Assert.AreEqual(8, mapDataList.Count); - var referenceLineMapData = (MapLineData)mapDataList[referenceLineIndex]; - var sectionsMapData = (MapLineData)mapDataList[sectionsIndex]; - var foreshoreProfilesMapData = (MapLineData)mapDataList[foreshoreProfilesIndex]; - var structuresMapData = (MapPointData)mapDataList[structuresIndex]; - var sectionsStartPointMapData = (MapPointData)mapDataList[sectionsStartPointIndex]; - var sectionsEndPointMapData = (MapPointData)mapDataList[sectionsEndPointIndex]; - var hydraulicBoundaryDatabaseMapData = (MapPointData)mapDataList[hydraulicBoundaryDatabaseIndex]; + var referenceLineMapData = (MapLineData) mapDataList[referenceLineIndex]; + var sectionsMapData = (MapLineData) mapDataList[sectionsIndex]; + var foreshoreProfilesMapData = (MapLineData) mapDataList[foreshoreProfilesIndex]; + var structuresMapData = (MapPointData) mapDataList[structuresIndex]; + var sectionsStartPointMapData = (MapPointData) mapDataList[sectionsStartPointIndex]; + var sectionsEndPointMapData = (MapPointData) mapDataList[sectionsEndPointIndex]; + var hydraulicBoundaryDatabaseMapData = (MapPointData) mapDataList[hydraulicBoundaryDatabaseIndex]; + var calculationsMapData = (MapLineData) mapDataList[calculationsIndex]; CollectionAssert.IsEmpty(referenceLineMapData.Features); CollectionAssert.IsEmpty(sectionsMapData.Features); @@ -628,6 +790,7 @@ CollectionAssert.IsEmpty(sectionsStartPointMapData.Features); CollectionAssert.IsEmpty(sectionsEndPointMapData.Features); CollectionAssert.IsEmpty(hydraulicBoundaryDatabaseMapData.Features); + CollectionAssert.IsEmpty(calculationsMapData.Features); Assert.AreEqual(RingtoetsCommonDataResources.ReferenceLine_DisplayName, referenceLineMapData.Name); Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanism_Sections_DisplayName, sectionsMapData.Name); @@ -636,6 +799,7 @@ Assert.AreEqual(GetSectionPointDisplayName(RingtoetsCommonFormsResources.FailureMechanismSections_StartPoints_DisplayName), sectionsStartPointMapData.Name); Assert.AreEqual(GetSectionPointDisplayName(RingtoetsCommonFormsResources.FailureMechanismSections_EndPoints_DisplayName), sectionsEndPointMapData.Name); Assert.AreEqual(RingtoetsCommonDataResources.HydraulicBoundaryConditions_DisplayName, hydraulicBoundaryDatabaseMapData.Name); + Assert.AreEqual(RingtoetsCommonDataResources.FailureMechanism_Calculations_DisplayName, calculationsMapData.Name); } private static string GetSectionPointDisplayName(string name) Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/RingtoetsMapDataFeaturesFactory.cs =================================================================== diff -u -r52289b39d16efbf1ea1cd2980d62a8541527d23c -radddff4153e676955aceeb958276c710a731cec4 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/RingtoetsMapDataFeaturesFactory.cs (.../RingtoetsMapDataFeaturesFactory.cs) (revision 52289b39d16efbf1ea1cd2980d62a8541527d23c) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/RingtoetsMapDataFeaturesFactory.cs (.../RingtoetsMapDataFeaturesFactory.cs) (revision adddff4153e676955aceeb958276c710a731cec4) @@ -29,8 +29,10 @@ using Core.Components.Gis.Geometries; using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Forms.Properties; using Ringtoets.HydraRing.Data; @@ -45,10 +47,12 @@ /// /// Create reference line features based on the provided . /// - /// The to create the reference line features for. + /// The to create the reference + /// line features for. /// The id of the . /// The name of the . - /// An array of features or an empty array when is null. + /// An array of features or an empty array when + /// is null. public static MapFeature[] CreateReferenceLineFeatures(ReferenceLine referenceLine, string id, string name) { var features = new List(); @@ -68,11 +72,14 @@ } /// - /// Create hydraulic boundary database location features based on the provided - /// with default labels for design water level and wave height. + /// Create hydraulic boundary database location features based on the provided + /// with default labels for design + /// water level and wave height. /// - /// The to create the location features for. - /// An array of features or an empty array when is null. + /// The + /// to create the location features for. + /// An array of features or an empty array when + /// is null. public static MapFeature[] CreateHydraulicBoundaryDatabaseFeaturesWithDefaultLabels(HydraulicBoundaryDatabase hydraulicBoundaryDatabase) { return CreateHydraulicBoundaryDatabaseFeatures(hydraulicBoundaryDatabase, @@ -81,11 +88,14 @@ } /// - /// Create hydraulic boundary database location features based on the provided - /// with optional labels for design water level and wave height. + /// Create hydraulic boundary database location features based on the provided + /// with optional labels for design + /// water level and wave height. /// - /// The to create the location features for. - /// An array of features or an empty array when is null. + /// The + /// to create the location features for. + /// An array of features or an empty array when + /// is null. public static MapFeature[] CreateHydraulicBoundaryDatabaseFeaturesWithOptionalLabels(HydraulicBoundaryDatabase hydraulicBoundaryDatabase) { return CreateHydraulicBoundaryDatabaseFeatures(hydraulicBoundaryDatabase, @@ -96,8 +106,10 @@ /// /// Create section features based on the provided . /// - /// The collection of to create the section features for. - /// An array of features or an empty array when is null or empty. + /// The collection of to create + /// the section features for. + /// An array of features or an empty array when is + /// null or empty. public static MapFeature[] CreateFailureMechanismSectionFeatures(IEnumerable sections) { var features = new List(); @@ -127,8 +139,10 @@ /// /// Create section start point features based on the provided . /// - /// The collection of to create the section start point features for. - /// An array of features or an empty array when is null or empty. + /// The collection of to create + /// the section start point features for. + /// An array of features or an empty array when is + /// null or empty. public static MapFeature[] CreateFailureMechanismSectionStartPointFeatures(IEnumerable sections) { return sections != null && sections.Any() @@ -142,8 +156,10 @@ /// /// Create section end point features based on the provided . /// - /// The collection of to create the section end point features for. - /// An array of features or an empty array when is null or empty. + /// The collection of to create + /// the section end point features for. + /// An array of features or an empty array when is + /// null or empty. public static MapFeature[] CreateFailureMechanismSectionEndPointFeatures(IEnumerable sections) { return sections != null && sections.Any() @@ -158,7 +174,8 @@ /// Create features for the geometry of the . /// /// The profiles to create features for. - /// An array of features or an empty array when is null or empty. + /// An array of features or an empty array when is + /// null or empty. public static MapFeature[] CreateDikeProfilesFeatures(IEnumerable dikeProfiles) { if (dikeProfiles == null || !dikeProfiles.Any()) @@ -173,7 +190,8 @@ /// Create features for the geometry of the . /// /// The profiles to create features for. - /// An array of features or an empty array when is null or empty. + /// An array of features or an empty array when + /// is null or empty. public static MapFeature[] CreateForeshoreProfilesFeatures(IEnumerable foreshoreProfiles) { if (foreshoreProfiles == null || !foreshoreProfiles.Any()) @@ -188,7 +206,8 @@ /// Create features for the geometry of the . /// /// The profiles to create features for. - /// An array of features or an empty array when is null or empty. + /// An array of features or an empty array when is + /// null or empty. public static MapFeature[] CreateStructuresFeatures(IEnumerable structures) { if (structures == null || !structures.Any()) @@ -199,6 +218,39 @@ return structures.Select(structure => GetAsSingleMapFeature(structure.Location)).ToArray(); } + /// + /// Create calculation features based on the provided . + /// + /// The collection of to create the + /// calculation features for. + /// An array of features or an empty array when is null + /// or empty. + public static MapFeature[] CreateStructureCalculationsFeatures(IEnumerable> calculationInputs) + where T : StructuresInputBase, new() + where U : StructureBase + { + var hasCalculations = calculationInputs != null && calculationInputs.Any(); + + if (!hasCalculations) + { + return new MapFeature[0]; + } + + var calculationsWithLocationAndHydraulicBoundaryLocation = calculationInputs.Where( + calculation => + calculation.InputParameters.Structure != null && + calculation.InputParameters.HydraulicBoundaryLocation != null); + + IList calculationData = + calculationsWithLocationAndHydraulicBoundaryLocation.Select( + calculation => new MapCalculationData( + calculation.Name, + calculation.InputParameters.Structure.Location, + calculation.InputParameters.HydraulicBoundaryLocation)).ToList(); + + return CreateCalculationsFeatures(calculationData); + } + public static MapFeature[] CreateCalculationsFeatures(IEnumerable calculationData) { if (calculationData == null || !calculationData.Any()) @@ -218,16 +270,18 @@ feature.MetaData[Resources.MetaData_Name] = calculationItem.Name; feature.MetaData[Resources.MetaData_Couple_distance] = - calculationItem.CalculationLocation.GetEuclideanDistanceTo(calculationItem.HydraulicBoundaryLocation.Location); + calculationItem.CalculationLocation.GetEuclideanDistanceTo( + calculationItem.HydraulicBoundaryLocation.Location); features.Add(feature); } return features.ToArray(); } - private static MapFeature[] CreateHydraulicBoundaryDatabaseFeatures(HydraulicBoundaryDatabase hydraulicBoundaryDatabase, - string designWaterLevelAttributeName, - string waveheightAttributeName) + private static MapFeature[] CreateHydraulicBoundaryDatabaseFeatures( + HydraulicBoundaryDatabase hydraulicBoundaryDatabase, + string designWaterLevelAttributeName, + string waveheightAttributeName) { var features = new List(); @@ -293,7 +347,8 @@ } /// - /// This class holds information to be able to present calculations coupled to hydraulic boundary locations on the map. + /// This class holds information to be able to present calculations coupled to + /// hydraulic boundary locations on the map. /// public class MapCalculationData { @@ -317,7 +372,8 @@ /// /// The name of the calculation. /// The location of the calculation. - /// The hydraulic boundary location assigned to the calculation. + /// The hydraulic boundary location + /// assigned to the calculation. public MapCalculationData(string calculationName, Point2D calculationLocation, HydraulicBoundaryLocation hydraulicBoundaryLocation) { if (calculationName == null) Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/StructureSelectionDialogTest.cs =================================================================== diff -u -r18a3f0bab0ce260604820928c136e66abca7daab -radddff4153e676955aceeb958276c710a731cec4 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/StructureSelectionDialogTest.cs (.../StructureSelectionDialogTest.cs) (revision 18a3f0bab0ce260604820928c136e66abca7daab) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/StructureSelectionDialogTest.cs (.../StructureSelectionDialogTest.cs) (revision adddff4153e676955aceeb958276c710a731cec4) @@ -138,10 +138,10 @@ Assert.AreEqual(testname, (string) dataGridViewControl.Rows[0].Cells[nameColumnIndex].Value); } } - } - public class TestStructure : StructureBase - { - public TestStructure(ConstructionProperties constructionProperties) : base(constructionProperties) {} + public class TestStructure : StructureBase + { + public TestStructure(ConstructionProperties constructionProperties) : base(constructionProperties) { } + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsMapDataFeaturesFactoryTest.cs =================================================================== diff -u -r52289b39d16efbf1ea1cd2980d62a8541527d23c -radddff4153e676955aceeb958276c710a731cec4 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsMapDataFeaturesFactoryTest.cs (.../RingtoetsMapDataFeaturesFactoryTest.cs) (revision 52289b39d16efbf1ea1cd2980d62a8541527d23c) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsMapDataFeaturesFactoryTest.cs (.../RingtoetsMapDataFeaturesFactoryTest.cs) (revision adddff4153e676955aceeb958276c710a731cec4) @@ -27,9 +27,11 @@ using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; using NUnit.Framework; +using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Forms.Views; using Ringtoets.HydraRing.Data; @@ -385,6 +387,83 @@ } [Test] + public void CreateStructureCalculationsFeatures_NullLocations_ReturnsEmptyCollection() + { + // Call + MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateStructureCalculationsFeatures< + SimpleStructuresInput, StructureBase>(null); + + // Assert + Assert.IsEmpty(features); + } + + [Test] + public void CreateStructureCalculationsFeatures_EmptyLocations_ReturnsEmptyCollection() + { + // Call + MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateStructureCalculationsFeatures + (Enumerable.Empty()); + + // Assert + Assert.IsEmpty(features); + } + + [Test] + public void CreateStructureCalculationsFeatures_WithCalculations_ReturnsCollectionWithCalculations() + { + // Setup + var calculationLocationA = new Point2D(1.2, 2.3); + var calculationLocationB = new Point2D(2.7, 2.0); + + var hydraulicBoundaryLocationA = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3); + var hydraulicBoundaryLocationB = new HydraulicBoundaryLocation(1, string.Empty, 7.7, 12.6); + + var simpleStructuresCalculationA = new SimpleStructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocationA, + Structure = new SimpleStructure(calculationLocationA) + } + }; + + var simpleStructuresCalculationB = new SimpleStructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocationB, + Structure = new SimpleStructure(calculationLocationB) + } + }; + + // Call + MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateStructureCalculationsFeatures + (new[] + { + simpleStructuresCalculationA, + simpleStructuresCalculationB + }); + + // Assert + Assert.AreEqual(2, features.Length); + Assert.AreEqual(1, features[0].MapGeometries.Count()); + Assert.AreEqual(1, features[1].MapGeometries.Count()); + var mapDataGeometryOne = features[0].MapGeometries.ElementAt(0).PointCollections.First().ToArray(); + var mapDataGeometryTwo = features[1].MapGeometries.ElementAt(0).PointCollections.First().ToArray(); + + CollectionElementsAlmostEquals(new[] + { + calculationLocationA, + hydraulicBoundaryLocationA.Location + }, mapDataGeometryOne); + CollectionElementsAlmostEquals(new[] + { + calculationLocationB, + hydraulicBoundaryLocationB.Location + }, mapDataGeometryTwo); + } + + [Test] public void CreateCalculationsFeatures_NullLocations_ReturnsEmptyCollection() { // Call @@ -628,5 +707,28 @@ { CollectionAssert.AreEqual(points, geometry.PointCollections.First()); } + + private class SimpleStructuresInput : StructuresInputBase + { + protected override void UpdateStructureParameters() + { + } + } + + private class SimpleStructuresCalculation : StructuresCalculation + { + } + + public class SimpleStructure : StructureBase + { + + public SimpleStructure(Point2D location) + : base(new ConstructionProperties + { + Location = location, + Name = "name", + Id = "id" + }) { } + } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismViewTest.cs =================================================================== diff -u -re866d883e0603dc8613eebc581953a9b2a8f5986 -radddff4153e676955aceeb958276c710a731cec4 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismViewTest.cs (.../GrassCoverErosionInwardsFailureMechanismViewTest.cs) (revision e866d883e0603dc8613eebc581953a9b2a8f5986) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismViewTest.cs (.../GrassCoverErosionInwardsFailureMechanismViewTest.cs) (revision adddff4153e676955aceeb958276c710a731cec4) @@ -35,10 +35,10 @@ using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.TestUtil; -using Ringtoets.HydraRing.Data; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; using Ringtoets.GrassCoverErosionInwards.Forms.Views; +using Ringtoets.HydraRing.Data; using Ringtoets.HydraRing.Data.TestUtil; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; @@ -353,7 +353,7 @@ // Setup using (var view = new GrassCoverErosionInwardsFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var failureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, new TestAssessmentSection()); @@ -383,7 +383,7 @@ // Setup using (var view = new GrassCoverErosionInwardsFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var failureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, new TestAssessmentSection()); @@ -413,7 +413,7 @@ // Setup using (var view = new GrassCoverErosionInwardsFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var failureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, new TestAssessmentSection()); @@ -441,7 +441,7 @@ view.Data = failureMechanismContext; - var calculationMapData = (MapLineData)map.Data.Collection.ElementAt(calculationsIndex); + var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); failureMechanism.CalculationsGroup.Children.Add(calculationB); @@ -459,7 +459,7 @@ // Setup using (var view = new GrassCoverErosionInwardsFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var failureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, new TestAssessmentSection()); @@ -477,7 +477,7 @@ }; view.Data = failureMechanismContext; - var calculationMapData = (MapLineData)map.Data.Collection.ElementAt(calculationsIndex); + var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); calculationA.InputParameters.DikeProfile = dikeProfileB; @@ -495,7 +495,7 @@ // Setup using (var view = new GrassCoverErosionInwardsFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var failureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, new TestAssessmentSection()); @@ -513,7 +513,7 @@ view.Data = failureMechanismContext; - var calculationMapData = (MapLineData)map.Data.Collection.ElementAt(calculationsIndex); + var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); calculationA.Name = "new name"; @@ -575,10 +575,10 @@ var dikeProfilesData = (MapLineData) mapDataList[updatedDikeProfilesLayerIndex]; Assert.AreEqual("Dijkprofielen", dikeProfilesData.Name); - var foreshoreProfilesData = (MapLineData)mapDataList[updatedForeshoreProfilesLayerIndex]; + var foreshoreProfilesData = (MapLineData) mapDataList[updatedForeshoreProfilesLayerIndex]; Assert.AreEqual("Voorlandprofielen", foreshoreProfilesData.Name); - var calculationsData = (MapLineData)mapDataList[updatedCalculationsIndex]; + var calculationsData = (MapLineData) mapDataList[updatedCalculationsIndex]; Assert.AreEqual("Berekeningen", calculationsData.Name); var points = new List @@ -612,10 +612,10 @@ var actualDikeProfilesData = (MapLineData) mapDataList[updatedDikeProfilesLayerIndex]; Assert.AreEqual("Dijkprofielen", actualDikeProfilesData.Name); - var actualForeshoreProfilesData = (MapLineData)mapDataList[updatedForeshoreProfilesLayerIndex]; + var actualForeshoreProfilesData = (MapLineData) mapDataList[updatedForeshoreProfilesLayerIndex]; Assert.AreEqual("Voorlandprofielen", actualForeshoreProfilesData.Name); - var actualCalculationsData = (MapLineData)mapDataList[updatedCalculationsIndex]; + var actualCalculationsData = (MapLineData) mapDataList[updatedCalculationsIndex]; Assert.AreEqual("Berekeningen", actualCalculationsData.Name); } } @@ -684,7 +684,7 @@ var profileDataA = dikeProfilesData.Features[i].MapGeometries.First(); CollectionAssert.AreEquivalent(dikeProfileArray[0].DikeGeometry, profileDataA.PointCollections.First()); } - + Assert.AreEqual("Dijkprofielen", mapData.Name); } @@ -741,23 +741,23 @@ private static void AssertCalculationsMapData(IEnumerable calculations, MapData mapData) { Assert.IsInstanceOf(mapData); - var calculationsMapData = (MapLineData)mapData; + var calculationsMapData = (MapLineData) mapData; var calculationsArray = calculations.ToArray(); var calculationsFeatures = calculationsMapData.Features.ToArray(); Assert.AreEqual(calculationsArray.Length, calculationsFeatures.Length); - for (int index = 0; index < calculationsArray.Length; index++) { var geometries = calculationsFeatures[index].MapGeometries.ToArray(); Assert.AreEqual(1, geometries.Length); GrassCoverErosionInwardsCalculation calculation = calculationsArray[index]; - CollectionAssert.AreEquivalent(new[] { - calculation.InputParameters.DikeProfile.WorldReferencePoint, - calculation.InputParameters.HydraulicBoundaryLocation.Location - }, - geometries[0].PointCollections.First()); + CollectionAssert.AreEquivalent(new[] + { + calculation.InputParameters.DikeProfile.WorldReferencePoint, + calculation.InputParameters.HydraulicBoundaryLocation.Location + }, + geometries[0].PointCollections.First()); } Assert.AreEqual("Berekeningen", mapData.Name); } @@ -777,6 +777,7 @@ var sectionsStartPointMapData = (MapPointData) mapDataList[sectionsStartPointIndex]; var sectionsEndPointMapData = (MapPointData) mapDataList[sectionsEndPointIndex]; var hydraulicBoundaryDatabaseMapData = (MapPointData) mapDataList[hydraulicBoundaryDatabaseIndex]; + var calculationsMapData = (MapLineData) mapDataList[calculationsIndex]; CollectionAssert.IsEmpty(referenceLineMapData.Features); CollectionAssert.IsEmpty(sectionsMapData.Features); @@ -785,6 +786,7 @@ CollectionAssert.IsEmpty(sectionsStartPointMapData.Features); CollectionAssert.IsEmpty(sectionsEndPointMapData.Features); CollectionAssert.IsEmpty(hydraulicBoundaryDatabaseMapData.Features); + CollectionAssert.IsEmpty(calculationsMapData.Features); Assert.AreEqual(RingtoetsCommonDataResources.ReferenceLine_DisplayName, referenceLineMapData.Name); Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanism_Sections_DisplayName, sectionsMapData.Name); @@ -793,6 +795,7 @@ Assert.AreEqual(GetSectionPointDisplayName(RingtoetsCommonFormsResources.FailureMechanismSections_StartPoints_DisplayName), sectionsStartPointMapData.Name); Assert.AreEqual(GetSectionPointDisplayName(RingtoetsCommonFormsResources.FailureMechanismSections_EndPoints_DisplayName), sectionsEndPointMapData.Name); Assert.AreEqual(RingtoetsCommonDataResources.HydraulicBoundaryConditions_DisplayName, hydraulicBoundaryDatabaseMapData.Name); + Assert.AreEqual(RingtoetsCommonDataResources.FailureMechanism_Calculations_DisplayName, calculationsMapData.Name); } private static string GetSectionPointDisplayName(string name) Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismViewTest.cs =================================================================== diff -u -re866d883e0603dc8613eebc581953a9b2a8f5986 -radddff4153e676955aceeb958276c710a731cec4 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismViewTest.cs) (revision e866d883e0603dc8613eebc581953a9b2a8f5986) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismViewTest.cs) (revision adddff4153e676955aceeb958276c710a731cec4) @@ -714,20 +714,23 @@ var sectionsStartPointMapData = (MapPointData)mapDataList[sectionsStartPointIndex]; var sectionsEndPointMapData = (MapPointData)mapDataList[sectionsEndPointIndex]; var hydraulicBoundaryDatabaseMapData = (MapPointData)mapDataList[hydraulicBoundaryDatabaseIndex]; + var calculationsMapData = (MapLineData)mapDataList[calculationsIndex]; CollectionAssert.IsEmpty(referenceLineMapData.Features); CollectionAssert.IsEmpty(sectionsMapData.Features); CollectionAssert.IsEmpty(foreshoreProfilesMapData.Features); CollectionAssert.IsEmpty(sectionsStartPointMapData.Features); CollectionAssert.IsEmpty(sectionsEndPointMapData.Features); CollectionAssert.IsEmpty(hydraulicBoundaryDatabaseMapData.Features); + CollectionAssert.IsEmpty(calculationsMapData.Features); Assert.AreEqual(RingtoetsCommonDataResources.ReferenceLine_DisplayName, referenceLineMapData.Name); Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanism_Sections_DisplayName, sectionsMapData.Name); Assert.AreEqual(RingtoetsCommonFormsResources.ForeshoreProfiles_DisplayName, foreshoreProfilesMapData.Name); Assert.AreEqual(GetSectionPointDisplayName(RingtoetsCommonFormsResources.FailureMechanismSections_StartPoints_DisplayName), sectionsStartPointMapData.Name); Assert.AreEqual(GetSectionPointDisplayName(RingtoetsCommonFormsResources.FailureMechanismSections_EndPoints_DisplayName), sectionsEndPointMapData.Name); Assert.AreEqual(RingtoetsCommonDataResources.HydraulicBoundaryConditions_DisplayName, hydraulicBoundaryDatabaseMapData.Name); + Assert.AreEqual(RingtoetsCommonDataResources.FailureMechanism_Calculations_DisplayName, calculationsMapData.Name); } private static string GetSectionPointDisplayName(string name) Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismView.cs =================================================================== diff -u -r07e54440666b51d4a93039da2f8b5fa031fe4fe2 -radddff4153e676955aceeb958276c710a731cec4 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismView.cs (.../HeightStructuresFailureMechanismView.cs) (revision 07e54440666b51d4a93039da2f8b5fa031fe4fe2) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismView.cs (.../HeightStructuresFailureMechanismView.cs) (revision adddff4153e676955aceeb958276c710a731cec4) @@ -20,13 +20,16 @@ // All rights reserved. using System.Collections.Generic; +using System.Linq; using System.Windows.Forms; using Core.Common.Base; using Core.Components.Gis.Data; using Core.Components.Gis.Forms; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Forms.Views; using Ringtoets.HeightStructures.Data; using Ringtoets.HeightStructures.Forms.PresentationObjects; @@ -46,13 +49,18 @@ private readonly Observer foreshoreProfilesObserver; private readonly Observer structuresObserver; + private readonly RecursiveObserver calculationInputObserver; + private readonly RecursiveObserver calculationGroupObserver; + private readonly RecursiveObserver> calculationObserver; + private readonly MapLineData referenceLineMapData; private readonly MapLineData sectionsMapData; private readonly MapPointData sectionsStartPointMapData; private readonly MapPointData sectionsEndPointMapData; private readonly MapPointData hydraulicBoundaryDatabaseMapData; private readonly MapLineData foreshoreProfilesMapData; private readonly MapPointData structuresMapData; + private readonly MapLineData calculationsMapData; private HeightStructuresFailureMechanismContext data; @@ -68,6 +76,11 @@ foreshoreProfilesObserver = new Observer(UpdateMapData); structuresObserver = new Observer(UpdateMapData); + calculationInputObserver = new RecursiveObserver( + UpdateMapData, pcg => pcg.Children.Concat(pcg.Children.OfType>().Select(pc => pc.InputParameters))); + calculationGroupObserver = new RecursiveObserver(UpdateMapData, pcg => pcg.Children); + calculationObserver = new RecursiveObserver>(UpdateMapData, pcg => pcg.Children); + referenceLineMapData = RingtoetsMapDataFactory.CreateReferenceLineMapData(); hydraulicBoundaryDatabaseMapData = RingtoetsMapDataFactory.CreateHydraulicBoundaryDatabaseMapData(); foreshoreProfilesMapData = RingtoetsMapDataFactory.CreateForeshoreProfileMapData(); @@ -76,6 +89,7 @@ sectionsMapData = RingtoetsMapDataFactory.CreateFailureMechanismSectionsMapData(); sectionsStartPointMapData = RingtoetsMapDataFactory.CreateFailureMechanismSectionsStartPointMapData(); sectionsEndPointMapData = RingtoetsMapDataFactory.CreateFailureMechanismSectionsEndPointMapData(); + calculationsMapData = RingtoetsMapDataFactory.CreateCalculationsMapData(); mapControl.Data.Add(referenceLineMapData); mapControl.Data.Add(sectionsMapData); @@ -84,6 +98,7 @@ mapControl.Data.Add(hydraulicBoundaryDatabaseMapData); mapControl.Data.Add(foreshoreProfilesMapData); mapControl.Data.Add(structuresMapData); + mapControl.Data.Add(calculationsMapData); mapControl.Data.Name = HeightStructuresDataResources.HeightStructuresFailureMechanism_DisplayName; mapControl.Data.NotifyObservers(); @@ -105,6 +120,9 @@ assessmentSectionObserver.Observable = null; foreshoreProfilesObserver.Observable = null; structuresObserver.Observable = null; + calculationInputObserver.Observable = null; + calculationGroupObserver.Observable = null; + calculationObserver.Observable = null; Map.ResetMapData(); return; @@ -114,6 +132,10 @@ assessmentSectionObserver.Observable = data.Parent; foreshoreProfilesObserver.Observable = data.WrappedData.ForeshoreProfiles; structuresObserver.Observable = data.WrappedData.HeightStructures; + calculationObserver.Observable = data.WrappedData.CalculationsGroup; + calculationInputObserver.Observable = data.WrappedData.CalculationsGroup; + calculationGroupObserver.Observable = data.WrappedData.CalculationsGroup; + calculationObserver.Observable = data.WrappedData.CalculationsGroup; UpdateMapData(); } @@ -132,6 +154,9 @@ failureMechanismObserver.Dispose(); assessmentSectionObserver.Dispose(); foreshoreProfilesObserver.Dispose(); + calculationInputObserver.Dispose(); + calculationGroupObserver.Dispose(); + calculationObserver.Dispose(); if (disposing && (components != null)) { @@ -147,6 +172,7 @@ HydraulicBoundaryDatabase hydraulicBoundaryDatabase = null; IEnumerable foreshoreProfiles = null; IEnumerable structures = null; + CalculationGroup calculationGroup = null; if (data != null) { @@ -155,6 +181,7 @@ hydraulicBoundaryDatabase = data.Parent.HydraulicBoundaryDatabase; foreshoreProfiles = data.WrappedData.ForeshoreProfiles; structures = data.WrappedData.HeightStructures; + calculationGroup = data.WrappedData.CalculationsGroup; } referenceLineMapData.Features = RingtoetsMapDataFeaturesFactory.CreateReferenceLineFeatures(referenceLine, data.Parent.Id, data.Parent.Name); @@ -164,6 +191,8 @@ hydraulicBoundaryDatabaseMapData.Features = RingtoetsMapDataFeaturesFactory.CreateHydraulicBoundaryDatabaseFeaturesWithDefaultLabels(hydraulicBoundaryDatabase); foreshoreProfilesMapData.Features = RingtoetsMapDataFeaturesFactory.CreateForeshoreProfilesFeatures(foreshoreProfiles); structuresMapData.Features = RingtoetsMapDataFeaturesFactory.CreateStructuresFeatures(structures); + calculationsMapData.Features = RingtoetsMapDataFeaturesFactory.CreateStructureCalculationsFeatures + (calculationGroup.GetCalculations().Cast>()); mapControl.Data.NotifyObservers(); } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismViewTest.cs =================================================================== diff -u -r52289b39d16efbf1ea1cd2980d62a8541527d23c -radddff4153e676955aceeb958276c710a731cec4 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismViewTest.cs (.../HeightStructuresFailureMechanismViewTest.cs) (revision 52289b39d16efbf1ea1cd2980d62a8541527d23c) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismViewTest.cs (.../HeightStructuresFailureMechanismViewTest.cs) (revision adddff4153e676955aceeb958276c710a731cec4) @@ -34,13 +34,14 @@ using Ringtoets.Common.Data.Contribution; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.TestUtil; -using Ringtoets.HydraRing.Data; using Ringtoets.HeightStructures.Data; using Ringtoets.HeightStructures.Data.TestUtil; using Ringtoets.HeightStructures.Forms.PresentationObjects; using Ringtoets.HeightStructures.Forms.Views; +using Ringtoets.HydraRing.Data; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; using HeightStructuresDataResources = Ringtoets.HeightStructures.Data.Properties.Resources; @@ -57,6 +58,7 @@ private const int hydraulicBoundaryDatabaseIndex = 4; private const int foreshoreProfilesIndex = 5; private const int structuresIndex = 6; + private const int calculationsIndex = 7; [Test] public void DefaultConstructor_DefaultValues() @@ -81,7 +83,7 @@ // Assert Assert.AreEqual(1, view.Controls.Count); Assert.AreSame(view.Map, view.Controls[0]); - Assert.AreEqual(DockStyle.Fill, ((Control)view.Map).Dock); + Assert.AreEqual(DockStyle.Fill, ((Control) view.Map).Dock); Assert.AreEqual(HeightStructuresDataResources.HeightStructuresFailureMechanism_DisplayName, view.Map.Data.Name); AssertEmptyMapData(view.Map.Data); } @@ -130,7 +132,7 @@ view.Data = failureMechanismContext; // Precondition - Assert.AreEqual(7, view.Map.Data.Collection.Count()); + Assert.AreEqual(8, view.Map.Data.Collection.Count()); // Call view.Data = null; @@ -164,7 +166,7 @@ // Setup using (var view = new HeightStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var geometryPoints = new[] { @@ -210,7 +212,7 @@ Assert.IsInstanceOf(mapData); var mapDataList = mapData.Collection.ToList(); - Assert.AreEqual(7, mapDataList.Count); + Assert.AreEqual(8, mapDataList.Count); AssertReferenceLineMapData(assessmentSection.ReferenceLine, mapDataList[referenceLineIndex]); MapDataTestHelper.AssertFailureMechanismSectionsMapData(failureMechanism.Sections, mapDataList[sectionsIndex]); AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, mapDataList[sectionsStartPointIndex]); @@ -226,7 +228,7 @@ // Setup using (var view = new HeightStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var hydraulicBoundaryDatabase1 = new HydraulicBoundaryDatabase { @@ -272,7 +274,7 @@ // Setup using (var view = new HeightStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var points1 = new List { @@ -316,16 +318,16 @@ // Setup using (var view = new HeightStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var failureMechanism = new HeightStructuresFailureMechanism(); var failureMechanismContext = new HeightStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); view.Data = failureMechanismContext; - var sectionMapData = (MapLineData)map.Data.Collection.ElementAt(sectionsIndex); - var sectionStartsMapData = (MapPointData)map.Data.Collection.ElementAt(sectionsStartPointIndex); - var sectionsEndsMapData = (MapPointData)map.Data.Collection.ElementAt(sectionsEndPointIndex); + var sectionMapData = (MapLineData) map.Data.Collection.ElementAt(sectionsIndex); + var sectionStartsMapData = (MapPointData) map.Data.Collection.ElementAt(sectionsStartPointIndex); + var sectionsEndsMapData = (MapPointData) map.Data.Collection.ElementAt(sectionsEndPointIndex); // Call failureMechanism.AddSection(new FailureMechanismSection(string.Empty, new[] @@ -348,7 +350,7 @@ // Setup using (var view = new HeightStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var failureMechanism = new HeightStructuresFailureMechanism(); var failureMechanismContext = new HeightStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); @@ -377,7 +379,7 @@ // Setup using (var view = new HeightStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var failureMechanism = new HeightStructuresFailureMechanism(); var failureMechanismContext = new HeightStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); @@ -401,20 +403,149 @@ } [Test] + public void UpdateObserver_CalculationGroupUpdated_MapDataUpdated() + { + // Setup + using (var view = new HeightStructuresFailureMechanismView()) + { + var map = (MapControl) view.Controls[0]; + + var failureMechanism = new HeightStructuresFailureMechanism(); + var failureMechanismContext = new HeightStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); + + var calculationLocationA = new Point2D(1.2, 2.3); + var calculationLocationB = new Point2D(2.7, 2.0); + + var hydraulicBoundaryLocationA = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3); + var hydraulicBoundaryLocationB = new HydraulicBoundaryLocation(1, string.Empty, 7.7, 12.6); + + var calculationA = new StructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocationA, + Structure = new TestHeightStructure(calculationLocationA) + } + }; + + var calculationB = new StructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocationB, + Structure = new TestHeightStructure(calculationLocationB) + } + }; + + failureMechanism.CalculationsGroup.Children.Add(calculationA); + + view.Data = failureMechanismContext; + + var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); + + failureMechanism.CalculationsGroup.Children.Add(calculationB); + + // Call + failureMechanism.CalculationsGroup.NotifyObservers(); + + // Assert + AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); + } + } + + [Test] + public void UpdateObserver_CalculationInputUpdated_MapDataUpdated() + { + // Setup + using (var view = new HeightStructuresFailureMechanismView()) + { + var map = (MapControl) view.Controls[0]; + + var failureMechanism = new HeightStructuresFailureMechanism(); + var failureMechanismContext = new HeightStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); + + var calculationLocationA = new Point2D(1.2, 2.3); + var calculationLocationB = new Point2D(2.7, 2.0); + + var hydraulicBoundaryLocationA = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3); + + var calculationA = new StructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocationA, + Structure = new TestHeightStructure(calculationLocationA) + } + }; + + view.Data = failureMechanismContext; + + var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); + + calculationA.InputParameters.Structure = new TestHeightStructure(calculationLocationB); + + // Call + calculationA.InputParameters.NotifyObservers(); + + // Assert + AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); + } + } + + [Test] + public void UpdateObserver_CalculationUpdated_MapDataUpdated() + { + // Setup + using (var view = new HeightStructuresFailureMechanismView()) + { + var map = (MapControl) view.Controls[0]; + + var failureMechanism = new HeightStructuresFailureMechanism(); + var failureMechanismContext = new HeightStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); + + var calculationLocationA = new Point2D(1.2, 2.3); + + var hydraulicBoundaryLocationA = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3); + + var calculationA = new StructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocationA, + Structure = new TestHeightStructure(calculationLocationA) + } + }; + + view.Data = failureMechanismContext; + + var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); + + calculationA.Name = "new name"; + + // Call + calculationA.NotifyObservers(); + + // Assert + AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); + } + } + + [Test] public void UpdateObserver_DataUpdated_MapLayersSameOrder() { // Setup - const int updatedRefenceLineLayerIndex = referenceLineIndex + 6; + const int updatedRefenceLineLayerIndex = referenceLineIndex + 7; const int updatedSectionsLayerIndex = sectionsIndex - 1; const int updateSectionStartLayerIndex = sectionsStartPointIndex - 1; const int updatedSectionEndLayerIndex = sectionsEndPointIndex - 1; const int updatedHydraulicLocationsLayerIndex = hydraulicBoundaryDatabaseIndex - 1; const int updatedForeshoreProfilesLayerIndex = foreshoreProfilesIndex - 1; - const int updatedStructuresLayerIndex = structuresIndex- 1; + const int updatedStructuresLayerIndex = structuresIndex - 1; + const int updatedCalculationsIndex = calculationsIndex - 1; using (var view = new HeightStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var assessmentSection = new TestAssessmentSection(); var failureMechanism = new HeightStructuresFailureMechanism(); @@ -424,34 +555,37 @@ var mapData = map.Data; - var dataToMove = (MapLineData)map.Data.Collection.ElementAt(referenceLineIndex); + var dataToMove = (MapLineData) map.Data.Collection.ElementAt(referenceLineIndex); mapData.Remove(dataToMove); mapData.Add(dataToMove); var mapDataList = mapData.Collection.ToList(); // Precondition - var referenceLineData = (MapLineData)mapDataList[updatedRefenceLineLayerIndex]; + var referenceLineData = (MapLineData) mapDataList[updatedRefenceLineLayerIndex]; Assert.AreEqual("Referentielijn", referenceLineData.Name); - var sectionsData = (MapLineData)mapDataList[updatedSectionsLayerIndex]; + var sectionsData = (MapLineData) mapDataList[updatedSectionsLayerIndex]; Assert.AreEqual("Vakindeling", sectionsData.Name); - var sectionStartsData = (MapPointData)mapDataList[updateSectionStartLayerIndex]; + var sectionStartsData = (MapPointData) mapDataList[updateSectionStartLayerIndex]; Assert.AreEqual("Vakindeling (startpunten)", sectionStartsData.Name); - var sectionEndsData = (MapPointData)mapDataList[updatedSectionEndLayerIndex]; + var sectionEndsData = (MapPointData) mapDataList[updatedSectionEndLayerIndex]; Assert.AreEqual("Vakindeling (eindpunten)", sectionEndsData.Name); - var hydraulicLocationsData = (MapPointData)mapDataList[updatedHydraulicLocationsLayerIndex]; + var hydraulicLocationsData = (MapPointData) mapDataList[updatedHydraulicLocationsLayerIndex]; Assert.AreEqual("Hydraulische randvoorwaarden", hydraulicLocationsData.Name); - var foreshoreProfilesData = (MapLineData)mapDataList[updatedForeshoreProfilesLayerIndex]; + var foreshoreProfilesData = (MapLineData) mapDataList[updatedForeshoreProfilesLayerIndex]; Assert.AreEqual("Voorlandprofielen", foreshoreProfilesData.Name); - var structuresData = (MapPointData)mapDataList[updatedStructuresLayerIndex]; + var structuresData = (MapPointData) mapDataList[updatedStructuresLayerIndex]; Assert.AreEqual("Kunstwerken", structuresData.Name); + var calculationsData = (MapLineData) mapDataList[updatedCalculationsIndex]; + Assert.AreEqual("Berekeningen", calculationsData.Name); + var points = new List { new Point2D(2.0, 5.0), @@ -465,26 +599,29 @@ assessmentSection.NotifyObservers(); // Call - var actualReferenceLineData = (MapLineData)mapDataList[updatedRefenceLineLayerIndex]; + var actualReferenceLineData = (MapLineData) mapDataList[updatedRefenceLineLayerIndex]; Assert.AreEqual("Referentielijn", actualReferenceLineData.Name); - var actualSectionsData = (MapLineData)mapDataList[updatedSectionsLayerIndex]; + var actualSectionsData = (MapLineData) mapDataList[updatedSectionsLayerIndex]; Assert.AreEqual("Vakindeling", actualSectionsData.Name); - var actualSectionStartsData = (MapPointData)mapDataList[updateSectionStartLayerIndex]; + var actualSectionStartsData = (MapPointData) mapDataList[updateSectionStartLayerIndex]; Assert.AreEqual("Vakindeling (startpunten)", actualSectionStartsData.Name); - var actualSectionEndsData = (MapPointData)mapDataList[updatedSectionEndLayerIndex]; + var actualSectionEndsData = (MapPointData) mapDataList[updatedSectionEndLayerIndex]; Assert.AreEqual("Vakindeling (eindpunten)", actualSectionEndsData.Name); - var actualHydraulicLocationsData = (MapPointData)mapDataList[updatedHydraulicLocationsLayerIndex]; + var actualHydraulicLocationsData = (MapPointData) mapDataList[updatedHydraulicLocationsLayerIndex]; Assert.AreEqual("Hydraulische randvoorwaarden", actualHydraulicLocationsData.Name); - var actualForeshoreProfilesData = (MapLineData)mapDataList[updatedForeshoreProfilesLayerIndex]; + var actualForeshoreProfilesData = (MapLineData) mapDataList[updatedForeshoreProfilesLayerIndex]; Assert.AreEqual("Voorlandprofielen", actualForeshoreProfilesData.Name); - var actualStructuresData = (MapPointData)mapDataList[updatedStructuresLayerIndex]; + var actualStructuresData = (MapPointData) mapDataList[updatedStructuresLayerIndex]; Assert.AreEqual("Kunstwerken", actualStructuresData.Name); + + var actualCalculationsData = (MapLineData) mapDataList[updatedCalculationsIndex]; + Assert.AreEqual("Berekeningen", actualCalculationsData.Name); } } @@ -506,7 +643,7 @@ var newHeightStructuresFailureMechanismContext = new HeightStructuresFailureMechanismContext(new HeightStructuresFailureMechanism(), newAssessmentSection); using (var view = new HeightStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; view.Data = oldHeightStructuresFailureMechanismContext; view.Data = newHeightStructuresFailureMechanismContext; @@ -525,7 +662,7 @@ private static void AssertReferenceLineMapData(ReferenceLine referenceLine, MapData mapData) { Assert.IsInstanceOf(mapData); - var referenceLineData = (MapLineData)mapData; + var referenceLineData = (MapLineData) mapData; if (referenceLine == null) { CollectionAssert.IsEmpty(referenceLineData.Features.First().MapGeometries.First().PointCollections.First()); @@ -541,7 +678,7 @@ { Assert.NotNull(foreshoreProfiles, "foreshoreProfiles should never be null."); - var foreshoreProfilesData = (MapLineData)mapData; + var foreshoreProfilesData = (MapLineData) mapData; var foreshoreProfileArray = foreshoreProfiles.ToArray(); Assert.AreEqual(foreshoreProfileArray.Length, foreshoreProfilesData.Features.Length); @@ -559,7 +696,7 @@ { Assert.NotNull(structures, "structures should never be null."); - var structuresData = (MapPointData)mapData; + var structuresData = (MapPointData) mapData; var structuresArray = structures.ToArray(); Assert.AreEqual(structuresArray.Length, structuresData.Features.Length); @@ -576,7 +713,7 @@ private static void AssertHydraulicBoundaryLocationsMapData(HydraulicBoundaryDatabase database, MapData mapData) { Assert.IsInstanceOf(mapData); - var hydraulicLocationsMapData = (MapPointData)mapData; + var hydraulicLocationsMapData = (MapPointData) mapData; if (database == null) { CollectionAssert.IsEmpty(hydraulicLocationsMapData.Features.First().MapGeometries.First().PointCollections.First()); @@ -591,34 +728,59 @@ private static void AssertFailureMechanismSectionsStartPointMapData(IEnumerable sections, MapData mapData) { Assert.IsInstanceOf(mapData); - var sectionsStartPointData = (MapPointData)mapData; + var sectionsStartPointData = (MapPointData) mapData; CollectionAssert.AreEqual(sections.Select(s => s.GetStart()), sectionsStartPointData.Features.First().MapGeometries.First().PointCollections.First()); Assert.AreEqual("Vakindeling (startpunten)", mapData.Name); } private static void AssertFailureMechanismSectionsEndPointMapData(IEnumerable sections, MapData mapData) { Assert.IsInstanceOf(mapData); - var sectionsStartPointData = (MapPointData)mapData; + var sectionsStartPointData = (MapPointData) mapData; CollectionAssert.AreEqual(sections.Select(s => s.GetLast()), sectionsStartPointData.Features.First().MapGeometries.First().PointCollections.First()); Assert.AreEqual("Vakindeling (eindpunten)", mapData.Name); } + private static void AssertCalculationsMapData(IEnumerable> calculations, MapData mapData) + { + Assert.IsInstanceOf(mapData); + var calculationsMapData = (MapLineData) mapData; + var calculationsArray = calculations.ToArray(); + var calculationsFeatures = calculationsMapData.Features.ToArray(); + Assert.AreEqual(calculationsArray.Length, calculationsFeatures.Length); + + for (int index = 0; index < calculationsArray.Length; index++) + { + var geometries = calculationsFeatures[index].MapGeometries.ToArray(); + Assert.AreEqual(1, geometries.Length); + + StructuresCalculation calculation = calculationsArray[index]; + CollectionAssert.AreEquivalent(new[] + { + calculation.InputParameters.Structure.Location, + calculation.InputParameters.HydraulicBoundaryLocation.Location + }, + geometries[0].PointCollections.First()); + } + Assert.AreEqual("Berekeningen", mapData.Name); + } + private static void AssertEmptyMapData(MapDataCollection mapData) { Assert.IsInstanceOf(mapData); var mapDataList = mapData.Collection.ToList(); - Assert.AreEqual(7, mapDataList.Count); + Assert.AreEqual(8, mapDataList.Count); - var referenceLineMapData = (MapLineData)mapDataList[referenceLineIndex]; - var sectionsMapData = (MapLineData)mapDataList[sectionsIndex]; - var foreshoreProfilesMapData = (MapLineData)mapDataList[foreshoreProfilesIndex]; - var structuresMapData = (MapPointData)mapDataList[structuresIndex]; - var sectionsStartPointMapData = (MapPointData)mapDataList[sectionsStartPointIndex]; - var sectionsEndPointMapData = (MapPointData)mapDataList[sectionsEndPointIndex]; - var hydraulicBoundaryDatabaseMapData = (MapPointData)mapDataList[hydraulicBoundaryDatabaseIndex]; + var referenceLineMapData = (MapLineData) mapDataList[referenceLineIndex]; + var sectionsMapData = (MapLineData) mapDataList[sectionsIndex]; + var foreshoreProfilesMapData = (MapLineData) mapDataList[foreshoreProfilesIndex]; + var structuresMapData = (MapPointData) mapDataList[structuresIndex]; + var sectionsStartPointMapData = (MapPointData) mapDataList[sectionsStartPointIndex]; + var sectionsEndPointMapData = (MapPointData) mapDataList[sectionsEndPointIndex]; + var hydraulicBoundaryDatabaseMapData = (MapPointData) mapDataList[hydraulicBoundaryDatabaseIndex]; + var calculationsMapData = (MapLineData) mapDataList[calculationsIndex]; CollectionAssert.IsEmpty(referenceLineMapData.Features); CollectionAssert.IsEmpty(sectionsMapData.Features); @@ -627,6 +789,7 @@ CollectionAssert.IsEmpty(sectionsStartPointMapData.Features); CollectionAssert.IsEmpty(sectionsEndPointMapData.Features); CollectionAssert.IsEmpty(hydraulicBoundaryDatabaseMapData.Features); + CollectionAssert.IsEmpty(calculationsMapData.Features); Assert.AreEqual(RingtoetsCommonDataResources.ReferenceLine_DisplayName, referenceLineMapData.Name); Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanism_Sections_DisplayName, sectionsMapData.Name); @@ -635,6 +798,7 @@ Assert.AreEqual(GetSectionPointDisplayName(RingtoetsCommonFormsResources.FailureMechanismSections_StartPoints_DisplayName), sectionsStartPointMapData.Name); Assert.AreEqual(GetSectionPointDisplayName(RingtoetsCommonFormsResources.FailureMechanismSections_EndPoints_DisplayName), sectionsEndPointMapData.Name); Assert.AreEqual(RingtoetsCommonDataResources.HydraulicBoundaryConditions_DisplayName, hydraulicBoundaryDatabaseMapData.Name); + Assert.AreEqual(RingtoetsCommonDataResources.FailureMechanism_Calculations_DisplayName, calculationsMapData.Name); } private static string GetSectionPointDisplayName(string name) Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismViewTest.cs =================================================================== diff -u -r52289b39d16efbf1ea1cd2980d62a8541527d23c -radddff4153e676955aceeb958276c710a731cec4 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismViewTest.cs (.../PipingFailureMechanismViewTest.cs) (revision 52289b39d16efbf1ea1cd2980d62a8541527d23c) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismViewTest.cs (.../PipingFailureMechanismViewTest.cs) (revision adddff4153e676955aceeb958276c710a731cec4) @@ -199,7 +199,7 @@ }); var surfaceLineA = new RingtoetsPipingSurfaceLine(); - surfaceLineA.SetGeometry(new [] + surfaceLineA.SetGeometry(new[] { new Point3D(0.0, 0.0, 1.0), new Point3D(3.0, 0.0, 1.7) @@ -632,7 +632,7 @@ var stochasticSoilModelsData = (MapLineData) mapDataList[updatedStochasticSoilModelsLayerIndex]; Assert.AreEqual("Stochastische ondergrondmodellen", stochasticSoilModelsData.Name); - var calculationsData = (MapLineData)mapDataList[updatedCalculationsIndex]; + var calculationsData = (MapLineData) mapDataList[updatedCalculationsIndex]; Assert.AreEqual("Berekeningen", calculationsData.Name); var points = new List @@ -669,7 +669,7 @@ var actualStochasticSoilModelsData = (MapLineData) mapDataList[updatedStochasticSoilModelsLayerIndex]; Assert.AreEqual("Stochastische ondergrondmodellen", actualStochasticSoilModelsData.Name); - var actualCalculationsData = (MapLineData)mapDataList[updatedCalculationsIndex]; + var actualCalculationsData = (MapLineData) mapDataList[updatedCalculationsIndex]; Assert.AreEqual("Berekeningen", actualCalculationsData.Name); } } @@ -800,18 +800,18 @@ var calculationsFeatures = calculationsMapData.Features.ToArray(); Assert.AreEqual(calculationsArray.Length, calculationsFeatures.Length); - for (int index = 0; index < calculationsArray.Length; index++) { var geometries = calculationsFeatures[index].MapGeometries.ToArray(); Assert.AreEqual(1, geometries.Length); PipingCalculationScenario calculation = calculationsArray[index]; - CollectionAssert.AreEquivalent(new[] { - calculation.InputParameters.SurfaceLine.ReferenceLineIntersectionWorldPoint, - calculation.InputParameters.HydraulicBoundaryLocation.Location - }, - geometries[0].PointCollections.First()); + CollectionAssert.AreEquivalent(new[] + { + calculation.InputParameters.SurfaceLine.ReferenceLineIntersectionWorldPoint, + calculation.InputParameters.HydraulicBoundaryLocation.Location + }, + geometries[0].PointCollections.First()); } Assert.AreEqual("Berekeningen", mapData.Name); } @@ -831,7 +831,7 @@ var sectionsStartPointMapData = (MapPointData) mapDataList[sectionsStartPointIndex]; var sectionsEndPointMapData = (MapPointData) mapDataList[sectionsEndPointIndex]; var hydraulicBoundaryDatabaseMapData = (MapPointData) mapDataList[hydraulicBoundaryDatabaseIndex]; - var calculationsMapData = (MapLineData)mapDataList[calculationsIndex]; + var calculationsMapData = (MapLineData) mapDataList[calculationsIndex]; CollectionAssert.IsEmpty(referenceLineMapData.Features); CollectionAssert.IsEmpty(sectionsMapData.Features); Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismView.cs =================================================================== diff -u -r07e54440666b51d4a93039da2f8b5fa031fe4fe2 -radddff4153e676955aceeb958276c710a731cec4 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismView.cs (.../StabilityPointStructuresFailureMechanismView.cs) (revision 07e54440666b51d4a93039da2f8b5fa031fe4fe2) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismView.cs (.../StabilityPointStructuresFailureMechanismView.cs) (revision adddff4153e676955aceeb958276c710a731cec4) @@ -20,13 +20,16 @@ // All rights reserved. using System.Collections.Generic; +using System.Linq; using System.Windows.Forms; using Core.Common.Base; using Core.Components.Gis.Data; using Core.Components.Gis.Forms; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Forms.Views; using Ringtoets.StabilityPointStructures.Data; using Ringtoets.StabilityPointStructures.Forms.PresentationObjects; @@ -46,13 +49,18 @@ private readonly Observer foreshoreProfilesObserver; private readonly Observer structuresObserver; + private readonly RecursiveObserver calculationInputObserver; + private readonly RecursiveObserver calculationGroupObserver; + private readonly RecursiveObserver> calculationObserver; + private readonly MapLineData referenceLineMapData; private readonly MapLineData sectionsMapData; private readonly MapPointData sectionsStartPointMapData; private readonly MapPointData sectionsEndPointMapData; private readonly MapPointData hydraulicBoundaryDatabaseMapData; private readonly MapLineData foreshoreProfilesMapData; private readonly MapPointData structuresMapData; + private readonly MapLineData calculationsMapData; private StabilityPointStructuresFailureMechanismContext data; @@ -68,6 +76,11 @@ foreshoreProfilesObserver = new Observer(UpdateMapData); structuresObserver = new Observer(UpdateMapData); + calculationInputObserver = new RecursiveObserver( + UpdateMapData, pcg => pcg.Children.Concat(pcg.Children.OfType>().Select(pc => pc.InputParameters))); + calculationGroupObserver = new RecursiveObserver(UpdateMapData, pcg => pcg.Children); + calculationObserver = new RecursiveObserver>(UpdateMapData, pcg => pcg.Children); + referenceLineMapData = RingtoetsMapDataFactory.CreateReferenceLineMapData(); hydraulicBoundaryDatabaseMapData = RingtoetsMapDataFactory.CreateHydraulicBoundaryDatabaseMapData(); foreshoreProfilesMapData = RingtoetsMapDataFactory.CreateForeshoreProfileMapData(); @@ -76,6 +89,7 @@ sectionsMapData = RingtoetsMapDataFactory.CreateFailureMechanismSectionsMapData(); sectionsStartPointMapData = RingtoetsMapDataFactory.CreateFailureMechanismSectionsStartPointMapData(); sectionsEndPointMapData = RingtoetsMapDataFactory.CreateFailureMechanismSectionsEndPointMapData(); + calculationsMapData = RingtoetsMapDataFactory.CreateCalculationsMapData(); mapControl.Data.Add(referenceLineMapData); mapControl.Data.Add(sectionsMapData); @@ -84,6 +98,7 @@ mapControl.Data.Add(hydraulicBoundaryDatabaseMapData); mapControl.Data.Add(foreshoreProfilesMapData); mapControl.Data.Add(structuresMapData); + mapControl.Data.Add(calculationsMapData); mapControl.Data.Name = StabilityPointStructuresDataResources.StabilityPointStructuresFailureMechanism_DisplayName; mapControl.Data.NotifyObservers(); @@ -105,6 +120,9 @@ assessmentSectionObserver.Observable = null; foreshoreProfilesObserver.Observable = null; structuresObserver.Observable = null; + calculationInputObserver.Observable = null; + calculationGroupObserver.Observable = null; + calculationObserver.Observable = null; Map.ResetMapData(); return; @@ -114,6 +132,9 @@ assessmentSectionObserver.Observable = data.Parent; foreshoreProfilesObserver.Observable = data.WrappedData.ForeshoreProfiles; structuresObserver.Observable = data.WrappedData.StabilityPointStructures; + calculationInputObserver.Observable = data.WrappedData.CalculationsGroup; + calculationGroupObserver.Observable = data.WrappedData.CalculationsGroup; + calculationObserver.Observable = data.WrappedData.CalculationsGroup; UpdateMapData(); } @@ -132,6 +153,9 @@ failureMechanismObserver.Dispose(); assessmentSectionObserver.Dispose(); foreshoreProfilesObserver.Dispose(); + calculationInputObserver.Dispose(); + calculationGroupObserver.Dispose(); + calculationObserver.Dispose(); if (disposing && (components != null)) { @@ -147,6 +171,7 @@ HydraulicBoundaryDatabase hydraulicBoundaryDatabase = null; IEnumerable foreshoreProfiles = null; IEnumerable structures = null; + CalculationGroup calculationGroup = null; if (data != null) { @@ -155,6 +180,7 @@ hydraulicBoundaryDatabase = data.Parent.HydraulicBoundaryDatabase; foreshoreProfiles = data.WrappedData.ForeshoreProfiles; structures = data.WrappedData.StabilityPointStructures; + calculationGroup = data.WrappedData.CalculationsGroup; } referenceLineMapData.Features = RingtoetsMapDataFeaturesFactory.CreateReferenceLineFeatures(referenceLine, data.Parent.Id, data.Parent.Name); @@ -164,6 +190,8 @@ hydraulicBoundaryDatabaseMapData.Features = RingtoetsMapDataFeaturesFactory.CreateHydraulicBoundaryDatabaseFeaturesWithDefaultLabels(hydraulicBoundaryDatabase); foreshoreProfilesMapData.Features = RingtoetsMapDataFeaturesFactory.CreateForeshoreProfilesFeatures(foreshoreProfiles); structuresMapData.Features = RingtoetsMapDataFeaturesFactory.CreateStructuresFeatures(structures); + calculationsMapData.Features = RingtoetsMapDataFeaturesFactory.CreateStructureCalculationsFeatures + (calculationGroup.GetCalculations().Cast>()); mapControl.Data.NotifyObservers(); } Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismViewTest.cs =================================================================== diff -u -r52289b39d16efbf1ea1cd2980d62a8541527d23c -radddff4153e676955aceeb958276c710a731cec4 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismViewTest.cs (.../StabilityPointStructuresFailureMechanismViewTest.cs) (revision 52289b39d16efbf1ea1cd2980d62a8541527d23c) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismViewTest.cs (.../StabilityPointStructuresFailureMechanismViewTest.cs) (revision adddff4153e676955aceeb958276c710a731cec4) @@ -34,6 +34,7 @@ using Ringtoets.Common.Data.Contribution; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.TestUtil; using Ringtoets.HydraRing.Data; @@ -57,6 +58,7 @@ private const int hydraulicBoundaryDatabaseIndex = 4; private const int foreshoreProfilesIndex = 5; private const int structuresIndex = 6; + private const int calculationsIndex = 7; [Test] public void DefaultConstructor_DefaultValues() @@ -81,7 +83,7 @@ // Assert Assert.AreEqual(1, view.Controls.Count); Assert.AreSame(view.Map, view.Controls[0]); - Assert.AreEqual(DockStyle.Fill, ((Control)view.Map).Dock); + Assert.AreEqual(DockStyle.Fill, ((Control) view.Map).Dock); Assert.AreEqual(StabilityPointStructuresDataResources.StabilityPointStructuresFailureMechanism_DisplayName, view.Map.Data.Name); AssertEmptyMapData(view.Map.Data); } @@ -130,7 +132,7 @@ view.Data = failureMechanismContext; // Precondition - Assert.AreEqual(7, view.Map.Data.Collection.Count()); + Assert.AreEqual(8, view.Map.Data.Collection.Count()); // Call view.Data = null; @@ -164,7 +166,7 @@ // Setup using (var view = new StabilityPointStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var geometryPoints = new[] { @@ -210,7 +212,7 @@ Assert.IsInstanceOf(mapData); var mapDataList = mapData.Collection.ToList(); - Assert.AreEqual(7, mapDataList.Count); + Assert.AreEqual(8, mapDataList.Count); AssertReferenceLineMapData(assessmentSection.ReferenceLine, mapDataList[referenceLineIndex]); MapDataTestHelper.AssertFailureMechanismSectionsMapData(failureMechanism.Sections, mapDataList[sectionsIndex]); AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, mapDataList[sectionsStartPointIndex]); @@ -226,7 +228,7 @@ // Setup using (var view = new StabilityPointStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var hydraulicBoundaryDatabase1 = new HydraulicBoundaryDatabase { @@ -272,7 +274,7 @@ // Setup using (var view = new StabilityPointStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var points1 = new List { @@ -316,16 +318,16 @@ // Setup using (var view = new StabilityPointStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var failureMechanism = new StabilityPointStructuresFailureMechanism(); var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); view.Data = failureMechanismContext; - var sectionMapData = (MapLineData)map.Data.Collection.ElementAt(sectionsIndex); - var sectionStartsMapData = (MapPointData)map.Data.Collection.ElementAt(sectionsStartPointIndex); - var sectionsEndsMapData = (MapPointData)map.Data.Collection.ElementAt(sectionsEndPointIndex); + var sectionMapData = (MapLineData) map.Data.Collection.ElementAt(sectionsIndex); + var sectionStartsMapData = (MapPointData) map.Data.Collection.ElementAt(sectionsStartPointIndex); + var sectionsEndsMapData = (MapPointData) map.Data.Collection.ElementAt(sectionsEndPointIndex); // Call failureMechanism.AddSection(new FailureMechanismSection(string.Empty, new[] @@ -348,7 +350,7 @@ // Setup using (var view = new StabilityPointStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var failureMechanism = new StabilityPointStructuresFailureMechanism(); var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); @@ -377,7 +379,7 @@ // Setup using (var view = new StabilityPointStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var failureMechanism = new StabilityPointStructuresFailureMechanism(); var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); @@ -401,20 +403,149 @@ } [Test] + public void UpdateObserver_CalculationGroupUpdated_MapDataUpdated() + { + // Setup + using (var view = new StabilityPointStructuresFailureMechanismView()) + { + var map = (MapControl) view.Controls[0]; + + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); + + var calculationLocationA = new Point2D(1.2, 2.3); + var calculationLocationB = new Point2D(2.7, 2.0); + + var hydraulicBoundaryLocationA = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3); + var hydraulicBoundaryLocationB = new HydraulicBoundaryLocation(1, string.Empty, 7.7, 12.6); + + var calculationA = new StructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocationA, + Structure = new TestStabilityPointStructure(calculationLocationA) + } + }; + + var calculationB = new StructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocationB, + Structure = new TestStabilityPointStructure(calculationLocationB) + } + }; + + failureMechanism.CalculationsGroup.Children.Add(calculationA); + + view.Data = failureMechanismContext; + + var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); + + failureMechanism.CalculationsGroup.Children.Add(calculationB); + + // Call + failureMechanism.CalculationsGroup.NotifyObservers(); + + // Assert + AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); + } + } + + [Test] + public void UpdateObserver_CalculationInputUpdated_MapDataUpdated() + { + // Setup + using (var view = new StabilityPointStructuresFailureMechanismView()) + { + var map = (MapControl) view.Controls[0]; + + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); + + var calculationLocationA = new Point2D(1.2, 2.3); + var calculationLocationB = new Point2D(2.7, 2.0); + + var hydraulicBoundaryLocationA = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3); + + var calculationA = new StructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocationA, + Structure = new TestStabilityPointStructure(calculationLocationA) + } + }; + + view.Data = failureMechanismContext; + + var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); + + calculationA.InputParameters.Structure = new TestStabilityPointStructure(calculationLocationB); + + // Call + calculationA.InputParameters.NotifyObservers(); + + // Assert + AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); + } + } + + [Test] + public void UpdateObserver_CalculationUpdated_MapDataUpdated() + { + // Setup + using (var view = new StabilityPointStructuresFailureMechanismView()) + { + var map = (MapControl) view.Controls[0]; + + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, new TestAssessmentSection()); + + var calculationLocationA = new Point2D(1.2, 2.3); + + var hydraulicBoundaryLocationA = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3); + + var calculationA = new StructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocationA, + Structure = new TestStabilityPointStructure(calculationLocationA) + } + }; + + view.Data = failureMechanismContext; + + var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); + + calculationA.Name = "new name"; + + // Call + calculationA.NotifyObservers(); + + // Assert + AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); + } + } + + [Test] public void UpdateObserver_DataUpdated_MapLayersSameOrder() { // Setup - const int updatedRefenceLineLayerIndex = referenceLineIndex + 6; + const int updatedRefenceLineLayerIndex = referenceLineIndex + 7; const int updatedSectionsLayerIndex = sectionsIndex - 1; const int updateSectionStartLayerIndex = sectionsStartPointIndex - 1; const int updatedSectionEndLayerIndex = sectionsEndPointIndex - 1; const int updatedHydraulicLocationsLayerIndex = hydraulicBoundaryDatabaseIndex - 1; const int updatedForeshoreProfilesLayerIndex = foreshoreProfilesIndex - 1; - const int updatedStructuresLayerIndex = structuresIndex- 1; + const int updatedStructuresLayerIndex = structuresIndex - 1; + const int updatedCalculationsIndex = calculationsIndex - 1; using (var view = new StabilityPointStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var assessmentSection = new TestAssessmentSection(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); @@ -424,34 +555,37 @@ var mapData = map.Data; - var dataToMove = (MapLineData)map.Data.Collection.ElementAt(referenceLineIndex); + var dataToMove = (MapLineData) map.Data.Collection.ElementAt(referenceLineIndex); mapData.Remove(dataToMove); mapData.Add(dataToMove); var mapDataList = mapData.Collection.ToList(); // Precondition - var referenceLineData = (MapLineData)mapDataList[updatedRefenceLineLayerIndex]; + var referenceLineData = (MapLineData) mapDataList[updatedRefenceLineLayerIndex]; Assert.AreEqual("Referentielijn", referenceLineData.Name); - var sectionsData = (MapLineData)mapDataList[updatedSectionsLayerIndex]; + var sectionsData = (MapLineData) mapDataList[updatedSectionsLayerIndex]; Assert.AreEqual("Vakindeling", sectionsData.Name); - var sectionStartsData = (MapPointData)mapDataList[updateSectionStartLayerIndex]; + var sectionStartsData = (MapPointData) mapDataList[updateSectionStartLayerIndex]; Assert.AreEqual("Vakindeling (startpunten)", sectionStartsData.Name); - var sectionEndsData = (MapPointData)mapDataList[updatedSectionEndLayerIndex]; + var sectionEndsData = (MapPointData) mapDataList[updatedSectionEndLayerIndex]; Assert.AreEqual("Vakindeling (eindpunten)", sectionEndsData.Name); - var hydraulicLocationsData = (MapPointData)mapDataList[updatedHydraulicLocationsLayerIndex]; + var hydraulicLocationsData = (MapPointData) mapDataList[updatedHydraulicLocationsLayerIndex]; Assert.AreEqual("Hydraulische randvoorwaarden", hydraulicLocationsData.Name); - var foreshoreProfilesData = (MapLineData)mapDataList[updatedForeshoreProfilesLayerIndex]; + var foreshoreProfilesData = (MapLineData) mapDataList[updatedForeshoreProfilesLayerIndex]; Assert.AreEqual("Voorlandprofielen", foreshoreProfilesData.Name); - var structuresData = (MapPointData)mapDataList[updatedStructuresLayerIndex]; + var structuresData = (MapPointData) mapDataList[updatedStructuresLayerIndex]; Assert.AreEqual("Kunstwerken", structuresData.Name); + var calculationsData = (MapLineData) mapDataList[updatedCalculationsIndex]; + Assert.AreEqual("Berekeningen", calculationsData.Name); + var points = new List { new Point2D(2.0, 5.0), @@ -465,26 +599,29 @@ assessmentSection.NotifyObservers(); // Call - var actualReferenceLineData = (MapLineData)mapDataList[updatedRefenceLineLayerIndex]; + var actualReferenceLineData = (MapLineData) mapDataList[updatedRefenceLineLayerIndex]; Assert.AreEqual("Referentielijn", actualReferenceLineData.Name); - var actualSectionsData = (MapLineData)mapDataList[updatedSectionsLayerIndex]; + var actualSectionsData = (MapLineData) mapDataList[updatedSectionsLayerIndex]; Assert.AreEqual("Vakindeling", actualSectionsData.Name); - var actualSectionStartsData = (MapPointData)mapDataList[updateSectionStartLayerIndex]; + var actualSectionStartsData = (MapPointData) mapDataList[updateSectionStartLayerIndex]; Assert.AreEqual("Vakindeling (startpunten)", actualSectionStartsData.Name); - var actualSectionEndsData = (MapPointData)mapDataList[updatedSectionEndLayerIndex]; + var actualSectionEndsData = (MapPointData) mapDataList[updatedSectionEndLayerIndex]; Assert.AreEqual("Vakindeling (eindpunten)", actualSectionEndsData.Name); - var actualHydraulicLocationsData = (MapPointData)mapDataList[updatedHydraulicLocationsLayerIndex]; + var actualHydraulicLocationsData = (MapPointData) mapDataList[updatedHydraulicLocationsLayerIndex]; Assert.AreEqual("Hydraulische randvoorwaarden", actualHydraulicLocationsData.Name); - var actualForeshoreProfilesData = (MapLineData)mapDataList[updatedForeshoreProfilesLayerIndex]; + var actualForeshoreProfilesData = (MapLineData) mapDataList[updatedForeshoreProfilesLayerIndex]; Assert.AreEqual("Voorlandprofielen", actualForeshoreProfilesData.Name); - var actualStructuresData = (MapPointData)mapDataList[updatedStructuresLayerIndex]; + var actualStructuresData = (MapPointData) mapDataList[updatedStructuresLayerIndex]; Assert.AreEqual("Kunstwerken", actualStructuresData.Name); + + var actualCalculationsData = (MapLineData) mapDataList[updatedCalculationsIndex]; + Assert.AreEqual("Berekeningen", actualCalculationsData.Name); } } @@ -506,7 +643,7 @@ var newStabilityPointStructuresFailureMechanismContext = new StabilityPointStructuresFailureMechanismContext(new StabilityPointStructuresFailureMechanism(), newAssessmentSection); using (var view = new StabilityPointStructuresFailureMechanismView()) { - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; view.Data = oldStabilityPointStructuresFailureMechanismContext; view.Data = newStabilityPointStructuresFailureMechanismContext; @@ -525,7 +662,7 @@ private static void AssertReferenceLineMapData(ReferenceLine referenceLine, MapData mapData) { Assert.IsInstanceOf(mapData); - var referenceLineData = (MapLineData)mapData; + var referenceLineData = (MapLineData) mapData; if (referenceLine == null) { CollectionAssert.IsEmpty(referenceLineData.Features.First().MapGeometries.First().PointCollections.First()); @@ -541,7 +678,7 @@ { Assert.NotNull(foreshoreProfiles, "foreshoreProfiles should never be null."); - var foreshoreProfilesData = (MapLineData)mapData; + var foreshoreProfilesData = (MapLineData) mapData; var foreshoreProfileArray = foreshoreProfiles.ToArray(); Assert.AreEqual(foreshoreProfileArray.Length, foreshoreProfilesData.Features.Length); @@ -559,7 +696,7 @@ { Assert.NotNull(structures, "structures should never be null."); - var structuresData = (MapPointData)mapData; + var structuresData = (MapPointData) mapData; var structuresArray = structures.ToArray(); Assert.AreEqual(structuresArray.Length, structuresData.Features.Length); @@ -576,7 +713,7 @@ private static void AssertHydraulicBoundaryLocationsMapData(HydraulicBoundaryDatabase database, MapData mapData) { Assert.IsInstanceOf(mapData); - var hydraulicLocationsMapData = (MapPointData)mapData; + var hydraulicLocationsMapData = (MapPointData) mapData; if (database == null) { CollectionAssert.IsEmpty(hydraulicLocationsMapData.Features.First().MapGeometries.First().PointCollections.First()); @@ -591,34 +728,59 @@ private static void AssertFailureMechanismSectionsStartPointMapData(IEnumerable sections, MapData mapData) { Assert.IsInstanceOf(mapData); - var sectionsStartPointData = (MapPointData)mapData; + var sectionsStartPointData = (MapPointData) mapData; CollectionAssert.AreEqual(sections.Select(s => s.GetStart()), sectionsStartPointData.Features.First().MapGeometries.First().PointCollections.First()); Assert.AreEqual("Vakindeling (startpunten)", mapData.Name); } private static void AssertFailureMechanismSectionsEndPointMapData(IEnumerable sections, MapData mapData) { Assert.IsInstanceOf(mapData); - var sectionsStartPointData = (MapPointData)mapData; + var sectionsStartPointData = (MapPointData) mapData; CollectionAssert.AreEqual(sections.Select(s => s.GetLast()), sectionsStartPointData.Features.First().MapGeometries.First().PointCollections.First()); Assert.AreEqual("Vakindeling (eindpunten)", mapData.Name); } + private static void AssertCalculationsMapData(IEnumerable> calculations, MapData mapData) + { + Assert.IsInstanceOf(mapData); + var calculationsMapData = (MapLineData) mapData; + var calculationsArray = calculations.ToArray(); + var calculationsFeatures = calculationsMapData.Features.ToArray(); + Assert.AreEqual(calculationsArray.Length, calculationsFeatures.Length); + + for (int index = 0; index < calculationsArray.Length; index++) + { + var geometries = calculationsFeatures[index].MapGeometries.ToArray(); + Assert.AreEqual(1, geometries.Length); + + StructuresCalculation calculation = calculationsArray[index]; + CollectionAssert.AreEquivalent(new[] + { + calculation.InputParameters.Structure.Location, + calculation.InputParameters.HydraulicBoundaryLocation.Location + }, + geometries[0].PointCollections.First()); + } + Assert.AreEqual("Berekeningen", mapData.Name); + } + private static void AssertEmptyMapData(MapDataCollection mapData) { Assert.IsInstanceOf(mapData); var mapDataList = mapData.Collection.ToList(); - Assert.AreEqual(7, mapDataList.Count); + Assert.AreEqual(8, mapDataList.Count); - var referenceLineMapData = (MapLineData)mapDataList[referenceLineIndex]; - var sectionsMapData = (MapLineData)mapDataList[sectionsIndex]; - var foreshoreProfilesMapData = (MapLineData)mapDataList[foreshoreProfilesIndex]; - var structuresMapData = (MapPointData)mapDataList[structuresIndex]; - var sectionsStartPointMapData = (MapPointData)mapDataList[sectionsStartPointIndex]; - var sectionsEndPointMapData = (MapPointData)mapDataList[sectionsEndPointIndex]; - var hydraulicBoundaryDatabaseMapData = (MapPointData)mapDataList[hydraulicBoundaryDatabaseIndex]; + var referenceLineMapData = (MapLineData) mapDataList[referenceLineIndex]; + var sectionsMapData = (MapLineData) mapDataList[sectionsIndex]; + var foreshoreProfilesMapData = (MapLineData) mapDataList[foreshoreProfilesIndex]; + var structuresMapData = (MapPointData) mapDataList[structuresIndex]; + var sectionsStartPointMapData = (MapPointData) mapDataList[sectionsStartPointIndex]; + var sectionsEndPointMapData = (MapPointData) mapDataList[sectionsEndPointIndex]; + var hydraulicBoundaryDatabaseMapData = (MapPointData) mapDataList[hydraulicBoundaryDatabaseIndex]; + var calculationsMapData = (MapLineData) mapDataList[calculationsIndex]; CollectionAssert.IsEmpty(referenceLineMapData.Features); CollectionAssert.IsEmpty(sectionsMapData.Features); @@ -627,6 +789,7 @@ CollectionAssert.IsEmpty(sectionsStartPointMapData.Features); CollectionAssert.IsEmpty(sectionsEndPointMapData.Features); CollectionAssert.IsEmpty(hydraulicBoundaryDatabaseMapData.Features); + CollectionAssert.IsEmpty(calculationsMapData.Features); Assert.AreEqual(RingtoetsCommonDataResources.ReferenceLine_DisplayName, referenceLineMapData.Name); Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanism_Sections_DisplayName, sectionsMapData.Name); @@ -635,6 +798,7 @@ Assert.AreEqual(GetSectionPointDisplayName(RingtoetsCommonFormsResources.FailureMechanismSections_StartPoints_DisplayName), sectionsStartPointMapData.Name); Assert.AreEqual(GetSectionPointDisplayName(RingtoetsCommonFormsResources.FailureMechanismSections_EndPoints_DisplayName), sectionsEndPointMapData.Name); Assert.AreEqual(RingtoetsCommonDataResources.HydraulicBoundaryConditions_DisplayName, hydraulicBoundaryDatabaseMapData.Name); + Assert.AreEqual(RingtoetsCommonDataResources.FailureMechanism_Calculations_DisplayName, calculationsMapData.Name); } private static string GetSectionPointDisplayName(string name) Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Views/StabilityStoneCoverFailureMechanismViewTest.cs =================================================================== diff -u -re866d883e0603dc8613eebc581953a9b2a8f5986 -radddff4153e676955aceeb958276c710a731cec4 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Views/StabilityStoneCoverFailureMechanismViewTest.cs (.../StabilityStoneCoverFailureMechanismViewTest.cs) (revision e866d883e0603dc8613eebc581953a9b2a8f5986) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Views/StabilityStoneCoverFailureMechanismViewTest.cs (.../StabilityStoneCoverFailureMechanismViewTest.cs) (revision adddff4153e676955aceeb958276c710a731cec4) @@ -714,20 +714,23 @@ var sectionsStartPointMapData = (MapPointData)mapDataList[sectionsStartPointIndex]; var sectionsEndPointMapData = (MapPointData)mapDataList[sectionsEndPointIndex]; var hydraulicBoundaryDatabaseMapData = (MapPointData)mapDataList[hydraulicBoundaryDatabaseIndex]; + var calculationsMapData = (MapLineData)mapDataList[calculationsIndex]; CollectionAssert.IsEmpty(referenceLineMapData.Features); CollectionAssert.IsEmpty(sectionsMapData.Features); CollectionAssert.IsEmpty(foreshoreProfilesMapData.Features); CollectionAssert.IsEmpty(sectionsStartPointMapData.Features); CollectionAssert.IsEmpty(sectionsEndPointMapData.Features); CollectionAssert.IsEmpty(hydraulicBoundaryDatabaseMapData.Features); + CollectionAssert.IsEmpty(calculationsMapData.Features); Assert.AreEqual(RingtoetsCommonDataResources.ReferenceLine_DisplayName, referenceLineMapData.Name); Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanism_Sections_DisplayName, sectionsMapData.Name); Assert.AreEqual(RingtoetsCommonFormsResources.ForeshoreProfiles_DisplayName, foreshoreProfilesMapData.Name); Assert.AreEqual(GetSectionPointDisplayName(RingtoetsCommonFormsResources.FailureMechanismSections_StartPoints_DisplayName), sectionsStartPointMapData.Name); Assert.AreEqual(GetSectionPointDisplayName(RingtoetsCommonFormsResources.FailureMechanismSections_EndPoints_DisplayName), sectionsEndPointMapData.Name); Assert.AreEqual(RingtoetsCommonDataResources.HydraulicBoundaryConditions_DisplayName, hydraulicBoundaryDatabaseMapData.Name); + Assert.AreEqual(RingtoetsCommonDataResources.FailureMechanism_Calculations_DisplayName, calculationsMapData.Name); } private static string GetSectionPointDisplayName(string name) Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Views/WaveImpactAsphaltCoverFailureMechanismViewTest.cs =================================================================== diff -u -re866d883e0603dc8613eebc581953a9b2a8f5986 -radddff4153e676955aceeb958276c710a731cec4 --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Views/WaveImpactAsphaltCoverFailureMechanismViewTest.cs (.../WaveImpactAsphaltCoverFailureMechanismViewTest.cs) (revision e866d883e0603dc8613eebc581953a9b2a8f5986) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Views/WaveImpactAsphaltCoverFailureMechanismViewTest.cs (.../WaveImpactAsphaltCoverFailureMechanismViewTest.cs) (revision adddff4153e676955aceeb958276c710a731cec4) @@ -713,21 +713,24 @@ var foreshoreProfilesMapData = (MapLineData) mapDataList[foreshoreProfilesIndex]; var sectionsStartPointMapData = (MapPointData) mapDataList[sectionsStartPointIndex]; var sectionsEndPointMapData = (MapPointData) mapDataList[sectionsEndPointIndex]; - var hydraulicBoundaryDatabaseMapData = (MapPointData) mapDataList[hydraulicBoundaryDatabaseIndex]; + var hydraulicBoundaryDatabaseMapData = (MapPointData)mapDataList[hydraulicBoundaryDatabaseIndex]; + var calculationsMapData = (MapLineData)mapDataList[calculationsIndex]; CollectionAssert.IsEmpty(referenceLineMapData.Features); CollectionAssert.IsEmpty(sectionsMapData.Features); CollectionAssert.IsEmpty(foreshoreProfilesMapData.Features); CollectionAssert.IsEmpty(sectionsStartPointMapData.Features); CollectionAssert.IsEmpty(sectionsEndPointMapData.Features); CollectionAssert.IsEmpty(hydraulicBoundaryDatabaseMapData.Features); + CollectionAssert.IsEmpty(calculationsMapData.Features); Assert.AreEqual(RingtoetsCommonDataResources.ReferenceLine_DisplayName, referenceLineMapData.Name); Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanism_Sections_DisplayName, sectionsMapData.Name); Assert.AreEqual(RingtoetsCommonFormsResources.ForeshoreProfiles_DisplayName, foreshoreProfilesMapData.Name); Assert.AreEqual(GetSectionPointDisplayName(RingtoetsCommonFormsResources.FailureMechanismSections_StartPoints_DisplayName), sectionsStartPointMapData.Name); Assert.AreEqual(GetSectionPointDisplayName(RingtoetsCommonFormsResources.FailureMechanismSections_EndPoints_DisplayName), sectionsEndPointMapData.Name); Assert.AreEqual(RingtoetsCommonDataResources.HydraulicBoundaryConditions_DisplayName, hydraulicBoundaryDatabaseMapData.Name); + Assert.AreEqual(RingtoetsCommonDataResources.FailureMechanism_Calculations_DisplayName, calculationsMapData.Name); } private static string GetSectionPointDisplayName(string name)