public void IsStructureIntersectionWithReferenceLineInSection_StructureDoesNotIntersectReferenceLine_ReturnsFalse() { // Setup var structure = new TestStructure(new Point2D(0.0, 0.0)); var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new[] { new Point2D(10.0, 0.0), new Point2D(20.0, 0.0) }); var calculation = new TestStructuresCalculationScenario { InputParameters = { Structure = structure } }; IEnumerable <Segment2D> lineSegments = Math2D.ConvertPointsToLineSegments(referenceLine.Points); // Call bool intersects = calculation.IsStructureIntersectionWithReferenceLineInSection(lineSegments); // Assert Assert.IsFalse(intersects); }
public void Export_ValidData_ReturnTrue() { // Setup var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new[] { new Point2D(1.1, 2.2), new Point2D(11.11, 22.22) }); string directoryPath = TestHelper.GetScratchPadPath(nameof(Export_ValidData_ReturnTrue)); using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(Export_ValidData_ReturnTrue))) { string filePath = Path.Combine(directoryPath, "test.shp"); var exporter = new ReferenceLineExporter(referenceLine, "anId", filePath); // Call bool isExported = exporter.Export(); // Assert Assert.IsTrue(isExported); } }
public void IsSurfaceLineIntersectionWithReferenceLineInSection_WithoutReferenceLineIntersectionWorldPoint_ThrowsArgumentNullException() { // Setup var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); surfaceLine.SetGeometry(new[] { new Point3D(0.0, 5.0, 0.0), new Point3D(0.0, 0.0, 1.0), new Point3D(0.0, -5.0, 0.0) }); var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new[] { new Point2D(0.0, 0.0), new Point2D(10.0, 0.0) }); var calculation = new MacroStabilityInwardsCalculationScenario { InputParameters = { SurfaceLine = surfaceLine } }; IEnumerable <Segment2D> lineSegments = Math2D.ConvertPointsToLineSegments(referenceLine.Points); // Call TestDelegate call = () => calculation.IsSurfaceLineIntersectionWithReferenceLineInSection(lineSegments); // Assert Assert.Throws <ArgumentNullException>(call); }
public void UpdateObserver_ReferenceLineUpdated_MapDataUpdated() { // Setup AssessmentSection assessmentSection = CreateAssessmentSectionWithReferenceLine(); ReferenceLine referenceLine = assessmentSection.ReferenceLine; using (var view = new AssemblyResultPerSectionMapView(assessmentSection)) { IMapControl map = GetMapControl(view); var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); observers[assemblyResultsObserverIndex].Expect(obs => obs.UpdateObserver()); observers[referenceLineIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); MapData referenceLineMapData = map.Data.Collection.ElementAt(referenceLineIndex); // Precondition AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); // Call referenceLine.SetGeometry(new[] { new Point2D(2.0, 5.0), new Point2D(4.0, 3.0) }); referenceLine.NotifyObservers(); // Assert AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); mocks.VerifyAll(); } }
public void Import_PrflIsIncomplete_FalseAndErrorLog() { // Setup var messageProvider = mocks.Stub <IImporterMessageProvider>(); mocks.ReplayAll(); string filePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO, Path.Combine("DikeProfiles", "PrflIsIncomplete", "Voorland_12-2.shp")); var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new List <Point2D> { new Point2D(130074.3, 543717.4), new Point2D(130084.3, 543727.4) }); var testProfilesImporter = new TestProfilesImporter(new ObservableList <object>(), referenceLine, filePath, messageProvider); // Call var importResult = true; Action call = () => importResult = testProfilesImporter.Import(); // Assert Action <IEnumerable <string> > asserts = messages => { bool found = messages.First().Contains(": de volgende parameters zijn niet aanwezig in het bestand: VOORLAND, DAMWAND, KRUINHOOGTE, DIJK, MEMO"); Assert.IsTrue(found); }; TestHelper.AssertLogMessages(call, asserts); Assert.IsFalse(importResult); }
public void IsStructureIntersectionWithReferenceLineInSection_EmptySegmentCollection_ThrowsInvalidOperationException() { // Setup var structure = new TestStructure(new Point2D(0.0, 0.0)); var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new[] { new Point2D(0.0, 0.0), new Point2D(10.0, 0.0) }); var calculation = new TestStructuresCalculationScenario { InputParameters = { Structure = structure } }; // Call void Call() => calculation.IsStructureIntersectionWithReferenceLineInSection(Enumerable.Empty <Segment2D>()); // Assert Assert.Throws <InvalidOperationException>(Call); }
private static ReferenceLine CreateReferenceLine(MapLineData lineMapData, string shapeFilePath) { MapFeature[] lineFeatures = lineMapData.Features.ToArray(); if (lineFeatures.Length > 1) { string message = new FileReaderErrorMessageBuilder(shapeFilePath) .Build(RiskeerCommonIOResources.ReferenceLineReader_File_contains_unsupported_multi_polyline); throw new CriticalFileReadException(message); } var referenceLine = new ReferenceLine(); MapFeature referenceLineFeature = lineMapData.Features.First(); MapGeometry[] referenceGeometries = referenceLineFeature.MapGeometries.ToArray(); if (referenceGeometries.Length > 1) { string message = new FileReaderErrorMessageBuilder(shapeFilePath) .Build(RiskeerCommonIOResources.ReferenceLineReader_File_contains_unsupported_multi_polyline); throw new CriticalFileReadException(message); } MapGeometry referenceGeometry = referenceGeometries[0]; referenceLine.SetGeometry(referenceGeometry.PointCollections.First().Select(t => new Point2D(t)).ToArray()); return(referenceLine); }
public void Transform_WithoutCharacteristicPoints_ReturnsSurfaceLineWithoutCharacteristicPointsSet() { // Setup var referenceLine = new ReferenceLine(); var transformer = new PipingSurfaceLineTransformer(referenceLine); const string surfaceLineName = "somewhere"; var surfaceLine = new SurfaceLine { Name = surfaceLineName }; surfaceLine.SetGeometry(new[] { new Point3D(1.0, 5.0, 2.1), new Point3D(1.0, 3.0, 2.1) }); referenceLine.SetGeometry(new[] { new Point2D(0.0, 4.0), new Point2D(2.0, 4.0) }); // Call PipingSurfaceLine result = transformer.Transform(surfaceLine, null); // Assert Assert.IsNull(result.DitchDikeSide); Assert.IsNull(result.BottomDitchDikeSide); Assert.IsNull(result.BottomDitchPolderSide); Assert.IsNull(result.DitchPolderSide); Assert.IsNull(result.DikeToeAtPolder); Assert.IsNull(result.DikeToeAtRiver); }
public void Transform_SurfaceLineNotOnReferenceLine_ThrowsImportedDataTransformException() { // Setup var referenceLine = new ReferenceLine(); var transformer = new PipingSurfaceLineTransformer(referenceLine); const string surfaceLineName = "somewhere"; var surfaceLine = new SurfaceLine { Name = surfaceLineName }; surfaceLine.SetGeometry(new[] { new Point3D(3.0, 4.0, 2.1), new Point3D(3.0, 5.0, 2.1) }); referenceLine.SetGeometry(new[] { new Point2D(2.0, 4.0) }); // Call TestDelegate test = () => transformer.Transform(surfaceLine, null); // Assert string message = $"Profielschematisatie {surfaceLineName} doorkruist de huidige referentielijn niet of op meer dan één punt en kan niet worden geïmporteerd. Dit kan komen doordat de profielschematisatie een lokaal coördinaatsysteem heeft."; var exception = Assert.Throws <ImportedDataTransformException>(test); Assert.AreEqual(message, exception.Message); }
public void GetFailureMechanismSectionGeometry_SectionStartAndEndBetweenDifferentTwoReferenceLinePoints_ReturnExpectedPoints() { // Setup var random = new Random(21); int sectionStart = random.Next(5, 15); int sectionEnd = random.Next(25, 35); var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new[] { new Point2D(0, 0), new Point2D(5, 0), new Point2D(15, 0), new Point2D(25, 0), new Point2D(35, 0) }); // Call IEnumerable <Point2D> sectionPoints = FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(referenceLine, sectionStart, sectionEnd); // Assert CollectionAssert.AreEqual(new[] { new Point2D(sectionStart, 0), new Point2D(15, 0), new Point2D(25, 0), new Point2D(sectionEnd, 0) }, sectionPoints); }
public void GetFailureMechanismSectionGeometry_SectionStartAndEndExactlyOnReferenceLinePoints_ReturnExpectedPoints() { // Setup const int sectionStart = 10; const int sectionEnd = 30; var points = new[] { new Point2D(0, 0), new Point2D(sectionStart, 0), new Point2D(20, 0), new Point2D(sectionEnd, 0) }; var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(points); // Call IEnumerable <Point2D> sectionPoints = FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(referenceLine, sectionStart, sectionEnd); // Assert CollectionAssert.AreEqual(new[] { new Point2D(sectionStart, 0), new Point2D(20, 0), new Point2D(sectionEnd, 0) }, sectionPoints); }
public void GetSingleReferenceLineIntersection_SurfaceLineThroughReferenceLinePoint_ReturnIntersectionPoint() { // Setup var referenceLine = new ReferenceLine(); const string surfaceLineName = "somewhere"; var surfaceLine = new SurfaceLine { Name = surfaceLineName }; surfaceLine.SetGeometry(new[] { new Point3D(3.0, 4.0, 2.1), new Point3D(3.0, 5.0, 2.1) }); referenceLine.SetGeometry(new[] { new Point2D(2.0, 4.5), new Point2D(3.0, 4.5), new Point2D(4.0, 4.5) }); // Call Point2D result = surfaceLine.GetSingleReferenceLineIntersection(referenceLine); // Assert Assert.AreEqual(new Point2D(3.0, 4.5), result); }
public void GetSingleReferenceLineIntersection_SurfaceLineIntersectsReferenceLineMultipleTimesInDifferentPoints_ThrowImportedDataTransformException() { // Setup var referenceLine = new ReferenceLine(); const string surfaceLineName = "somewhere"; var surfaceLine = new SurfaceLine { Name = surfaceLineName }; surfaceLine.SetGeometry(new[] { new Point3D(1.0, 5.0, 2.1), new Point3D(1.0, 3.0, 2.1) }); referenceLine.SetGeometry(new[] { new Point2D(0.0, 5.0), new Point2D(2.0, 4.0), new Point2D(0.0, 3.0) }); // Call TestDelegate test = () => surfaceLine.GetSingleReferenceLineIntersection(referenceLine); // Assert string message = $"Profielschematisatie {surfaceLineName} doorkruist de huidige referentielijn niet of op meer dan één punt en kan niet worden geïmporteerd."; var exception = Assert.Throws <ImportedDataTransformException>(test); Assert.AreEqual(message, exception.Message); }
public void Import_TwoPrflWithSameId_FalseAndErrorLog() { // Setup var messageProvider = mocks.Stub <IImporterMessageProvider>(); mocks.ReplayAll(); string testFileDirectory = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO, Path.Combine("DikeProfiles", "TwoPrflWithSameId")); string filePath = Path.Combine(testFileDirectory, "profiel001.shp"); var referencePoints = new List <Point2D> { new Point2D(130074.3, 543717.4), new Point2D(130084.3, 543727.4) }; var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(referencePoints); var testProfilesImporter = new TestProfilesImporter(new ObservableList <object>(), referenceLine, filePath, messageProvider); // Call var importResult = true; Action call = () => importResult = testProfilesImporter.Import(); // Assert string erroneousProfileFile = Path.Combine(testFileDirectory, "profiel001_2.prfl"); string expectedMessage = $"Meerdere definities gevonden voor profiel 'profiel001'. Bestand '{erroneousProfileFile}' wordt overgeslagen."; TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 1); Assert.IsFalse(importResult); }
public void CreateReferenceLineFeatures_GivenReferenceLine_ReturnsReferenceLineFeature() { // Setup const string id = "1"; const string name = "Traject 1"; var points = new[] { new Point2D(1.2, 2.3), new Point2D(2.7, 2.0) }; var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(points); // Call IEnumerable <MapFeature> features = RiskeerMapDataFeaturesFactory.CreateReferenceLineFeatures(referenceLine, id, name); // Assert MapFeature mapFeature = features.Single(); Assert.AreEqual(3, mapFeature.MetaData.Keys.Count); Assert.AreEqual(id, mapFeature.MetaData["ID"]); Assert.AreEqual(name, mapFeature.MetaData["Naam"]); var expectedLength = new RoundedDouble(2, Math2D.Length(points)); Assert.AreEqual(expectedLength, (RoundedDouble)mapFeature.MetaData["Lengte*"], expectedLength.GetAccuracy()); AssertEqualPointCollections(points, mapFeature.MapGeometries.ElementAt(0)); }
public void Constructor_WithReferenceLine_DataUpdatedToCollectionOfFilledMapData() { // Setup var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new[] { new Point2D(1.0, 2.0), new Point2D(2.0, 1.0) }); var assessmentSection = new AssessmentSectionStub { ReferenceLine = referenceLine }; // Call AssessmentSectionReferenceLineView view = ShowCalculationsView(assessmentSection); // Assert Assert.IsInstanceOf <MapDataCollection>(view.Map.Data); MapDataCollection mapData = view.Map.Data; Assert.IsNotNull(mapData); MapData referenceLineMapData = mapData.Collection.ElementAt(referenceLineIndex); MapDataTestHelper.AssertReferenceLineMapData(referenceLine, referenceLineMapData); Assert.IsTrue(referenceLineMapData.IsVisible); }
public void IsDikeProfileIntersectionWithReferenceLineInSection_EmptySegmentCollection_ThrowsInvalidOperationException() { // Setup DikeProfile dikeProfile = DikeProfileTestFactory.CreateDikeProfile(new Point2D(0.0, 0.0)); var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new[] { new Point2D(0.0, 0.0), new Point2D(10.0, 0.0) }); var calculation = new GrassCoverErosionInwardsCalculationScenario { InputParameters = { DikeProfile = dikeProfile } }; // Call void Call() => calculation.IsDikeProfileIntersectionWithReferenceLineInSection(Enumerable.Empty <Segment2D>()); // Assert Assert.Throws <InvalidOperationException>(Call); }
public void IsDikeProfileIntersectionWithReferenceLineInSection_DikeProfileDoesNotIntersectReferenceLine_ReturnsFalse() { // Setup DikeProfile dikeProfile = DikeProfileTestFactory.CreateDikeProfile(new Point2D(0.0, 0.0)); var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new[] { new Point2D(10.0, 0.0), new Point2D(20.0, 0.0) }); var calculation = new GrassCoverErosionInwardsCalculationScenario { InputParameters = { DikeProfile = dikeProfile } }; IEnumerable <Segment2D> lineSegments = Math2D.ConvertPointsToLineSegments(referenceLine.Points); // Call bool intersects = calculation.IsDikeProfileIntersectionWithReferenceLineInSection(lineSegments); // Assert Assert.IsFalse(intersects); }
public void Import_DikeProfileLocationsNotCloseEnoughToReferenceLine_FalseAndLogError() { // Setup var messageProvider = mocks.Stub <IImporterMessageProvider>(); mocks.ReplayAll(); string filePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO, Path.Combine("DikeProfiles", "AllOkTestData", "Voorlanden 12-2.shp")); var referencePoints = new List <Point2D> { new Point2D(141223.2, 548393.4), new Point2D(143854.3, 545323.1), new Point2D(145561.0, 541920.3), new Point2D(146432.1, 538235.2), new Point2D(146039.4, 533920.2) }; var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(referencePoints); var testProfilesImporter = new TestProfilesImporter(new ObservableList <object>(), referenceLine, filePath, messageProvider); // Call var importResult = true; Action call = () => importResult = testProfilesImporter.Import(); // Assert const string expectedMessages = "Fout bij het lezen van profiellocatie 1. De profiellocatie met ID 'profiel001' ligt niet op de referentielijn."; TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessages, LogLevelConstant.Error), 1); Assert.IsFalse(importResult); }
public void Export_InvalidDirectoryRights_LogErrorAndReturnFalse() { // Setup var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new[] { new Point2D(1.1, 2.2), new Point2D(11.11, 22.22) }); string directoryPath = TestHelper.GetScratchPadPath(nameof(Export_InvalidDirectoryRights_LogErrorAndReturnFalse)); using (var disposeHelper = new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(Export_InvalidDirectoryRights_LogErrorAndReturnFalse))) { string filePath = Path.Combine(directoryPath, "test.shp"); var exporter = new ReferenceLineExporter(referenceLine, "anId", filePath); disposeHelper.LockDirectory(FileSystemRights.Write); var isExported = true; // Call Action call = () => isExported = exporter.Export(); // Assert string expectedMessage = $"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.{Environment.NewLine}Er is geen referentielijn geëxporteerd."; TestHelper.AssertLogMessageIsGenerated(call, expectedMessage); Assert.IsFalse(isExported); } }
public void UpdateObserver_ReferenceLineUpdated_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(); MapData referenceLineMapData = map.Data.Collection.ElementAt(referenceLineIndex); // Precondition MapDataTestHelper.AssertReferenceLineMapData(referenceLine, referenceLineMapData); Assert.IsTrue(referenceLineMapData.IsVisible); // Call referenceLine.SetGeometry(new List <Point2D> { new Point2D(2.0, 5.0), new Point2D(4.0, 3.0) }); referenceLine.NotifyObservers(); // Assert MapDataTestHelper.AssertReferenceLineMapData(referenceLine, referenceLineMapData); Assert.IsTrue(referenceLineMapData.IsVisible); mocks.VerifyAll(); }
public void UpdateObserver_ReferenceLineUpdated_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(); MapData referenceLineMapData = map.Data.Collection.ElementAt(referenceLineIndex); // Precondition MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); // Call referenceLine.SetGeometry(new List <Point2D> { new Point2D(2.0, 5.0), new Point2D(4.0, 3.0) }); referenceLine.NotifyObservers(); // Assert MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); mocks.VerifyAll(); } }
/// <summary> /// Sets a default geometry on a <see cref="ReferenceLine"/>. /// </summary> public static void SetReferenceLineGeometry(ReferenceLine referenceLine) { referenceLine.SetGeometry(new[] { new Point2D(1, 1), new Point2D(2, 2), new Point2D(3, 3), new Point2D(4, 4) }); }
public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_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; MapData referenceLineMapData = 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 MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); // When referenceLine.SetGeometry(new List <Point2D> { new Point2D(2.0, 5.0), new Point2D(4.0, 3.0) }); referenceLine.NotifyObservers(); // Then MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); mocks.VerifyAll(); }
public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_ThenMapDataUpdatedAndObserversNotified() { // 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 }; var failureMechanism = new SpecificFailureMechanism(); SpecificFailureMechanismView view = CreateView(failureMechanism, assessmentSection); IEnumerable <MapData> mapDataCollection = view.Map.Data.Collection; MapData referenceLineMapData = mapDataCollection.ElementAt(referenceLineIndex); var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, mapDataCollection); observers[referenceLineIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); // Precondition MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); // When referenceLine.SetGeometry(new List <Point2D> { new Point2D(2.0, 5.0), new Point2D(4.0, 3.0) }); referenceLine.NotifyObservers(); // Then MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); mocks.VerifyAll(); }
public void UpdateObserver_DataUpdated_MapLayersSameOrder() { // Setup var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new[] { new Point2D(1.0, 2.0), new Point2D(2.0, 1.0) }); var assessmentSection = new AssessmentSectionStub { ReferenceLine = referenceLine }; assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] { new HydraulicBoundaryLocation(1, "test1", 1.0, 2.0) }); AssessmentSectionExtendedView extendedView = ShowCalculationsView(assessmentSection); MapDataCollection mapData = extendedView.Map.Data; MapData dataToMove = mapData.Collection.ElementAt(0); mapData.Remove(dataToMove); mapData.Add(dataToMove); // Precondition var referenceLineMapData = (MapLineData)mapData.Collection.ElementAt(referenceLineIndex + 1); Assert.AreEqual("Referentielijn", referenceLineMapData.Name); var hrLocationsMapData = (MapPointData)mapData.Collection.ElementAt(hydraulicBoundaryLocationsIndex - 1); Assert.AreEqual("Hydraulische belastingen", hrLocationsMapData.Name); // Call assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] { new HydraulicBoundaryLocation(2, "test2", 2.0, 3.0) }); assessmentSection.HydraulicBoundaryDatabase.Locations.NotifyObservers(); // Assert var actualReferenceLineMapData = (MapLineData)mapData.Collection.ElementAt(referenceLineIndex + 1); Assert.AreEqual("Referentielijn", actualReferenceLineMapData.Name); var actualHrLocationsMapData = (MapPointData)mapData.Collection.ElementAt(hydraulicBoundaryLocationsIndex - 1); Assert.AreEqual("Hydraulische belastingen", actualHrLocationsMapData.Name); }
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 SetGeometry_NullGeometry_ThrowArgumentNullException() { // Setup var referenceLine = new ReferenceLine(); // Call TestDelegate call = () => referenceLine.SetGeometry(null); // Assert const string expectedMessage = "De geometrie die opgegeven werd voor de referentielijn heeft geen waarde."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentNullException>(call, expectedMessage); }
private static ReferenceLine CreateMatchingReferenceLine() { var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new[] { new Point2D(131223.2, 548393.4), new Point2D(133854.3, 545323.1), new Point2D(135561.0, 541920.3), new Point2D(136432.1, 538235.2), new Point2D(136039.4, 533920.2) }); return(referenceLine); }
private static ReferenceLine CreateReferenceLine() { var referencePoints = new List <Point2D> { new Point2D(131144.094, 549979.893), new Point2D(131538.705, 548316.752), new Point2D(135878.442, 532149.859), new Point2D(131225.017, 548395.948), new Point2D(131270.38, 548367.462), new Point2D(131507.119, 548322.951) }; var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(referencePoints); return(referenceLine); }