Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismViewTest.cs =================================================================== diff -u -r3722e29f53ce7db0f11fb184cdc2a76d33078cf2 -ra2eb198a93d224a701f3fa4d6a68023e22ebcd79 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismViewTest.cs (.../HeightStructuresFailureMechanismViewTest.cs) (revision 3722e29f53ce7db0f11fb184cdc2a76d33078cf2) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismViewTest.cs (.../HeightStructuresFailureMechanismViewTest.cs) (revision a2eb198a93d224a701f3fa4d6a68023e22ebcd79) @@ -29,7 +29,6 @@ using NUnit.Framework; 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; @@ -179,10 +178,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 { @@ -219,8 +218,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); @@ -242,7 +249,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]); @@ -443,10 +466,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 @@ -467,21 +490,50 @@ var failureMechanism = new HeightStructuresFailureMechanism(); var failureMechanismContext = new HeightStructuresFailureMechanismContext(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); } } @@ -746,10 +798,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 oldHeightStructuresFailureMechanismContext = new HeightStructuresFailureMechanismContext(new HeightStructuresFailureMechanism(), oldAssessmentSection); var newHeightStructuresFailureMechanismContext = new HeightStructuresFailureMechanismContext(new HeightStructuresFailureMechanism(), newAssessmentSection); @@ -771,24 +823,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."); @@ -822,10 +856,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); }