public void UpdateObserver_DataUpdated_MapLayersSameOrder() { // Setup const int updatedReferenceLineLayerIndex = referenceLineIndex + 1; const int updatedDuneLocationsLayerIndex = duneLocationsIndex - 1; var assessmentSection = new AssessmentSectionStub(); var failureMechanism = new DuneErosionFailureMechanism(); DuneErosionFailureMechanismView view = CreateView(failureMechanism, assessmentSection); IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl; MapDataCollection mapData = map.Data; var dataToMove = (MapLineData)map.Data.Collection.ElementAt(referenceLineIndex); mapData.Remove(dataToMove); mapData.Add(dataToMove); List <MapData> mapDataList = mapData.Collection.ToList(); // Precondition var referenceLineData = (MapLineData)mapDataList[updatedReferenceLineLayerIndex]; Assert.AreEqual("Referentielijn", referenceLineData.Name); var duneLocationsData = (MapPointData)mapDataList[updatedDuneLocationsLayerIndex]; Assert.AreEqual("Hydraulische belastingen", duneLocationsData.Name); var points = new List <Point2D> { new Point2D(2.0, 5.0), new Point2D(4.0, 3.0) }; var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(points); assessmentSection.ReferenceLine = referenceLine; // Call assessmentSection.NotifyObservers(); // Assert var actualReferenceLineData = (MapLineData)mapDataList[updatedReferenceLineLayerIndex]; Assert.AreEqual("Referentielijn", actualReferenceLineData.Name); var actualDuneLocationsData = (MapPointData)mapDataList[updatedDuneLocationsLayerIndex]; Assert.AreEqual("Hydraulische belastingen", actualDuneLocationsData.Name); }
public void UpdateObserver_AssessmentSectionUpdated_MapDataUpdated() { // Setup var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new List <Point2D> { new Point2D(1.0, 2.0), new Point2D(2.0, 1.0) }); var assessmentSection = new AssessmentSectionStub { ReferenceLine = referenceLine }; AssessmentSectionReferenceLineView view = ShowCalculationsView(assessmentSection); IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl; var mocks = new MockRepository(); IObserver observer = AttachReferenceLineMapDataObserver(mocks, map.Data.Collection); observer.Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); var referenceLineMapData = (MapLineData)map.Data.Collection.ElementAt(referenceLineIndex); // Precondition MapFeaturesTestHelper.AssertReferenceLineMetaData(assessmentSection.ReferenceLine, assessmentSection, referenceLineMapData.Features); MapDataTestHelper.AssertReferenceLineMapData(referenceLine, referenceLineMapData); Assert.IsTrue(referenceLineMapData.IsVisible); // Call assessmentSection.Name = "New name"; assessmentSection.NotifyObservers(); // Assert MapFeaturesTestHelper.AssertReferenceLineMetaData(assessmentSection.ReferenceLine, assessmentSection, referenceLineMapData.Features); mocks.VerifyAll(); }
public void UpdateObserver_AssessmentSectionUpdated_MapDataUpdated() { // Setup var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new List <Point2D> { new Point2D(1.0, 2.0), new Point2D(2.0, 1.0) }); var assessmentSection = new AssessmentSectionStub { ReferenceLine = referenceLine }; using (StandAloneFailureMechanismView <IFailureMechanism <FailureMechanismSectionResult>, FailureMechanismSectionResult> view = CreateView(new TestFailureMechanism(), assessmentSection)) { IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl; var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); observers[referenceLineIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); var referenceLineMapData = (MapLineData)map.Data.Collection.ElementAt(referenceLineIndex); // Precondition MapFeaturesTestHelper.AssertReferenceLineMetaData(assessmentSection.ReferenceLine, assessmentSection, referenceLineMapData.Features); // Call assessmentSection.Name = "New name"; assessmentSection.NotifyObservers(); // Assert MapFeaturesTestHelper.AssertReferenceLineMetaData(assessmentSection.ReferenceLine, assessmentSection, referenceLineMapData.Features); mocks.VerifyAll(); } }
public void GivenViewWithAssessmentSectionData_WhenAssessmentSectionUpdatedAndNotified_ThenMapDataUpdated() { // Given var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new List <Point2D> { new Point2D(1.0, 2.0), new Point2D(2.0, 1.0) }); var assessmentSection = new AssessmentSectionStub { ReferenceLine = referenceLine }; GrassCoverErosionInwardsFailureMechanismView view = CreateView(new GrassCoverErosionInwardsFailureMechanism(), assessmentSection); IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl; var referenceLineMapData = (MapLineData)map.Data.Collection.ElementAt(referenceLineIndex); var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); observers[referenceLineIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); // Precondition MapFeaturesTestHelper.AssertReferenceLineMetaData(assessmentSection.ReferenceLine, assessmentSection, referenceLineMapData.Features); // When assessmentSection.Name = "New name"; assessmentSection.NotifyObservers(); // Then MapFeaturesTestHelper.AssertReferenceLineMetaData(assessmentSection.ReferenceLine, assessmentSection, referenceLineMapData.Features); mocks.VerifyAll(); }
public void UpdateObserver_DataUpdated_MapLayersSameOrder() { // Setup const int updatedReferenceLineLayerIndex = referenceLineIndex + 7; const int updatedSurfaceLineLayerIndex = surfaceLinesIndex - 1; const int updatedSectionCollectionIndex = sectionsCollectionIndex - 1; const int updatedAssemblyResultsIndex = assemblyResultsIndex - 1; const int updatedHydraulicLocationsLayerIndex = hydraulicBoundaryLocationsIndex - 1; const int updatedStochasticSoilModelsLayerIndex = stochasticSoilModelsIndex - 1; const int updatedProbabilisticCalculationsIndex = probabilisticCalculationsIndex - 1; const int updatedSemiProbabilisticCalculationsIndex = semiProbabilisticCalculationsIndex - 1; var assessmentSection = new AssessmentSectionStub(); PipingFailureMechanismView view = CreateView(new PipingFailureMechanism(), assessmentSection); IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl; MapDataCollection mapData = map.Data; var dataToMove = (MapLineData)map.Data.Collection.ElementAt(referenceLineIndex); mapData.Remove(dataToMove); mapData.Add(dataToMove); IEnumerable <MapData> mapDataCollection = mapData.Collection; // Precondition var referenceLineData = (MapLineData)mapDataCollection.ElementAt(updatedReferenceLineLayerIndex); Assert.AreEqual("Referentielijn", referenceLineData.Name); var surfaceLineData = (MapLineData)mapDataCollection.ElementAt(updatedSurfaceLineLayerIndex); Assert.AreEqual("Profielschematisaties", surfaceLineData.Name); var sectionsData = (MapDataCollection)mapDataCollection.ElementAt(updatedSectionCollectionIndex); Assert.AreEqual("Vakindeling", sectionsData.Name); var assemblyResultsData = (MapLineData)mapDataCollection.ElementAt(updatedAssemblyResultsIndex); Assert.AreEqual("Duidingsklasse per vak", assemblyResultsData.Name); var hydraulicLocationsData = (MapPointData)mapDataCollection.ElementAt(updatedHydraulicLocationsLayerIndex); Assert.AreEqual("Hydraulische belastingen", hydraulicLocationsData.Name); var stochasticSoilModelsData = (MapLineData)mapDataCollection.ElementAt(updatedStochasticSoilModelsLayerIndex); Assert.AreEqual("Stochastische ondergrondmodellen", stochasticSoilModelsData.Name); var probabilisticCalculationsData = (MapLineData)mapDataCollection.ElementAt(updatedProbabilisticCalculationsIndex); Assert.AreEqual("Probabilistische berekeningen", probabilisticCalculationsData.Name); var semiProbabilisticCalculationsData = (MapLineData)mapDataCollection.ElementAt(updatedSemiProbabilisticCalculationsIndex); Assert.AreEqual("Semi-probabilistische berekeningen", semiProbabilisticCalculationsData.Name); var points = new List <Point2D> { new Point2D(2.0, 5.0), new Point2D(4.0, 3.0) }; var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(points); assessmentSection.ReferenceLine = referenceLine; // Call assessmentSection.NotifyObservers(); // Assert var actualReferenceLineData = (MapLineData)mapDataCollection.ElementAt(updatedReferenceLineLayerIndex); Assert.AreEqual("Referentielijn", actualReferenceLineData.Name); var actualSurfaceLineData = (MapLineData)mapDataCollection.ElementAt(updatedSurfaceLineLayerIndex); Assert.AreEqual("Profielschematisaties", actualSurfaceLineData.Name); var actualSectionsData = (MapDataCollection)mapDataCollection.ElementAt(updatedSectionCollectionIndex); Assert.AreEqual("Vakindeling", actualSectionsData.Name); var actualAssemblyResultsData = (MapLineData)mapDataCollection.ElementAt(updatedAssemblyResultsIndex); Assert.AreEqual("Duidingsklasse per vak", actualAssemblyResultsData.Name); var actualHydraulicLocationsData = (MapPointData)mapDataCollection.ElementAt(updatedHydraulicLocationsLayerIndex); Assert.AreEqual("Hydraulische belastingen", actualHydraulicLocationsData.Name); var actualStochasticSoilModelsData = (MapLineData)mapDataCollection.ElementAt(updatedStochasticSoilModelsLayerIndex); Assert.AreEqual("Stochastische ondergrondmodellen", actualStochasticSoilModelsData.Name); var actualSemiProbabilisticCalculationsData = (MapLineData)mapDataCollection.ElementAt(updatedSemiProbabilisticCalculationsIndex); Assert.AreEqual("Semi-probabilistische berekeningen", actualSemiProbabilisticCalculationsData.Name); var actualProbabilisticCalculationsData = (MapLineData)mapDataCollection.ElementAt(updatedProbabilisticCalculationsIndex); Assert.AreEqual("Probabilistische berekeningen", actualProbabilisticCalculationsData.Name); }
public void UpdateObserver_DataUpdated_MapLayersSameOrder() { // Setup const int updatedReferenceLineLayerIndex = referenceLineIndex + 3; const int updatedHydraulicLocationsLayerIndex = hydraulicBoundaryLocationsIndex - 1; const int updatedForeshoreProfilesLayerIndex = foreshoreProfilesIndex - 1; const int updatedCalculationsIndex = calculationsIndex - 1; var assessmentSection = new AssessmentSectionStub(); var failureMechanism = new StabilityStoneCoverFailureMechanism(); StabilityStoneCoverFailureMechanismView view = CreateView(failureMechanism, assessmentSection); IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl; MapDataCollection mapData = map.Data; var dataToMove = (MapLineData)map.Data.Collection.ElementAt(referenceLineIndex); mapData.Remove(dataToMove); mapData.Add(dataToMove); IEnumerable <MapData> mapDataCollection = mapData.Collection; // Precondition var referenceLineData = (MapLineData)mapDataCollection.ElementAt(updatedReferenceLineLayerIndex); Assert.AreEqual("Referentielijn", referenceLineData.Name); var hydraulicLocationsData = (MapPointData)mapDataCollection.ElementAt(updatedHydraulicLocationsLayerIndex); Assert.AreEqual("Hydraulische belastingen", hydraulicLocationsData.Name); var foreshoreProfilesData = (MapLineData)mapDataCollection.ElementAt(updatedForeshoreProfilesLayerIndex); Assert.AreEqual("Voorlandprofielen", foreshoreProfilesData.Name); var calculationsData = (MapLineData)mapDataCollection.ElementAt(updatedCalculationsIndex); Assert.AreEqual("Berekeningen", calculationsData.Name); var points = new List <Point2D> { new Point2D(2.0, 5.0), new Point2D(4.0, 3.0) }; var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(points); assessmentSection.ReferenceLine = referenceLine; // Call assessmentSection.NotifyObservers(); // Assert var actualReferenceLineData = (MapLineData)mapDataCollection.ElementAt(updatedReferenceLineLayerIndex); Assert.AreEqual("Referentielijn", actualReferenceLineData.Name); var actualHydraulicLocationsData = (MapPointData)mapDataCollection.ElementAt(updatedHydraulicLocationsLayerIndex); Assert.AreEqual("Hydraulische belastingen", actualHydraulicLocationsData.Name); var actualForeshoreProfilesData = (MapLineData)mapDataCollection.ElementAt(updatedForeshoreProfilesLayerIndex); Assert.AreEqual("Voorlandprofielen", actualForeshoreProfilesData.Name); var actualCalculationsData = (MapLineData)mapDataCollection.ElementAt(updatedCalculationsIndex); Assert.AreEqual("Berekeningen", actualCalculationsData.Name); }
public void NotifyObservers_DataUpdated_MapLayersSameOrder() { // Setup const int updatedReferenceLineLayerIndex = referenceLineIndex + 6; const int updatedSectionCollectionIndex = sectionsCollectionIndex - 1; const int updatedAssemblyResultsIndex = assemblyResultsIndex - 1; const int updatedHydraulicLocationsLayerIndex = hydraulicBoundaryLocationsIndex - 1; const int updatedForeshoreProfilesLayerIndex = foreshoreProfilesIndex - 1; const int updatedStructuresLayerIndex = structuresIndex - 1; const int updatedCalculationsIndex = calculationsIndex - 1; var assessmentSection = new AssessmentSectionStub(); StabilityPointStructuresFailureMechanismView view = CreateView(new StabilityPointStructuresFailureMechanism(), assessmentSection); IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl; MapDataCollection mapData = map.Data; var dataToMove = (MapLineData)map.Data.Collection.ElementAt(referenceLineIndex); mapData.Remove(dataToMove); mapData.Add(dataToMove); List <MapData> mapDataList = mapData.Collection.ToList(); // Precondition var referenceLineData = (MapLineData)mapDataList[updatedReferenceLineLayerIndex]; Assert.AreEqual("Referentielijn", referenceLineData.Name); var sectionsData = (MapDataCollection)mapDataList[updatedSectionCollectionIndex]; Assert.AreEqual("Vakindeling", sectionsData.Name); var assemblyResultsData = (MapLineData)mapDataList[updatedAssemblyResultsIndex]; Assert.AreEqual("Duidingsklasse per vak", assemblyResultsData.Name); var hydraulicLocationsData = (MapPointData)mapDataList[updatedHydraulicLocationsLayerIndex]; Assert.AreEqual("Hydraulische belastingen", hydraulicLocationsData.Name); var foreshoreProfilesData = (MapLineData)mapDataList[updatedForeshoreProfilesLayerIndex]; Assert.AreEqual("Voorlandprofielen", foreshoreProfilesData.Name); var structuresData = (MapPointData)mapDataList[updatedStructuresLayerIndex]; Assert.AreEqual("Kunstwerken", structuresData.Name); var calculationsData = (MapLineData)mapDataList[updatedCalculationsIndex]; Assert.AreEqual("Berekeningen", calculationsData.Name); var points = new List <Point2D> { new Point2D(2.0, 5.0), new Point2D(4.0, 3.0) }; var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(points); assessmentSection.ReferenceLine = referenceLine; // Call assessmentSection.NotifyObservers(); // Assert var actualReferenceLineData = (MapLineData)mapDataList[updatedReferenceLineLayerIndex]; Assert.AreEqual("Referentielijn", actualReferenceLineData.Name); var actualSectionsData = (MapDataCollection)mapDataList[updatedSectionCollectionIndex]; Assert.AreEqual("Vakindeling", actualSectionsData.Name); var actualAssemblyResultsData = (MapLineData)mapDataList[updatedAssemblyResultsIndex]; Assert.AreEqual("Duidingsklasse per vak", actualAssemblyResultsData.Name); var actualHydraulicLocationsData = (MapPointData)mapDataList[updatedHydraulicLocationsLayerIndex]; Assert.AreEqual("Hydraulische belastingen", actualHydraulicLocationsData.Name); var actualForeshoreProfilesData = (MapLineData)mapDataList[updatedForeshoreProfilesLayerIndex]; Assert.AreEqual("Voorlandprofielen", actualForeshoreProfilesData.Name); var actualStructuresData = (MapPointData)mapDataList[updatedStructuresLayerIndex]; Assert.AreEqual("Kunstwerken", actualStructuresData.Name); var actualCalculationsData = (MapLineData)mapDataList[updatedCalculationsIndex]; Assert.AreEqual("Berekeningen", actualCalculationsData.Name); }
public void UpdateObserver_DataUpdated_MapLayersSameOrder() { // Given const int updatedReferenceLineLayerIndex = referenceLineIndex + hydraulicBoundaryLocationsIndex; const int updatedSectionsCollectionLayerIndex = sectionsCollectionIndex - 1; const int updatedHydraulicBoundaryLocationsLayerIndex = hydraulicBoundaryLocationsIndex - 1; const int updatedAssemblyResultsIndex = assemblyResultsIndex - 1; var assessmentSection = new AssessmentSectionStub(); var failureMechanism = new SpecificFailureMechanism(); SpecificFailureMechanismView view = CreateView(failureMechanism, assessmentSection); MapDataCollection mapData = view.Map.Data; IEnumerable <MapData> mapDataCollection = mapData.Collection; MapData dataToMove = mapDataCollection.ElementAt(referenceLineIndex); mapData.Remove(dataToMove); mapData.Add(dataToMove); // Precondition MapData referenceLineData = mapDataCollection.ElementAt(updatedReferenceLineLayerIndex); Assert.AreEqual("Referentielijn", referenceLineData.Name); MapData sectionsData = mapDataCollection.ElementAt(updatedSectionsCollectionLayerIndex); Assert.AreEqual("Vakindeling", sectionsData.Name); var assemblyResultsData = (MapLineData)mapDataCollection.ElementAt(updatedAssemblyResultsIndex); Assert.AreEqual("Duidingsklasse per vak", assemblyResultsData.Name); MapData hydraulicBoundaryLocationsData = mapDataCollection.ElementAt(updatedHydraulicBoundaryLocationsLayerIndex); Assert.AreEqual("Hydraulische belastingen", hydraulicBoundaryLocationsData.Name); // When var points = new List <Point2D> { new Point2D(2.0, 5.0), new Point2D(4.0, 3.0) }; var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(points); assessmentSection.ReferenceLine = referenceLine; assessmentSection.NotifyObservers(); // Then MapData actualReferenceLineData = mapDataCollection.ElementAt(updatedReferenceLineLayerIndex); Assert.AreEqual("Referentielijn", actualReferenceLineData.Name); MapData actualSectionsData = mapDataCollection.ElementAt(updatedSectionsCollectionLayerIndex); Assert.AreEqual("Vakindeling", actualSectionsData.Name); var actualAssemblyResultsData = (MapLineData)mapDataCollection.ElementAt(updatedAssemblyResultsIndex); Assert.AreEqual("Duidingsklasse per vak", actualAssemblyResultsData.Name); MapData actualHydraulicBoundaryLocationsData = mapDataCollection.ElementAt(updatedHydraulicBoundaryLocationsLayerIndex); Assert.AreEqual("Hydraulische belastingen", actualHydraulicBoundaryLocationsData.Name); }
public void UpdateObserver_DataUpdated_MapLayersSameOrder() { // Setup const int updatedReferenceLineLayerIndex = referenceLineIndex + 3; const int updatedSectionCollectionIndex = sectionsCollectionIndex - 1; const int updatedAssemblyResultsIndex = assemblyResultsIndex - 1; const int updatedHydraulicLocationsLayerIndex = hydraulicBoundaryLocationsIndex - 1; var assessmentSection = new AssessmentSectionStub(); var failureMechanism = new TestFailureMechanism(); using (StandAloneFailureMechanismView <IFailureMechanism <FailureMechanismSectionResult>, FailureMechanismSectionResult> view = CreateView(failureMechanism, assessmentSection)) { IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl; MapDataCollection mapData = map.Data; var dataToMove = (MapLineData)map.Data.Collection.ElementAt(referenceLineIndex); mapData.Remove(dataToMove); mapData.Add(dataToMove); IEnumerable <MapData> mapDataCollection = mapData.Collection; // Precondition var referenceLineData = (MapLineData)mapDataCollection.ElementAt(updatedReferenceLineLayerIndex); Assert.AreEqual("Referentielijn", referenceLineData.Name); var sectionsData = (MapDataCollection)mapDataCollection.ElementAt(updatedSectionCollectionIndex); Assert.AreEqual("Vakindeling", sectionsData.Name); var assemblyResultsData = (MapLineData)mapDataCollection.ElementAt(updatedAssemblyResultsIndex); Assert.AreEqual("Duidingsklasse per vak", assemblyResultsData.Name); var hydraulicLocationsData = (MapPointData)mapDataCollection.ElementAt(updatedHydraulicLocationsLayerIndex); Assert.AreEqual("Hydraulische belastingen", hydraulicLocationsData.Name); var points = new List <Point2D> { new Point2D(2.0, 5.0), new Point2D(4.0, 3.0) }; var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(points); assessmentSection.ReferenceLine = referenceLine; // Call assessmentSection.NotifyObservers(); // Assert var actualReferenceLineData = (MapLineData)mapDataCollection.ElementAt(updatedReferenceLineLayerIndex); Assert.AreEqual("Referentielijn", actualReferenceLineData.Name); var actualSectionsData = (MapDataCollection)mapDataCollection.ElementAt(updatedSectionCollectionIndex); Assert.AreEqual("Vakindeling", actualSectionsData.Name); var actualAssemblyResultsData = (MapLineData)mapDataCollection.ElementAt(updatedAssemblyResultsIndex); Assert.AreEqual("Duidingsklasse per vak", actualAssemblyResultsData.Name); var actualHydraulicLocationsData = (MapPointData)mapDataCollection.ElementAt(updatedHydraulicLocationsLayerIndex); Assert.AreEqual("Hydraulische belastingen", actualHydraulicLocationsData.Name); } }