Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/DikeProfileTest.cs =================================================================== diff -u -r4e7e4a0740ddf86ceb74893155d1f20f95efb342 -r30026b56425d53753f03e790e4938a2e7852369a --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/DikeProfileTest.cs (.../DikeProfileTest.cs) (revision 4e7e4a0740ddf86ceb74893155d1f20f95efb342) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/DikeProfileTest.cs (.../DikeProfileTest.cs) (revision 30026b56425d53753f03e790e4938a2e7852369a) @@ -20,7 +20,6 @@ // All rights reserved. using System; -using System.Collections.Generic; using System.Linq; using Core.Common.Base.Data; using Core.Common.Base.Geometry; @@ -243,252 +242,6 @@ } [Test] - public void AddForshoreProfileSection_NoElementsYetInCollection_AddNewProfileSection() - { - // Setup - var dikeProfile = new DikeProfile(new Point2D(0, 0)); - - var newSection = new ProfileSection(new Point2D(1.1, 2.2), new Point2D(3.3, 4.4)); - - // Precondition - CollectionAssert.IsEmpty(dikeProfile.ForeshoreGeometry); - - // Call - dikeProfile.AddForshoreGeometrySection(newSection); - - // Assert - CollectionAssert.Contains(dikeProfile.ForeshoreGeometry, newSection); - Assert.AreEqual(1, dikeProfile.ForeshoreGeometry.Count()); - } - - [Test] - public void AddForshoreProfileSection_CollectionHasElementsAndNewElementConnectsToStart_NewElementInsertedAtFront() - { - // Setup - var dikeProfile = new DikeProfile(new Point2D(0, 0)); - - var connectedPoint = new Point2D(1.1, 2.2); - var existingSection = new ProfileSection(connectedPoint, new Point2D(3.3, 4.4)); - dikeProfile.AddForshoreGeometrySection(existingSection); - - var newSection = new ProfileSection(new Point2D(0.0, 0.0), connectedPoint); - - // Call - dikeProfile.AddForshoreGeometrySection(newSection); - - // Assert - ProfileSection[] expectedForshoreSections = - { - newSection, - existingSection - }; - CollectionAssert.AreEqual(expectedForshoreSections, dikeProfile.ForeshoreGeometry); - } - - [Test] - public void AddForshoreProfileSection_CollectionHasElementsAndNewElementNotProperlyConnectsToStart_ThrowsArgumentException() - { - // Setup - var dikeProfile = new DikeProfile(new Point2D(0, 0)); - - var connectedPoint = new Point2D(1.1, 2.2); - var existingSection = new ProfileSection(connectedPoint, new Point2D(3.3, 4.4)); - dikeProfile.AddForshoreGeometrySection(existingSection); - - var newSection = new ProfileSection(connectedPoint, new Point2D(0.0, 0.0)); - - // Call - TestDelegate call = () => dikeProfile.AddForshoreGeometrySection(newSection); - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, - "Het nieuwe segment is wel verbonden, maar heeft een verkeerde oriƫntatie (moet omgedraaid worden)."); - CollectionAssert.DoesNotContain(dikeProfile.ForeshoreGeometry, newSection); - } - - [Test] - public void AddForshoreProfileSection_CollectionHasElementAndNewElementConnectsToEnd_NewElementInsertedAtEnd() - { - // Setup - var dikeProfile = new DikeProfile(new Point2D(0, 0)); - - var connectedPoint = new Point2D(4.4, 5.5); - var existingSection = new ProfileSection(new Point2D(1.1, 2.2), connectedPoint); - dikeProfile.AddForshoreGeometrySection(existingSection); - - var newSection = new ProfileSection(connectedPoint, new Point2D(12.12, 13.13)); - - // Call - dikeProfile.AddForshoreGeometrySection(newSection); - - // Assert - ProfileSection[] expectedForshoreSections = - { - existingSection, - newSection - }; - CollectionAssert.AreEqual(expectedForshoreSections, dikeProfile.ForeshoreGeometry); - } - - [Test] - public void AddForshoreProfileSection_CollectionHasElementsAndNewElementNotProperlyConnectsToEnd_ThrowsArgumentException() - { - // Setup - var dikeProfile = new DikeProfile(new Point2D(0, 0)); - - var connectedPoint = new Point2D(4.4, 5.5); - var existingSection = new ProfileSection(new Point2D(1.1, 2.2), connectedPoint); - dikeProfile.AddForshoreGeometrySection(existingSection); - - var newSection = new ProfileSection(new Point2D(12.12, 13.13), connectedPoint); - - // Call - TestDelegate call = () => dikeProfile.AddForshoreGeometrySection(newSection); - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, - "Het nieuwe segment is wel verbonden, maar heeft een verkeerde oriƫntatie (moet omgedraaid worden)."); - CollectionAssert.DoesNotContain(dikeProfile.ForeshoreGeometry, newSection); - } - - [Test] - public void AddForshoreProfileSection_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) - }; - IEnumerable existingSections = Math2D.ConvertLinePointsToLineSegments(existingPoints) - .Select(segment => new ProfileSection(segment.FirstPoint, segment.SecondPoint)); - foreach (ProfileSection existingSection in existingSections) - { - dikeProfile.AddForshoreGeometrySection(existingSection); - } - - var random = new Random(123); - var totallyDisconnectSection = new ProfileSection(new Point2D(random.NextDouble(), random.NextDouble()), - new Point2D(random.NextDouble(), random.NextDouble())); - - // Call - TestDelegate call = () => dikeProfile.AddForshoreGeometrySection(totallyDisconnectSection); - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, - "Het nieuwe segment is niet verbonden met de bestaande geometrie."); - CollectionAssert.DoesNotContain(dikeProfile.ForeshoreGeometry, totallyDisconnectSection); - } - - [Test] - [TestCase(1)] - [TestCase(2)] - public void AddForshoreProfileSection_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) - }; - ProfileSection[] existingSections = Math2D.ConvertLinePointsToLineSegments(existingPoints) - .Select(segment => new ProfileSection(segment.FirstPoint, segment.SecondPoint)) - .ToArray(); - foreach (ProfileSection existingSection in existingSections) - { - dikeProfile.AddForshoreGeometrySection(existingSection); - } - - ProfileSection totallyDisconnectSection = existingSections[index]; - - // Call - TestDelegate call = () => dikeProfile.AddForshoreGeometrySection(totallyDisconnectSection); - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, - "Het nieuwe segment is niet verbonden met de bestaande geometrie."); - Assert.AreEqual(existingSections.Length, dikeProfile.ForeshoreGeometry.Count()); - } - - [Test] - public void AddForshoreProfileSection_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) - }; - ProfileSection[] existingSections = Math2D.ConvertLinePointsToLineSegments(existingPoints) - .Select(segment => new ProfileSection(segment.FirstPoint, segment.SecondPoint)) - .ToArray(); - foreach (ProfileSection existingSection in existingSections) - { - dikeProfile.AddForshoreGeometrySection(existingSection); - } - - var touchingSection = new ProfileSection(existingSections[index].EndingPoint, new Point2D(999.99, 999.9)); - - // Call - TestDelegate call = () => dikeProfile.AddForshoreGeometrySection(touchingSection); - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, - "Het nieuwe segment is niet verbonden met de bestaande geometrie."); - CollectionAssert.DoesNotContain(dikeProfile.ForeshoreGeometry, touchingSection); - } - - [Test] - public void AddForshoreProfileSection_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) - }; - ProfileSection[] existingSections = Math2D.ConvertLinePointsToLineSegments(existingPoints) - .Select(segment => new ProfileSection(segment.FirstPoint, segment.SecondPoint)) - .ToArray(); - foreach (ProfileSection existingSection in existingSections) - { - dikeProfile.AddForshoreGeometrySection(existingSection); - } - - var touchingSection = new ProfileSection(new Point2D(999.99, 999.9), existingSections[index].StartingPoint); - - // Call - TestDelegate call = () => dikeProfile.AddForshoreGeometrySection(touchingSection); - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, - "Het nieuwe segment is niet verbonden met de bestaande geometrie."); - CollectionAssert.DoesNotContain(dikeProfile.ForeshoreGeometry, touchingSection); - } - - [Test] public void AddDikeGeometrySection_NoElementsYetInCollection_AddNewRoughnessProfileSection() { // Setup