Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismViewTest.cs =================================================================== diff -u -r3722e29f53ce7db0f11fb184cdc2a76d33078cf2 -ra2eb198a93d224a701f3fa4d6a68023e22ebcd79 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismViewTest.cs (.../ClosingStructuresFailureMechanismViewTest.cs) (revision 3722e29f53ce7db0f11fb184cdc2a76d33078cf2) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismViewTest.cs (.../ClosingStructuresFailureMechanismViewTest.cs) (revision a2eb198a93d224a701f3fa4d6a68023e22ebcd79) @@ -34,7 +34,6 @@ using Ringtoets.ClosingStructures.Forms.Views; using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; -using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.Structures; @@ -185,10 +184,10 @@ var referenceLine = new ReferenceLine(); referenceLine.SetGeometry(new[] - { - new Point2D(1.0, 2.0), - new Point2D(2.0, 1.0) - }); + { + new Point2D(1.0, 2.0), + new Point2D(2.0, 1.0) + }); var assessmentSection = new ObservableTestAssessmentSectionStub { @@ -225,8 +224,16 @@ failureMechanism.AddSection(new FailureMechanismSection("B", geometryPoints.Skip(1).Take(2))); failureMechanism.AddSection(new FailureMechanismSection("C", geometryPoints.Skip(2).Take(2))); - failureMechanism.ForeshoreProfiles.Add(new TestForeshoreProfile()); - failureMechanism.ForeshoreProfiles.Add(new TestForeshoreProfile()); + failureMechanism.ForeshoreProfiles.Add(new TestForeshoreProfile(new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + })); + failureMechanism.ForeshoreProfiles.Add(new TestForeshoreProfile(new[] + { + new Point2D(2, 2), + new Point2D(3, 3) + })); failureMechanism.CalculationsGroup.Children.Add(calculationA); failureMechanism.CalculationsGroup.Children.Add(calculationB); @@ -248,7 +255,23 @@ MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, mapDataList[sectionsStartPointIndex]); MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(failureMechanism.Sections, mapDataList[sectionsEndPointIndex]); MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase.Locations, mapDataList[hydraulicBoundaryLocationsIndex]); - AssertForeshoreProfiles(failureMechanism.ForeshoreProfiles, mapDataList[foreshoreProfilesIndex]); + + var expectedGeometry = new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(0, -1) + }, + new[] + { + new Point2D(0, -2), + new Point2D(0, -3) + } + }; + + MapDataTestHelper.AssertForeshoreProfiles(failureMechanism.ForeshoreProfiles, expectedGeometry, mapDataList[foreshoreProfilesIndex]); + AssertCalculationsMapData( failureMechanism.Calculations.Cast>(), mapDataList[calculationsIndex]); @@ -449,10 +472,10 @@ // Call failureMechanism.AddSection(new FailureMechanismSection(string.Empty, new[] - { - new Point2D(1, 2), - new Point2D(1, 2) - })); + { + new Point2D(1, 2), + new Point2D(1, 2) + })); failureMechanism.NotifyObservers(); // Assert @@ -473,21 +496,50 @@ var failureMechanism = new ClosingStructuresFailureMechanism(); var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub()); - failureMechanism.ForeshoreProfiles.Add(new TestForeshoreProfile()); + failureMechanism.ForeshoreProfiles.Add(new TestForeshoreProfile(new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + })); view.Data = failureMechanismContext; var foreshoreProfileData = map.Data.Collection.ElementAt(foreshoreProfilesIndex); // Precondition - AssertForeshoreProfiles(failureMechanism.ForeshoreProfiles, foreshoreProfileData); + MapDataTestHelper.AssertForeshoreProfiles(failureMechanism.ForeshoreProfiles, new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(0, -1) + } + }, foreshoreProfileData); // Call - failureMechanism.ForeshoreProfiles.Add(new TestForeshoreProfile()); + failureMechanism.ForeshoreProfiles.Add(new TestForeshoreProfile(new[] + { + new Point2D(2, 2), + new Point2D(3, 3) + })); failureMechanism.ForeshoreProfiles.NotifyObservers(); // Assert - AssertForeshoreProfiles(failureMechanism.ForeshoreProfiles, foreshoreProfileData); + var expectedGeometry = new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(0, -1) + }, + new[] + { + new Point2D(0, -2), + new Point2D(0, -3) + } + }; + + MapDataTestHelper.AssertForeshoreProfiles(failureMechanism.ForeshoreProfiles, expectedGeometry, foreshoreProfileData); } } @@ -752,10 +804,10 @@ newAssessmentSection.ReferenceLine = new ReferenceLine(); newAssessmentSection.ReferenceLine.SetGeometry(new[] - { - new Point2D(2, 4), - new Point2D(3, 4) - }); + { + new Point2D(2, 4), + new Point2D(3, 4) + }); var oldClosingStructuresFailureMechanismContext = new ClosingStructuresFailureMechanismContext(new ClosingStructuresFailureMechanism(), oldAssessmentSection); var newClosingStructuresFailureMechanismContext = new ClosingStructuresFailureMechanismContext(new ClosingStructuresFailureMechanism(), newAssessmentSection); @@ -777,24 +829,6 @@ } } - private static void AssertForeshoreProfiles(IEnumerable foreshoreProfiles, MapData mapData) - { - Assert.NotNull(foreshoreProfiles, "foreshoreProfiles should never be null."); - - var foreshoreProfilesData = (MapLineData) mapData; - var foreshoreProfileArray = foreshoreProfiles.ToArray(); - - Assert.AreEqual(foreshoreProfileArray.Length, foreshoreProfilesData.Features.Length); - - for (int i = 0; i < foreshoreProfileArray.Length; i++) - { - var profileDataA = foreshoreProfilesData.Features[i].MapGeometries.First(); - CollectionAssert.AreEquivalent(foreshoreProfileArray[0].Geometry, profileDataA.PointCollections.First()); - } - - Assert.AreEqual("Voorlandprofielen", mapData.Name); - } - private static void AssertStructures(IEnumerable structures, MapData mapData) { Assert.NotNull(structures, "structures should never be null."); @@ -828,10 +862,10 @@ StructuresCalculation calculation = calculationsArray[index]; CollectionAssert.AreEquivalent(new[] - { - calculation.InputParameters.Structure.Location, - calculation.InputParameters.HydraulicBoundaryLocation.Location - }, geometries[0].PointCollections.First()); + { + calculation.InputParameters.Structure.Location, + calculation.InputParameters.HydraulicBoundaryLocation.Location + }, geometries[0].PointCollections.First()); } Assert.AreEqual("Berekeningen", mapData.Name); }