Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/FailureMechanismViewTest.cs =================================================================== diff -u -rb8b024eb53a66982983e881cdf054ee64f4cee46 -r3914ef316f5063d454c34567d5476c4cf2f105b3 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/FailureMechanismViewTest.cs (.../FailureMechanismViewTest.cs) (revision b8b024eb53a66982983e881cdf054ee64f4cee46) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/FailureMechanismViewTest.cs (.../FailureMechanismViewTest.cs) (revision 3914ef316f5063d454c34567d5476c4cf2f105b3) @@ -43,11 +43,18 @@ public class FailureMechanismViewTest { 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 sectionsCollectionIndex = 1; + private const int hydraulicBoundaryLocationsIndex = 2; + private const int sectionsIndex = 0; + private const int sectionsStartPointIndex = 1; + private const int sectionsEndPointIndex = 2; + + private const int hydraulicBoundaryLocationsObserverIndex = 1; + private const int sectionsObserverIndex = 2; + private const int sectionsStartPointObserverIndex = 3; + private const int sectionsEndPointObserverIndex = 4; + [Test] public void Constructor_ExpectedValues() { @@ -167,11 +174,14 @@ Assert.IsInstanceOf(mapData); List mapDataList = mapData.Collection.ToList(); - Assert.AreEqual(5, mapDataList.Count); + Assert.AreEqual(3, 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]); } } @@ -195,7 +205,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); @@ -230,7 +240,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); @@ -305,17 +315,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); - // Call FailureMechanismTestHelper.SetSections(failureMechanism, new[] { @@ -339,10 +350,8 @@ public void UpdateObserver_DataUpdated_MapLayersSameOrder() { // Setup - const int updatedReferenceLineLayerIndex = referenceLineIndex + 4; - const int updatedSectionsLayerIndex = sectionsIndex - 1; - const int updateSectionStartLayerIndex = sectionsStartPointIndex - 1; - const int updatedSectionEndLayerIndex = sectionsEndPointIndex - 1; + const int updatedReferenceLineLayerIndex = referenceLineIndex + 2; + const int updatedSectionCollectionIndex = sectionsCollectionIndex - 1; const int updatedHydraulicLocationsLayerIndex = hydraulicBoundaryLocationsIndex - 1; var assessmentSection = new AssessmentSectionStub(); @@ -364,15 +373,9 @@ var referenceLineData = (MapLineData) mapDataList[updatedReferenceLineLayerIndex]; Assert.AreEqual("Referentielijn", referenceLineData.Name); - var sectionsData = (MapLineData) mapDataList[updatedSectionsLayerIndex]; + var sectionsData = (MapDataCollection) mapDataList[updatedSectionCollectionIndex]; 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); @@ -392,15 +395,9 @@ var actualReferenceLineData = (MapLineData) mapDataList[updatedReferenceLineLayerIndex]; Assert.AreEqual("Referentielijn", actualReferenceLineData.Name); - var actualSectionsData = (MapLineData) mapDataList[updatedSectionsLayerIndex]; + var actualSectionsData = (MapDataCollection) mapDataList[updatedSectionCollectionIndex]; 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); } @@ -412,25 +409,33 @@ List mapDataList = mapDataCollection.Collection.ToList(); - Assert.AreEqual(5, mapDataList.Count); + Assert.AreEqual(3, mapDataList.Count); var referenceLineMapData = (MapLineData) mapDataList[referenceLineIndex]; - var sectionsMapData = (MapLineData) mapDataList[sectionsIndex]; - var sectionsStartPointMapData = (MapPointData) mapDataList[sectionsStartPointIndex]; - var sectionsEndPointMapData = (MapPointData) mapDataList[sectionsEndPointIndex]; var hydraulicBoundaryLocationsMapData = (MapPointData) mapDataList[hydraulicBoundaryLocationsIndex]; CollectionAssert.IsEmpty(referenceLineMapData.Features); - CollectionAssert.IsEmpty(sectionsMapData.Features); - CollectionAssert.IsEmpty(sectionsStartPointMapData.Features); - CollectionAssert.IsEmpty(sectionsEndPointMapData.Features); CollectionAssert.IsEmpty(hydraulicBoundaryLocationsMapData.Features); Assert.AreEqual("Referentielijn", referenceLineMapData.Name); - Assert.AreEqual("Vakindeling", sectionsMapData.Name); - Assert.AreEqual("Vakindeling (startpunten)", sectionsStartPointMapData.Name); - Assert.AreEqual("Vakindeling (eindpunten)", sectionsEndPointMapData.Name); Assert.AreEqual("Hydraulische belastingen", hydraulicBoundaryLocationsMapData.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); } /// @@ -447,25 +452,26 @@ var referenceLineMapDataObserver = mocks.StrictMock(); mapDataArray[referenceLineIndex].Attach(referenceLineMapDataObserver); + var hydraulicBoundaryLocationsMapDataObserver = mocks.StrictMock(); + mapDataArray[hydraulicBoundaryLocationsIndex].Attach(hydraulicBoundaryLocationsMapDataObserver); + + MapData[] sectionsCollection = ((MapDataCollection) mapDataArray[sectionsCollectionIndex]).Collection.ToArray(); var sectionsMapDataObserver = mocks.StrictMock(); - mapDataArray[sectionsIndex].Attach(sectionsMapDataObserver); + sectionsCollection[sectionsIndex].Attach(sectionsMapDataObserver); var sectionsStartPointMapDataObserver = mocks.StrictMock(); - mapDataArray[sectionsStartPointIndex].Attach(sectionsStartPointMapDataObserver); + sectionsCollection[sectionsStartPointIndex].Attach(sectionsStartPointMapDataObserver); var sectionsEndPointMapDataObserver = mocks.StrictMock(); - mapDataArray[sectionsEndPointIndex].Attach(sectionsEndPointMapDataObserver); + sectionsCollection[sectionsEndPointIndex].Attach(sectionsEndPointMapDataObserver); - var hydraulicBoundaryLocationsMapDataObserver = mocks.StrictMock(); - mapDataArray[hydraulicBoundaryLocationsIndex].Attach(hydraulicBoundaryLocationsMapDataObserver); - return new[] { referenceLineMapDataObserver, + hydraulicBoundaryLocationsMapDataObserver, sectionsMapDataObserver, sectionsStartPointMapDataObserver, - sectionsEndPointMapDataObserver, - hydraulicBoundaryLocationsMapDataObserver + sectionsEndPointMapDataObserver }; } }