Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/DikeProfileTest.cs =================================================================== diff -u -r30026b56425d53753f03e790e4938a2e7852369a -reab646f5a7508cdda5bc871d6cb2e103383604cf --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/DikeProfileTest.cs (.../DikeProfileTest.cs) (revision 30026b56425d53753f03e790e4938a2e7852369a) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/DikeProfileTest.cs (.../DikeProfileTest.cs) (revision eab646f5a7508cdda5bc871d6cb2e103383604cf) @@ -20,7 +20,6 @@ // All rights reserved. using System; -using System.Linq; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.TestUtil; @@ -240,256 +239,5 @@ // Assert Assert.IsTrue(hasBreakWater); } - - [Test] - public void AddDikeGeometrySection_NoElementsYetInCollection_AddNewRoughnessProfileSection() - { - // Setup - var dikeProfile = new DikeProfile(new Point2D(0, 0)); - - var section = new RoughnessProfileSection(new Point2D(1.1, 2.2), new Point2D(3.3, 4.4), 5.5); - - // Precondition - CollectionAssert.IsEmpty(dikeProfile.ForeshoreGeometry); - - // Call - dikeProfile.AddDikeGeometrySection(section); - - // Assert - CollectionAssert.Contains(dikeProfile.DikeGeometry, section); - Assert.AreEqual(1, dikeProfile.DikeGeometry.Count()); - } - - [Test] - public void AddDikeGeometrySection_CollectionHasElementsAndNewElementConnectsToStart_NewElementInsertedAtFront() - { - // Setup - var dikeProfile = new DikeProfile(new Point2D(0, 0)); - - var connectedPoint = new Point2D(1.1, 2.2); - var existingSection = new RoughnessProfileSection(connectedPoint, new Point2D(3.3, 4.4), 1.0); - dikeProfile.AddDikeGeometrySection(existingSection); - - var newSection = new RoughnessProfileSection(new Point2D(0.0, 0.0), connectedPoint, 1.0); - - // Call - dikeProfile.AddDikeGeometrySection(newSection); - - // Assert - RoughnessProfileSection[] expectedGeometrySections = - { - newSection, - existingSection - }; - CollectionAssert.AreEqual(expectedGeometrySections, dikeProfile.DikeGeometry); - } - - [Test] - public void AddDikeGeometrySection_CollectionHasElementsAndNewElementNotProperlyConnectsToStart_ThrowsArgumentException() - { - // Setup - var dikeProfile = new DikeProfile(new Point2D(0, 0)); - - var connectedPoint = new Point2D(1.1, 2.2); - var existingSection = new RoughnessProfileSection(connectedPoint, new Point2D(3.3, 4.4), 0.8); - dikeProfile.AddDikeGeometrySection(existingSection); - - var newSection = new RoughnessProfileSection(connectedPoint, new Point2D(0.0, 0.0), 1.0); - - // Call - TestDelegate call = () => dikeProfile.AddDikeGeometrySection(newSection); - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, - "Het nieuwe segment is wel verbonden, maar heeft een verkeerde oriƫntatie (moet omgedraaid worden)."); - CollectionAssert.DoesNotContain(dikeProfile.DikeGeometry, newSection); - } - - [Test] - public void AddDikeGeometrySection_CollectionHasElementAndNewElementConnectsToEnd_NewElementInsertedAtEnd() - { - // Setup - var dikeProfile = new DikeProfile(new Point2D(0, 0)); - - var connectedPoint = new Point2D(4.4, 5.5); - var existingSection = new RoughnessProfileSection(new Point2D(1.1, 2.2), connectedPoint, 0.5); - dikeProfile.AddDikeGeometrySection(existingSection); - - var newSection = new RoughnessProfileSection(connectedPoint, new Point2D(12.12, 13.13), 0.6); - - // Call - dikeProfile.AddDikeGeometrySection(newSection); - - // Assert - RoughnessProfileSection[] expectedGeometrySections = - { - existingSection, - newSection - }; - CollectionAssert.AreEqual(expectedGeometrySections, dikeProfile.DikeGeometry); - } - - [Test] - public void AddDikeGeometrySection_CollectionHasElementsAndNewElementNotProperlyConnectsToEnd_ThrowsArgumentException() - { - // Setup - var dikeProfile = new DikeProfile(new Point2D(0, 0)); - - var connectedPoint = new Point2D(4.4, 5.5); - var existingSection = new RoughnessProfileSection(new Point2D(1.1, 2.2), connectedPoint, 0.7); - dikeProfile.AddDikeGeometrySection(existingSection); - - var newSection = new RoughnessProfileSection(new Point2D(12.12, 13.13), connectedPoint, 0.6); - - // Call - TestDelegate call = () => dikeProfile.AddDikeGeometrySection(newSection); - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, - "Het nieuwe segment is wel verbonden, maar heeft een verkeerde oriƫntatie (moet omgedraaid worden)."); - CollectionAssert.DoesNotContain(dikeProfile.DikeGeometry, newSection); - } - - [Test] - public void AddDikeGeometrySection_CollectionHasElementsAndNewElementNotConnected_ThrowsArgumentException() - { - // Setup - var dikeProfile = new DikeProfile(new Point2D(0, 0)); - - var existingPoints = new[] - { - new Point2D(-10.10, -11.11), - new Point2D(-10.10, 5.5), - new Point2D(7.7, 5.5), - new Point2D(7.7, -4.4), - new Point2D(13.13, -2.2) - }; - foreach (RoughnessProfileSection existingSection in Math2D.ConvertLinePointsToLineSegments(existingPoints) - .Select(segment => ConvertSegmentToRoughnessSection(segment, 0.8))) - { - dikeProfile.AddDikeGeometrySection(existingSection); - } - - var random = new Random(123); - var totallyDisconnectSection = new RoughnessProfileSection(new Point2D(random.NextDouble(), random.NextDouble()), - new Point2D(random.NextDouble(), random.NextDouble()), - 0.7); - - // Call - TestDelegate call = () => dikeProfile.AddDikeGeometrySection(totallyDisconnectSection); - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, - "Het nieuwe segment is niet verbonden met de bestaande geometrie."); - CollectionAssert.DoesNotContain(dikeProfile.DikeGeometry, totallyDisconnectSection); - } - - [Test] - [TestCase(1)] - [TestCase(2)] - public void AddDikeGeometrySection_CollectionHasElementsAndNewElementAlreadyPartOfCollection_ThrowsArgumentException(int index) - { - // Setup - var dikeProfile = new DikeProfile(new Point2D(0, 0)); - - var existingPoints = new[] - { - new Point2D(-10.10, -11.11), - new Point2D(-10.10, 5.5), - new Point2D(7.7, 5.5), - new Point2D(7.7, -4.4), - new Point2D(13.13, -2.2) - }; - RoughnessProfileSection[] roughnessProfileSections = Math2D.ConvertLinePointsToLineSegments(existingPoints) - .Select(segment => ConvertSegmentToRoughnessSection(segment, 0.7)) - .ToArray(); - foreach (RoughnessProfileSection existingSection in roughnessProfileSections) - { - dikeProfile.AddDikeGeometrySection(existingSection); - } - - RoughnessProfileSection alreadyAddedElement = dikeProfile.DikeGeometry.ElementAt(index); - - // Call - TestDelegate call = () => dikeProfile.AddDikeGeometrySection(alreadyAddedElement); - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, - "Het nieuwe segment is niet verbonden met de bestaande geometrie."); - Assert.AreEqual(roughnessProfileSections.Length, dikeProfile.DikeGeometry.Count()); - } - - [Test] - public void AddDikeGeometrySection_CollectionHasElementsAndIsConnectedToElementInMiddleWithFirstPoint_ThrowsArgumentException( - [Range(0, 2)] int index) - { - // Setup - var dikeProfile = new DikeProfile(new Point2D(0, 0)); - - var existingPoints = new[] - { - new Point2D(-2.2, -2.2), - new Point2D(-1.1, -1.2), - new Point2D(3.3, -1.1), - new Point2D(4.4, 6.7), - new Point2D(7.6, 3.2) - }; - RoughnessProfileSection[] existingSections = Math2D.ConvertLinePointsToLineSegments(existingPoints) - .Select(segment => ConvertSegmentToRoughnessSection(segment, 0.9)) - .ToArray(); - foreach (RoughnessProfileSection existingSection in existingSections) - { - dikeProfile.AddDikeGeometrySection(existingSection); - } - - var touchingSection = new RoughnessProfileSection(existingSections[index].EndingPoint, new Point2D(999.99, 999.9), 0.6); - - // Call - TestDelegate call = () => dikeProfile.AddDikeGeometrySection(touchingSection); - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, - "Het nieuwe segment is niet verbonden met de bestaande geometrie."); - CollectionAssert.DoesNotContain(dikeProfile.DikeGeometry, touchingSection); - } - - [Test] - public void AddDikeGeometrySection_CollectionHasElementsAndIsConnectedToElementInMiddleWithSecondPoint_ThrowsArgumentException( - [Range(1, 3)] int index) - { - // Setup - var dikeProfile = new DikeProfile(new Point2D(0, 0)); - - var existingPoints = new[] - { - new Point2D(-2.2, -2.2), - new Point2D(-1.1, -1.2), - new Point2D(3.3, -1.1), - new Point2D(4.4, 6.7), - new Point2D(7.6, 3.2) - }; - RoughnessProfileSection[] existingSections = Math2D.ConvertLinePointsToLineSegments(existingPoints) - .Select(segment => ConvertSegmentToRoughnessSection(segment, 0.9)) - .ToArray(); - foreach (RoughnessProfileSection existingSection in existingSections) - { - dikeProfile.AddDikeGeometrySection(existingSection); - } - - var touchingSection = new RoughnessProfileSection(new Point2D(999.99, 999.9), existingSections[index].StartingPoint, 0.8); - - // Call - TestDelegate call = () => dikeProfile.AddDikeGeometrySection(touchingSection); - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, - "Het nieuwe segment is niet verbonden met de bestaande geometrie."); - CollectionAssert.DoesNotContain(dikeProfile.DikeGeometry, touchingSection); - } - - private RoughnessProfileSection ConvertSegmentToRoughnessSection(Segment2D segment, double roughness) - { - return new RoughnessProfileSection(segment.FirstPoint, segment.SecondPoint, roughness); - } } } \ No newline at end of file