Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismView.cs =================================================================== diff -u -r2a81f01756e227d5ce93717b21b87e8a5cd5fcbb -r6e5757c5c7aa457696aba585ea8e3cd9f1f343b7 --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismView.cs (.../WaveImpactAsphaltCoverFailureMechanismView.cs) (revision 2a81f01756e227d5ce93717b21b87e8a5cd5fcbb) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismView.cs (.../WaveImpactAsphaltCoverFailureMechanismView.cs) (revision 6e5757c5c7aa457696aba585ea8e3cd9f1f343b7) @@ -46,12 +46,14 @@ public partial class WaveImpactAsphaltCoverFailureMechanismView : UserControl, IMapView { private readonly MapLineData referenceLineMapData; - private readonly MapLineData sectionsMapData; - private readonly MapPointData sectionsStartPointMapData; - private readonly MapPointData sectionsEndPointMapData; private readonly MapPointData hydraulicBoundaryLocationsMapData; private readonly MapLineData foreshoreProfilesMapData; private readonly MapLineData calculationsMapData; + + private readonly MapLineData sectionsMapData; + private readonly MapPointData sectionsStartPointMapData; + private readonly MapPointData sectionsEndPointMapData; + private Observer failureMechanismObserver; private Observer assessmentSectionObserver; private Observer hydraulicBoundaryLocationsObserver; @@ -100,15 +102,20 @@ referenceLineMapData = RingtoetsMapDataFactory.CreateReferenceLineMapData(); hydraulicBoundaryLocationsMapData = RingtoetsMapDataFactory.CreateHydraulicBoundaryLocationsMapData(); foreshoreProfilesMapData = RingtoetsMapDataFactory.CreateForeshoreProfileMapData(); + calculationsMapData = RingtoetsMapDataFactory.CreateCalculationsMapData(); + + MapDataCollection sectionsMapDataCollection = RingtoetsMapDataFactory.CreateSectionsMapDataCollection(); sectionsMapData = RingtoetsMapDataFactory.CreateFailureMechanismSectionsMapData(); sectionsStartPointMapData = RingtoetsMapDataFactory.CreateFailureMechanismSectionsStartPointMapData(); sectionsEndPointMapData = RingtoetsMapDataFactory.CreateFailureMechanismSectionsEndPointMapData(); - calculationsMapData = RingtoetsMapDataFactory.CreateCalculationsMapData(); mapDataCollection.Add(referenceLineMapData); - mapDataCollection.Add(sectionsMapData); - mapDataCollection.Add(sectionsStartPointMapData); - mapDataCollection.Add(sectionsEndPointMapData); + + sectionsMapDataCollection.Add(sectionsMapData); + sectionsMapDataCollection.Add(sectionsStartPointMapData); + sectionsMapDataCollection.Add(sectionsEndPointMapData); + mapDataCollection.Add(sectionsMapDataCollection); + mapDataCollection.Add(hydraulicBoundaryLocationsMapData); mapDataCollection.Add(foreshoreProfilesMapData); mapDataCollection.Add(calculationsMapData); Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Views/WaveImpactAsphaltCoverFailureMechanismViewTest.cs =================================================================== diff -u -re051fc6fb26bb69bd092c5da9a7686fbb2fb0736 -r6e5757c5c7aa457696aba585ea8e3cd9f1f343b7 --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Views/WaveImpactAsphaltCoverFailureMechanismViewTest.cs (.../WaveImpactAsphaltCoverFailureMechanismViewTest.cs) (revision e051fc6fb26bb69bd092c5da9a7686fbb2fb0736) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Views/WaveImpactAsphaltCoverFailureMechanismViewTest.cs (.../WaveImpactAsphaltCoverFailureMechanismViewTest.cs) (revision 6e5757c5c7aa457696aba585ea8e3cd9f1f343b7) @@ -46,13 +46,22 @@ public class WaveImpactAsphaltCoverFailureMechanismViewTest { private const int referenceLineIndex = 0; - private const int sectionsIndex = 1; - private const int sectionsStartPointIndex = 2; - private const int sectionsEndPointIndex = 3; - private const int hydraulicBoundaryLocationsIndex = 4; - private const int foreshoreProfilesIndex = 5; - private const int calculationsIndex = 6; + private const int sectionsCollectionIndex = 1; + private const int hydraulicBoundaryLocationsIndex = 2; + private const int foreshoreProfilesIndex = 3; + private const int calculationsIndex = 4; + private const int sectionsIndex = 0; + private const int sectionsStartPointIndex = 1; + private const int sectionsEndPointIndex = 2; + + private const int hydraulicBoundaryLocationsObserverIndex = 1; + private const int foreshoreProfileObserverIndex = 2; + private const int calculationObserverIndex = 3; + private const int sectionsObserverIndex = 4; + private const int sectionsStartPointObserverIndex = 5; + private const int sectionsEndPointObserverIndex = 6; + [Test] public void Constructor_FailureMechanismNull_ThrowsArgumentNullException() { @@ -202,15 +211,17 @@ Assert.IsInstanceOf(mapData); List mapDataList = mapData.Collection.ToList(); - Assert.AreEqual(7, mapDataList.Count); + Assert.AreEqual(5, mapDataList.Count); MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, mapDataList[referenceLineIndex]); - MapDataTestHelper.AssertFailureMechanismSectionsMapData(failureMechanism.Sections, mapDataList[sectionsIndex]); - MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, mapDataList[sectionsStartPointIndex]); - MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(failureMechanism.Sections, mapDataList[sectionsEndPointIndex]); + + IEnumerable sectionsCollection = ((MapDataCollection) mapDataList[sectionsCollectionIndex]).Collection; + MapDataTestHelper.AssertFailureMechanismSectionsMapData(failureMechanism.Sections, sectionsCollection.ElementAt(sectionsIndex)); + MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, sectionsCollection.ElementAt(sectionsStartPointIndex)); + MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(failureMechanism.Sections, sectionsCollection.ElementAt(sectionsEndPointIndex)); + MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(assessmentSection, mapDataList[hydraulicBoundaryLocationsIndex]); MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, mapDataList[foreshoreProfilesIndex]); - AssertCalculationsMapData(failureMechanism.Calculations.Cast(), - mapDataList[calculationsIndex]); + AssertCalculationsMapData(failureMechanism.Calculations.Cast(), mapDataList[calculationsIndex]); } } @@ -230,7 +241,7 @@ var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); - observers[hydraulicBoundaryLocationsIndex].Expect(obs => obs.UpdateObserver()); + observers[hydraulicBoundaryLocationsObserverIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); MapData hydraulicBoundaryLocationsMapData = map.Data.Collection.ElementAt(hydraulicBoundaryLocationsIndex); @@ -270,7 +281,7 @@ var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); - observers[hydraulicBoundaryLocationsIndex].Expect(obs => obs.UpdateObserver()); + observers[hydraulicBoundaryLocationsObserverIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); MapData hydraulicBoundaryLocationsMapData = map.Data.Collection.ElementAt(hydraulicBoundaryLocationsIndex); @@ -297,7 +308,7 @@ { ReferenceLine = new ReferenceLine() }; - assessmentSection.ReferenceLine.SetGeometry(new[] + assessmentSection.ReferenceLine.SetGeometry(new List { new Point2D(1.0, 2.0), new Point2D(2.0, 1.0) @@ -318,7 +329,7 @@ MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); // When - assessmentSection.ReferenceLine.SetGeometry(new[] + assessmentSection.ReferenceLine.SetGeometry(new List { new Point2D(2.0, 5.0), new Point2D(4.0, 3.0) @@ -341,17 +352,18 @@ { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; + IEnumerable sectionsCollection = ((MapDataCollection) map.Data.Collection.ElementAt(sectionsCollectionIndex)).Collection; + var sectionMapData = (MapLineData) sectionsCollection.ElementAt(sectionsIndex); + var sectionStartsMapData = (MapPointData) sectionsCollection.ElementAt(sectionsStartPointIndex); + var sectionsEndsMapData = (MapPointData) sectionsCollection.ElementAt(sectionsEndPointIndex); + var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); - observers[sectionsIndex].Expect(obs => obs.UpdateObserver()); - observers[sectionsStartPointIndex].Expect(obs => obs.UpdateObserver()); - observers[sectionsEndPointIndex].Expect(obs => obs.UpdateObserver()); + observers[sectionsObserverIndex].Expect(obs => obs.UpdateObserver()); + observers[sectionsStartPointObserverIndex].Expect(obs => obs.UpdateObserver()); + observers[sectionsEndPointObserverIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); - var sectionMapData = (MapLineData) map.Data.Collection.ElementAt(sectionsIndex); - var sectionStartsMapData = (MapPointData) map.Data.Collection.ElementAt(sectionsStartPointIndex); - var sectionsEndsMapData = (MapPointData) map.Data.Collection.ElementAt(sectionsEndPointIndex); - // When FailureMechanismTestHelper.SetSections(failureMechanism, new[] { @@ -380,6 +392,7 @@ new Point2D(0, 0), new Point2D(1, 1) }); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); failureMechanism.ForeshoreProfiles.AddRange(new[] { @@ -392,7 +405,7 @@ var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); - observers[foreshoreProfilesIndex].Expect(obs => obs.UpdateObserver()); + observers[foreshoreProfileObserverIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); MapData foreshoreProfileData = map.Data.Collection.ElementAt(foreshoreProfilesIndex); @@ -435,7 +448,7 @@ var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); - observers[foreshoreProfilesIndex].Expect(obs => obs.UpdateObserver()); + observers[foreshoreProfileObserverIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); MapData foreshoreProfileData = map.Data.Collection.ElementAt(foreshoreProfilesIndex); @@ -481,13 +494,14 @@ var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); - observers[calculationsIndex].Expect(obs => obs.UpdateObserver()); + observers[calculationObserverIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); // Precondition - AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); + AssertCalculationsMapData(failureMechanism.Calculations.Cast(), + calculationMapData); // When var calculationB = new WaveImpactAsphaltCoverWaveConditionsCalculation @@ -528,13 +542,14 @@ var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); - observers[calculationsIndex].Expect(obs => obs.UpdateObserver()); + observers[calculationObserverIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); // Precondition - AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); + AssertCalculationsMapData(failureMechanism.Calculations.Cast(), + calculationMapData); // When calculationA.InputParameters.ForeshoreProfile = new TestForeshoreProfile(new Point2D(1.5, 1.5)); @@ -567,13 +582,14 @@ var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); - observers[calculationsIndex].Expect(obs => obs.UpdateObserver()); + observers[calculationObserverIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); - //Precondition - AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); + // Precondition + AssertCalculationsMapData(failureMechanism.Calculations.Cast(), + calculationMapData); // When calculationA.Name = "new name"; @@ -589,10 +605,8 @@ public void UpdateObserver_DataUpdated_MapLayersSameOrder() { // Setup - const int updatedReferenceLineLayerIndex = referenceLineIndex + 6; - const int updatedSectionsLayerIndex = sectionsIndex - 1; - const int updateSectionStartLayerIndex = sectionsStartPointIndex - 1; - const int updatedSectionEndLayerIndex = sectionsEndPointIndex - 1; + const int updatedReferenceLineLayerIndex = referenceLineIndex + 4; + const int updatedSectionsCollectionLayerIndex = sectionsCollectionIndex - 1; const int updatedHydraulicLocationsLayerIndex = hydraulicBoundaryLocationsIndex - 1; const int updatedForeshoreProfilesLayerIndex = foreshoreProfilesIndex - 1; const int updatedCalculationsIndex = calculationsIndex - 1; @@ -616,15 +630,9 @@ var referenceLineData = (MapLineData) mapDataList[updatedReferenceLineLayerIndex]; Assert.AreEqual("Referentielijn", referenceLineData.Name); - var sectionsData = (MapLineData) mapDataList[updatedSectionsLayerIndex]; + var sectionsData = (MapDataCollection) mapDataList[updatedSectionsCollectionLayerIndex]; Assert.AreEqual("Vakindeling", sectionsData.Name); - var sectionStartsData = (MapPointData) mapDataList[updateSectionStartLayerIndex]; - Assert.AreEqual("Vakindeling (startpunten)", sectionStartsData.Name); - - var sectionEndsData = (MapPointData) mapDataList[updatedSectionEndLayerIndex]; - Assert.AreEqual("Vakindeling (eindpunten)", sectionEndsData.Name); - var hydraulicLocationsData = (MapPointData) mapDataList[updatedHydraulicLocationsLayerIndex]; Assert.AreEqual("Hydraulische belastingen", hydraulicLocationsData.Name); @@ -650,15 +658,9 @@ var actualReferenceLineData = (MapLineData) mapDataList[updatedReferenceLineLayerIndex]; Assert.AreEqual("Referentielijn", actualReferenceLineData.Name); - var actualSectionsData = (MapLineData) mapDataList[updatedSectionsLayerIndex]; + var actualSectionsData = (MapDataCollection) mapDataList[updatedSectionsCollectionLayerIndex]; Assert.AreEqual("Vakindeling", actualSectionsData.Name); - var actualSectionStartsData = (MapPointData) mapDataList[updateSectionStartLayerIndex]; - Assert.AreEqual("Vakindeling (startpunten)", actualSectionStartsData.Name); - - var actualSectionEndsData = (MapPointData) mapDataList[updatedSectionEndLayerIndex]; - Assert.AreEqual("Vakindeling (eindpunten)", actualSectionEndsData.Name); - var actualHydraulicLocationsData = (MapPointData) mapDataList[updatedHydraulicLocationsLayerIndex]; Assert.AreEqual("Hydraulische belastingen", actualHydraulicLocationsData.Name); @@ -700,31 +702,39 @@ List mapDataList = mapDataCollection.Collection.ToList(); - Assert.AreEqual(7, mapDataList.Count); + Assert.AreEqual(5, mapDataList.Count); var referenceLineMapData = (MapLineData) mapDataList[referenceLineIndex]; - var sectionsMapData = (MapLineData) mapDataList[sectionsIndex]; var foreshoreProfilesMapData = (MapLineData) mapDataList[foreshoreProfilesIndex]; - var sectionsStartPointMapData = (MapPointData) mapDataList[sectionsStartPointIndex]; - var sectionsEndPointMapData = (MapPointData) mapDataList[sectionsEndPointIndex]; var hydraulicBoundaryLocationsMapData = (MapPointData) mapDataList[hydraulicBoundaryLocationsIndex]; 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(hydraulicBoundaryLocationsMapData.Features); CollectionAssert.IsEmpty(calculationsMapData.Features); Assert.AreEqual("Referentielijn", referenceLineMapData.Name); - Assert.AreEqual("Vakindeling", sectionsMapData.Name); Assert.AreEqual("Voorlandprofielen", foreshoreProfilesMapData.Name); - Assert.AreEqual("Vakindeling (startpunten)", sectionsStartPointMapData.Name); - Assert.AreEqual("Vakindeling (eindpunten)", sectionsEndPointMapData.Name); Assert.AreEqual("Hydraulische belastingen", hydraulicBoundaryLocationsMapData.Name); Assert.AreEqual("Berekeningen", calculationsMapData.Name); + + var sectionsMapDataCollection = (MapDataCollection) mapDataList[sectionsCollectionIndex]; + Assert.AreEqual("Vakindeling", sectionsMapDataCollection.Name); + List sectionsDataList = sectionsMapDataCollection.Collection.ToList(); + Assert.AreEqual(3, sectionsDataList.Count); + + var sectionsMapData = (MapLineData) sectionsDataList[sectionsIndex]; + var sectionsStartPointMapData = (MapPointData) sectionsDataList[sectionsStartPointIndex]; + var sectionsEndPointMapData = (MapPointData) sectionsDataList[sectionsEndPointIndex]; + + CollectionAssert.IsEmpty(sectionsEndPointMapData.Features); + CollectionAssert.IsEmpty(sectionsStartPointMapData.Features); + CollectionAssert.IsEmpty(sectionsMapData.Features); + + Assert.AreEqual("Vakindeling (eindpunten)", sectionsEndPointMapData.Name); + Assert.AreEqual("Vakindeling (startpunten)", sectionsStartPointMapData.Name); + Assert.AreEqual("Vakindeling", sectionsMapData.Name); } /// @@ -741,15 +751,6 @@ var referenceLineMapDataObserver = mocks.StrictMock(); mapDataArray[referenceLineIndex].Attach(referenceLineMapDataObserver); - var sectionsMapDataObserver = mocks.StrictMock(); - mapDataArray[sectionsIndex].Attach(sectionsMapDataObserver); - - var sectionsStartPointMapDataObserver = mocks.StrictMock(); - mapDataArray[sectionsStartPointIndex].Attach(sectionsStartPointMapDataObserver); - - var sectionsEndPointMapDataObserver = mocks.StrictMock(); - mapDataArray[sectionsEndPointIndex].Attach(sectionsEndPointMapDataObserver); - var hydraulicBoundaryLocationsMapDataObserver = mocks.StrictMock(); mapDataArray[hydraulicBoundaryLocationsIndex].Attach(hydraulicBoundaryLocationsMapDataObserver); @@ -759,15 +760,25 @@ var calculationsMapDataObserver = mocks.StrictMock(); mapDataArray[calculationsIndex].Attach(calculationsMapDataObserver); + MapData[] sectionsCollection = ((MapDataCollection) mapDataArray[sectionsCollectionIndex]).Collection.ToArray(); + var sectionsMapDataObserver = mocks.StrictMock(); + sectionsCollection[sectionsIndex].Attach(sectionsMapDataObserver); + + var sectionsStartPointMapDataObserver = mocks.StrictMock(); + sectionsCollection[sectionsStartPointIndex].Attach(sectionsStartPointMapDataObserver); + + var sectionsEndPointMapDataObserver = mocks.StrictMock(); + sectionsCollection[sectionsEndPointIndex].Attach(sectionsEndPointMapDataObserver); + return new[] { referenceLineMapDataObserver, - sectionsMapDataObserver, - sectionsStartPointMapDataObserver, - sectionsEndPointMapDataObserver, hydraulicBoundaryLocationsMapDataObserver, foreshoreProfilesMapDataObserver, - calculationsMapDataObserver + calculationsMapDataObserver, + sectionsMapDataObserver, + sectionsStartPointMapDataObserver, + sectionsEndPointMapDataObserver }; } }