Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismViewTest.cs =================================================================== diff -u -r3722e29f53ce7db0f11fb184cdc2a76d33078cf2 -ra2eb198a93d224a701f3fa4d6a68023e22ebcd79 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismViewTest.cs) (revision 3722e29f53ce7db0f11fb184cdc2a76d33078cf2) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismViewTest.cs) (revision a2eb198a93d224a701f3fa4d6a68023e22ebcd79) @@ -28,7 +28,6 @@ using Core.Components.Gis.Forms; using NUnit.Framework; using Ringtoets.Common.Data.AssessmentSection; -using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; @@ -169,10 +168,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 { @@ -204,8 +203,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.WaveConditionsCalculationGroup.Children.Add(calculationA); failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculationB); failureMechanism.HydraulicBoundaryLocations.Add(new HydraulicBoundaryLocation(1, "test", 1.0, 2.0)); @@ -228,7 +235,21 @@ MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, mapDataList[sectionsStartPointIndex]); MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(failureMechanism.Sections, mapDataList[sectionsEndPointIndex]); MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(failureMechanism.HydraulicBoundaryLocations, 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]); } @@ -331,10 +352,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 @@ -355,21 +376,50 @@ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); var failureMechanismContext = new GrassCoverErosionOutwardsFailureMechanismContext(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); } } @@ -588,10 +638,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 oldGrassCoverErosionOutwardsFailureMechanismContext = new GrassCoverErosionOutwardsFailureMechanismContext(new GrassCoverErosionOutwardsFailureMechanism(), oldAssessmentSection); var newGrassCoverErosionOutwardsFailureMechanismContext = new GrassCoverErosionOutwardsFailureMechanismContext(new GrassCoverErosionOutwardsFailureMechanism(), newAssessmentSection); @@ -613,25 +663,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.IsInstanceOf(mapData); - 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 AssertCalculationsMapData(IEnumerable calculations, MapData mapData) { Assert.IsInstanceOf(mapData); @@ -647,10 +678,10 @@ GrassCoverErosionOutwardsWaveConditionsCalculation calculation = calculationsArray[index]; CollectionAssert.AreEquivalent(new[] - { - calculation.InputParameters.ForeshoreProfile.WorldReferencePoint, - calculation.InputParameters.HydraulicBoundaryLocation.Location - }, + { + calculation.InputParameters.ForeshoreProfile.WorldReferencePoint, + calculation.InputParameters.HydraulicBoundaryLocation.Location + }, geometries[0].PointCollections.First()); } Assert.AreEqual("Berekeningen", mapData.Name);