Index: Core/Common/src/Core.Common.Base/Geometry/Point3DExtensions.cs =================================================================== diff -u -r27e5d9fb2ffd87ea219ecfb4217a8080f819df62 -r449e2761ad14af6e84ea5c1a56aea71bc535e8f9 --- Core/Common/src/Core.Common.Base/Geometry/Point3DExtensions.cs (.../Point3DExtensions.cs) (revision 27e5d9fb2ffd87ea219ecfb4217a8080f819df62) +++ Core/Common/src/Core.Common.Base/Geometry/Point3DExtensions.cs (.../Point3DExtensions.cs) (revision 449e2761ad14af6e84ea5c1a56aea71bc535e8f9) @@ -74,7 +74,7 @@ throw new ArgumentException("The startWorldCoordinate and endWorldCoordinate can't be the same."); } - // Project vector onto the 'spanning vector' to determine it's X coordinate in local coordinates: + // Project vector onto the 'spanning vector' to determine its X coordinate in local coordinates: double projectOnSpanningVectorFactor = (vectorToPoint.DotProduct(spanningVector)) / spanningVectorDotProduct; double localCoordinateX = projectOnSpanningVectorFactor * length; Index: Core/Common/test/Core.Common.Base.Test/Geometry/Point3DExtensionsTest.cs =================================================================== diff -u -r27e5d9fb2ffd87ea219ecfb4217a8080f819df62 -r449e2761ad14af6e84ea5c1a56aea71bc535e8f9 --- Core/Common/test/Core.Common.Base.Test/Geometry/Point3DExtensionsTest.cs (.../Point3DExtensionsTest.cs) (revision 27e5d9fb2ffd87ea219ecfb4217a8080f819df62) +++ Core/Common/test/Core.Common.Base.Test/Geometry/Point3DExtensionsTest.cs (.../Point3DExtensionsTest.cs) (revision 449e2761ad14af6e84ea5c1a56aea71bc535e8f9) @@ -69,7 +69,7 @@ } [Test] - public void ProjectIntoLocalCoordinates_WorldCoordinateSameAsStartAndEndWordlCoordinate_ThrowsArgumentException() + public void ProjectIntoLocalCoordinates_WorldCoordinateSameAsStartAndEndWorldCoordinate_ThrowsArgumentException() { // Setup const double originalZ = 3.3; @@ -85,6 +85,40 @@ } [Test] + public void ProjectIntoLocalCoordinates_StartAndEndWorldCoordinateLengthSmallerThanTolerance_ThrowsArgumentException() + { + // Setup + const double originalZ = 3.3; + Point3D point = new Point3D(1.1, 2.2, originalZ); + + Point2D startPoint = new Point2D(point.X, point.Y); + Point2D endPoint = new Point2D(point.X, point.Y + 1e-7); + + // Call + TestDelegate call = () => point.ProjectIntoLocalCoordinates(startPoint, endPoint); + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "The startWorldCoordinate and endWorldCoordinate can't be the same."); + } + + [Test] + public void ProjectIntoLocalCoordinates_StartAdnEndWorldCoordinateLengthBiggerThanTolerance_DoesNotThrow() + { + // Setup + const double originalZ = 3.3; + Point3D point = new Point3D(1.1, 2.2, originalZ); + + Point2D startPoint = new Point2D(point.X, point.Y); + Point2D endPoint = new Point2D(point.X, point.Y + 1e-6); + + // Call + TestDelegate call = () => point.ProjectIntoLocalCoordinates(startPoint, endPoint); + + // Assert + Assert.DoesNotThrow(call); + } + + [Test] public void ProjectIntoLocalCoordinates_GeometryWithMultiplePoints_ProjectPointsOntoLzPlaneKeepingOriginalZ() { // Setup Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingChartDataFactory.cs =================================================================== diff -u -r6ae3b82563c665574a6e8e1465e1fec3d8080dbe -r449e2761ad14af6e84ea5c1a56aea71bc535e8f9 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingChartDataFactory.cs (.../PipingChartDataFactory.cs) (revision 6ae3b82563c665574a6e8e1465e1fec3d8080dbe) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingChartDataFactory.cs (.../PipingChartDataFactory.cs) (revision 449e2761ad14af6e84ea5c1a56aea71bc535e8f9) @@ -80,7 +80,7 @@ /// /// Create a with default styling based on the . /// - /// The entry point for which to create . + /// The distance along the at which to place the entry point. /// The to place the entry point on. /// based on the . /// Thrown when is NaN. @@ -109,8 +109,8 @@ /// /// Create a with default styling based on the . /// - /// The entry point for which to create . - /// The to place the entry point on. + /// The distance along the at which to place the exit point. + /// The to place the exit point on. /// based on the . /// Thrown when is NaN. /// Thrown when is null. @@ -138,99 +138,116 @@ /// /// Create a with default styling based on the . /// - /// The to place the ditch polder side on. + /// The which contains a point which + /// characterizes the ditch at polder side, to create for. /// based on the . - /// /// Thrown when is null. + /// Thrown when is null or + /// the contains no . public static ChartData CreateDitchPolderSide(RingtoetsPipingSurfaceLine surfaceLine) { if (surfaceLine == null) { throw new ArgumentNullException("surfaceLine"); } - return CreateLocalPoint(surfaceLine.DitchPolderSide, surfaceLine, PipingDataResources.CharacteristicPoint_DitchPolderSide, new ChartPointStyle(Color.Red, 8, Color.Transparent, 0, ChartPointSymbol.Circle)); + return CreateCharacteristicPoint(surfaceLine.DitchPolderSide, surfaceLine, PipingDataResources.CharacteristicPoint_DitchPolderSide, Color.Red); } /// /// Create a with default styling based on the . /// - /// The to place the bottom ditch polder side on. + /// The which contains a point which + /// characterizes the bottom ditch at polder side, to create for. /// based on the . - /// /// Thrown when is null. + /// Thrown when is null or + /// the contains no . public static ChartData CreateBottomDitchPolderSide(RingtoetsPipingSurfaceLine surfaceLine) { if (surfaceLine == null) { throw new ArgumentNullException("surfaceLine"); } - return CreateLocalPoint(surfaceLine.BottomDitchPolderSide, surfaceLine, PipingDataResources.CharacteristicPoint_BottomDitchPolderSide, new ChartPointStyle(Color.Blue, 8, Color.Transparent, 0, ChartPointSymbol.Circle)); + return CreateCharacteristicPoint(surfaceLine.BottomDitchPolderSide, surfaceLine, PipingDataResources.CharacteristicPoint_BottomDitchPolderSide, Color.Blue); } /// /// Create a with default styling based on the . /// - /// The to place the bottom ditch dike side on. + /// The which contains a point which + /// characterizes the bottom ditch at dike side, to create for. /// based on the . - /// /// Thrown when is null. + /// Thrown when is null or + /// the contains no . public static ChartData CreateBottomDitchDikeSide(RingtoetsPipingSurfaceLine surfaceLine) { if (surfaceLine == null) { throw new ArgumentNullException("surfaceLine"); } - return CreateLocalPoint(surfaceLine.BottomDitchDikeSide, surfaceLine, PipingDataResources.CharacteristicPoint_BottomDitchDikeSide, new ChartPointStyle(Color.Green, 8, Color.Transparent, 0, ChartPointSymbol.Circle)); + return CreateCharacteristicPoint(surfaceLine.BottomDitchDikeSide, surfaceLine, PipingDataResources.CharacteristicPoint_BottomDitchDikeSide, Color.Green); } /// /// Create a with default styling based on the . /// - /// The to place the ditch dike side on. + /// The which contains a point which + /// characterizes the ditch at diek side, to create for. /// based on the . - /// /// Thrown when is null. + /// Thrown when is null or + /// the contains no . public static ChartData CreateDitchDikeSide(RingtoetsPipingSurfaceLine surfaceLine) { if (surfaceLine == null) { throw new ArgumentNullException("surfaceLine"); } - return CreateLocalPoint(surfaceLine.DitchDikeSide, surfaceLine, PipingDataResources.CharacteristicPoint_DitchDikeSide, new ChartPointStyle(Color.Purple, 8, Color.Transparent, 0, ChartPointSymbol.Circle)); + return CreateCharacteristicPoint(surfaceLine.DitchDikeSide, surfaceLine, PipingDataResources.CharacteristicPoint_DitchDikeSide, Color.Purple); } /// /// Create a with default styling based on the . /// - /// The to place the dike toe at river on. + /// The which contains a point which + /// characterizes the dike toe at river side, to create for. /// based on the . - /// /// Thrown when is null. + /// Thrown when is null or + /// the contains no . public static ChartData CreateDikeToeAtRiver(RingtoetsPipingSurfaceLine surfaceLine) { if (surfaceLine == null) { throw new ArgumentNullException("surfaceLine"); } - return CreateLocalPoint(surfaceLine.DikeToeAtRiver, surfaceLine, PipingDataResources.CharacteristicPoint_DikeToeAtRiver, new ChartPointStyle(Color.Orange, 8, Color.Transparent, 0, ChartPointSymbol.Circle)); + return CreateCharacteristicPoint(surfaceLine.DikeToeAtRiver, surfaceLine, PipingDataResources.CharacteristicPoint_DikeToeAtRiver, Color.Orange); } /// /// Create a with default styling based on the . /// - /// The to place the dike toe at polder on. + /// The which contains a point which + /// characterizes the dike toe at polder side, to create for. /// based on the . - /// /// Thrown when is null. + /// Thrown when is null or + /// the contains no . public static ChartData CreateDikeToeAtPolder(RingtoetsPipingSurfaceLine surfaceLine) { if (surfaceLine == null) { throw new ArgumentNullException("surfaceLine"); } - return CreateLocalPoint(surfaceLine.DikeToeAtPolder, surfaceLine, PipingDataResources.CharacteristicPoint_DikeToeAtPolder, new ChartPointStyle(Color.Silver, 8, Color.Transparent, 0, ChartPointSymbol.Circle)); + return CreateCharacteristicPoint(surfaceLine.DikeToeAtPolder, surfaceLine, PipingDataResources.CharacteristicPoint_DikeToeAtPolder, Color.Silver); } + private static ChartData CreateCharacteristicPoint(Point3D worldPoint, RingtoetsPipingSurfaceLine surfaceLine, string name, Color color) + { + return CreateLocalPoint(worldPoint, surfaceLine, name, new ChartPointStyle(color, 8, Color.Transparent, 0, ChartPointSymbol.Circle)); + } + private static ChartData CreateLocalPoint(Point3D worldPoint, RingtoetsPipingSurfaceLine surfaceLine, string name, ChartPointStyle style) { Point2D firstPoint = Point3DToPoint2D(surfaceLine.Points.First()); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingChartDataFactoryTest.cs =================================================================== diff -u -r6ae3b82563c665574a6e8e1465e1fec3d8080dbe -r449e2761ad14af6e84ea5c1a56aea71bc535e8f9 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingChartDataFactoryTest.cs (.../PipingChartDataFactoryTest.cs) (revision 6ae3b82563c665574a6e8e1465e1fec3d8080dbe) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingChartDataFactoryTest.cs (.../PipingChartDataFactoryTest.cs) (revision 449e2761ad14af6e84ea5c1a56aea71bc535e8f9) @@ -33,7 +33,6 @@ using Ringtoets.Piping.Forms.Properties; using Ringtoets.Piping.Forms.Views; using Ringtoets.Piping.Primitives; - using PipingDataResources = Ringtoets.Piping.Data.Properties.Resources; namespace Ringtoets.Piping.Forms.Test.Views @@ -84,18 +83,9 @@ public void Create_GivenSurfaceLine_ReturnsChartDataWithDefaultStyling() { // Setup - var points = new[] - { - new Point3D(1.2, 2.3, 4.0), - new Point3D(2.7, 2.0, 6.0) - }; + var surfaceLine = GetSurfaceLineWithGeometry(); + surfaceLine.Name = "Surface line name"; - var surfaceLine = new RingtoetsPipingSurfaceLine - { - Name = "Surface line name" - }; - surfaceLine.SetGeometry(points); - // Call ChartData data = PipingChartDataFactory.Create(surfaceLine); @@ -114,7 +104,7 @@ public void CreateEntryPoint_EntryPointNaN_ThrowsArgumentException() { // Call - TestDelegate call = () => PipingChartDataFactory.CreateEntryPoint((RoundedDouble)double.NaN, null); + TestDelegate call = () => PipingChartDataFactory.CreateEntryPoint((RoundedDouble) double.NaN, null); // Assert var exception = Assert.Throws(call); @@ -136,15 +126,8 @@ public void CreateEntryPoint_GivenSurfaceLine_ReturnsChartDataWithDefaultStyling() { // Setup - var points = new[] - { - new Point3D(1.2, 2.3, 4.0), - new Point3D(2.7, 2.0, 6.0) - }; + var surfaceLine = GetSurfaceLineWithGeometry(); - var surfaceLine = new RingtoetsPipingSurfaceLine(); - surfaceLine.SetGeometry(points); - var input = new PipingInput(new GeneralPipingInput()) { SurfaceLine = surfaceLine @@ -160,7 +143,10 @@ Assert.AreEqual(Resources.PipingInput_EntryPointL_DisplayName, chartPointData.Name); Point2D entryPointOnLine = new Point2D(input.EntryPointL, surfaceLine.GetZAtL(input.EntryPointL)); - AssertEqualPointCollections(new[] {entryPointOnLine}, chartPointData.Points); + AssertEqualPointCollections(new[] + { + entryPointOnLine + }, chartPointData.Points); AssertEqualStyle(chartPointData.Style, Color.Blue, 8, Color.Gray, 2, ChartPointSymbol.Triangle); } @@ -169,7 +155,7 @@ public void CreateExitPoint_ExitPointNaN_ThrowsArgumentException() { // Call - TestDelegate call = () => PipingChartDataFactory.CreateExitPoint((RoundedDouble)double.NaN, null); + TestDelegate call = () => PipingChartDataFactory.CreateExitPoint((RoundedDouble) double.NaN, null); // Assert var exception = Assert.Throws(call); @@ -180,7 +166,7 @@ public void CreateExitPoint_SurfaceLineNull_ThrowsArgumentException() { // Call - TestDelegate call = () => PipingChartDataFactory.CreateExitPoint((RoundedDouble)1.0, null); + TestDelegate call = () => PipingChartDataFactory.CreateExitPoint((RoundedDouble) 1.0, null); // Assert var exception = Assert.Throws(call); @@ -191,15 +177,8 @@ public void CreateExitPoint_GivenSurfaceLine_ReturnsChartDataWithDefaultStyling() { // Setup - var points = new[] - { - new Point3D(1.2, 2.3, 4.0), - new Point3D(2.7, 2.8, 6.0) - }; + var surfaceLine = GetSurfaceLineWithGeometry(); - var surfaceLine = new RingtoetsPipingSurfaceLine(); - surfaceLine.SetGeometry(points); - var input = new PipingInput(new GeneralPipingInput()) { SurfaceLine = surfaceLine @@ -210,18 +189,21 @@ // Assert Assert.IsInstanceOf(data); - ChartPointData chartPointData = (ChartPointData)data; + ChartPointData chartPointData = (ChartPointData) data; Assert.AreEqual(1, chartPointData.Points.Count()); Assert.AreEqual(Resources.PipingInput_ExitPointL_DisplayName, chartPointData.Name); Point2D exitPointOnLine = new Point2D(input.ExitPointL, surfaceLine.GetZAtL(input.ExitPointL)); - AssertEqualPointCollections(new[] { exitPointOnLine }, chartPointData.Points); + AssertEqualPointCollections(new[] + { + exitPointOnLine + }, chartPointData.Points); AssertEqualStyle(chartPointData.Style, Color.Brown, 8, Color.Gray, 2, ChartPointSymbol.Triangle); } [Test] - public void CreateDitchPolderSide_DitchPolderSideNull_ThrowsArgumentNullException() + public void CreateDitchPolderSide_SurfaceLineNull_ThrowsArgumentNullException() { // Call TestDelegate call = () => PipingChartDataFactory.CreateDitchPolderSide(null); @@ -232,26 +214,33 @@ } [Test] + public void CreateDitchPolderSide_DitchPolderSideNull_ThrowsArgumentNullException() + { + // Setup + var surfaceLine = GetSurfaceLineWithGeometry(); + + // Call + TestDelegate call = () => PipingChartDataFactory.CreateDitchPolderSide(surfaceLine); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("worldCoordinate", exception.ParamName); + } + + [Test] public void CreateDitchPolderSide_GivenDitchPolderSide_ReturnsChartDataWithDefaultStyling() { // Setup Point3D ditchPolderSide = new Point3D(1.2, 2.3, 4.0); - var points = new[] - { - new Point3D(1.2, 2.3, 4.0), - new Point3D(2.7, 2.0, 6.0) - }; - - var surfaceLine = new RingtoetsPipingSurfaceLine(); - surfaceLine.SetGeometry(points); + var surfaceLine = GetSurfaceLineWithGeometry(); surfaceLine.SetDitchPolderSideAt(ditchPolderSide); // Call ChartData data = PipingChartDataFactory.CreateDitchPolderSide(surfaceLine); // Assert Assert.IsInstanceOf(data); - ChartPointData chartPointData = (ChartPointData)data; + ChartPointData chartPointData = (ChartPointData) data; Assert.AreEqual(1, chartPointData.Points.Count()); Assert.AreEqual(PipingDataResources.CharacteristicPoint_DitchPolderSide, chartPointData.Name); @@ -261,7 +250,7 @@ } [Test] - public void CreateBottomDitchPolderSide_BottomDitchPolderSideNull_ThrowsArgumentNullException() + public void CreateBottomDitchPolderSide_SurfaceLineNull_ThrowsArgumentNullException() { // Call TestDelegate call = () => PipingChartDataFactory.CreateBottomDitchPolderSide(null); @@ -272,26 +261,33 @@ } [Test] + public void CreateBottomDitchPolderSide_BottomDitchPolderSideNull_ThrowsArgumentNullException() + { + // Setup + var surfaceLine = GetSurfaceLineWithGeometry(); + + // Call + TestDelegate call = () => PipingChartDataFactory.CreateBottomDitchPolderSide(surfaceLine); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("worldCoordinate", exception.ParamName); + } + + [Test] public void CreateBottomDitchPolderSide_GivenBottomDitchPolderSide_ReturnsChartDataWithDefaultStyling() { // Setup Point3D bottomDitchPolderSide = new Point3D(1.2, 2.3, 4.0); - var points = new[] - { - new Point3D(1.2, 2.3, 4.0), - new Point3D(2.7, 2.0, 6.0) - }; - - var surfaceLine = new RingtoetsPipingSurfaceLine(); - surfaceLine.SetGeometry(points); + var surfaceLine = GetSurfaceLineWithGeometry(); surfaceLine.SetBottomDitchPolderSideAt(bottomDitchPolderSide); // Call ChartData data = PipingChartDataFactory.CreateBottomDitchPolderSide(surfaceLine); // Assert Assert.IsInstanceOf(data); - ChartPointData chartPointData = (ChartPointData)data; + ChartPointData chartPointData = (ChartPointData) data; Assert.AreEqual(1, chartPointData.Points.Count()); Assert.AreEqual(PipingDataResources.CharacteristicPoint_BottomDitchPolderSide, chartPointData.Name); @@ -301,7 +297,7 @@ } [Test] - public void CreateBottomDitchDikeSide_BottomDitchDikeSideNull_ThrowsArgumentNullException() + public void CreateBottomDitchDikeSide_SurfaceLineNull_ThrowsArgumentNullException() { // Call TestDelegate call = () => PipingChartDataFactory.CreateBottomDitchDikeSide(null); @@ -312,26 +308,33 @@ } [Test] - public void CreateBottomDitchDikeSide_GivenBottomDitchDikeSide_ReturnsChartDataWithDefaultStyling() + public void CreateBottomDitchDikeSide_BottomDitchDikeSideNull_ThrowsArgumentNullException() { // Setup - Point3D bottomDitchDikeSide = new Point3D(1.0, 4.3, 6.4); - var points = new[] - { - new Point3D(1.0, 4.3, 6.4), - new Point3D(2.7, 2.0, 6.0) - }; + var surfaceLine = GetSurfaceLineWithGeometry(); - var surfaceLine = new RingtoetsPipingSurfaceLine(); - surfaceLine.SetGeometry(points); + // Call + TestDelegate call = () => PipingChartDataFactory.CreateBottomDitchDikeSide(surfaceLine); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("worldCoordinate", exception.ParamName); + } + + [Test] + public void CreateBottomDitchDikeSide_GivenBottomDitchDikeSide_ReturnsChartDataWithDefaultStyling() + { + // Setup + Point3D bottomDitchDikeSide = new Point3D(1.2, 2.3, 4.0); + var surfaceLine = GetSurfaceLineWithGeometry(); surfaceLine.SetBottomDitchDikeSideAt(bottomDitchDikeSide); // Call ChartData data = PipingChartDataFactory.CreateBottomDitchDikeSide(surfaceLine); // Assert Assert.IsInstanceOf(data); - ChartPointData chartPointData = (ChartPointData)data; + ChartPointData chartPointData = (ChartPointData) data; Assert.AreEqual(1, chartPointData.Points.Count()); Assert.AreEqual(PipingDataResources.CharacteristicPoint_BottomDitchDikeSide, chartPointData.Name); @@ -341,7 +344,7 @@ } [Test] - public void CreateDitchDikeSide_DitchDikeSideNull_ThrowsArgumentNullException() + public void CreateDitchDikeSide_SurfaceLineNull_ThrowsArgumentNullException() { // Call TestDelegate call = () => PipingChartDataFactory.CreateDitchDikeSide(null); @@ -352,26 +355,33 @@ } [Test] - public void CreateDitchDikeSide_GivenDitchDikeSide_ReturnsChartDataWithDefaultStyling() + public void CreateDitchDikeSide_DitchDikeSideNull_ThrowsArgumentNullException() { // Setup - Point3D ditchDikeSide = new Point3D(1.0, 4.3, 6.4); - var points = new[] - { - new Point3D(1.0, 4.3, 6.4), - new Point3D(2.7, 2.0, 6.0) - }; + var surfaceLine = GetSurfaceLineWithGeometry(); - var surfaceLine = new RingtoetsPipingSurfaceLine(); - surfaceLine.SetGeometry(points); + // Call + TestDelegate call = () => PipingChartDataFactory.CreateDitchDikeSide(surfaceLine); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("worldCoordinate", exception.ParamName); + } + + [Test] + public void CreateDitchDikeSide_GivenDitchDikeSide_ReturnsChartDataWithDefaultStyling() + { + // Setup + Point3D ditchDikeSide = new Point3D(1.2, 2.3, 4.0); + var surfaceLine = GetSurfaceLineWithGeometry(); surfaceLine.SetDitchDikeSideAt(ditchDikeSide); // Call ChartData data = PipingChartDataFactory.CreateDitchDikeSide(surfaceLine); // Assert Assert.IsInstanceOf(data); - ChartPointData chartPointData = (ChartPointData)data; + ChartPointData chartPointData = (ChartPointData) data; Assert.AreEqual(1, chartPointData.Points.Count()); Assert.AreEqual(PipingDataResources.CharacteristicPoint_DitchDikeSide, chartPointData.Name); @@ -381,7 +391,7 @@ } [Test] - public void CreateDikeToeAtRiver_DikeToeAtRiverNull_ThrowsArgumentNullException() + public void CreateDikeToeAtRiver_SurfaceLineNull_ThrowsArgumentNullException() { // Call TestDelegate call = () => PipingChartDataFactory.CreateDikeToeAtRiver(null); @@ -392,26 +402,33 @@ } [Test] + public void CreateDikeToeAtRiver_DikeToeAtRiverNull_ThrowsArgumentNullException() + { + // Setup + var surfaceLine = GetSurfaceLineWithGeometry(); + + // Call + TestDelegate call = () => PipingChartDataFactory.CreateDikeToeAtRiver(surfaceLine); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("worldCoordinate", exception.ParamName); + } + + [Test] public void CreateDikeToeAtRiver_GivenDikeToeAtRivere_ReturnsChartDataWithDefaultStyling() { // Setup Point3D dikeToeAtRiver = new Point3D(1.2, 2.3, 4.0); - var points = new[] - { - new Point3D(1.2, 2.3, 4.0), - new Point3D(2.7, 2.0, 6.0) - }; - - var surfaceLine = new RingtoetsPipingSurfaceLine(); - surfaceLine.SetGeometry(points); + var surfaceLine = GetSurfaceLineWithGeometry(); surfaceLine.SetDikeToeAtRiverAt(dikeToeAtRiver); // Call ChartData data = PipingChartDataFactory.CreateDikeToeAtRiver(surfaceLine); // Assert Assert.IsInstanceOf(data); - ChartPointData chartPointData = (ChartPointData)data; + ChartPointData chartPointData = (ChartPointData) data; Assert.AreEqual(1, chartPointData.Points.Count()); Assert.AreEqual(PipingDataResources.CharacteristicPoint_DikeToeAtRiver, chartPointData.Name); @@ -421,7 +438,7 @@ } [Test] - public void CreateDikeToeAtPolder_DikeToeAtPolderNull_ThrowsArgumentNullException() + public void CreateDikeToeAtPolder_SurfaceLineNull_ThrowsArgumentNullException() { // Call TestDelegate call = () => PipingChartDataFactory.CreateDikeToeAtPolder(null); @@ -432,26 +449,33 @@ } [Test] - public void CreateDikeToeAtPolder_GivenDikeToeAtPolder_ReturnsChartDataWithDefaultStyling() + public void CreateDikeToeAtPolder_DikeToeAtPolderNull_ThrowsArgumentNullException() { // Setup - Point3D dikeToeAtPolder = new Point3D(1.0, 4.3, 6.4); - var points = new[] - { - new Point3D(1.0, 4.3, 6.4), - new Point3D(2.7, 2.0, 6.0) - }; + var surfaceLine = GetSurfaceLineWithGeometry(); - var surfaceLine = new RingtoetsPipingSurfaceLine(); - surfaceLine.SetGeometry(points); + // Call + TestDelegate call = () => PipingChartDataFactory.CreateDikeToeAtPolder(surfaceLine); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("worldCoordinate", exception.ParamName); + } + + [Test] + public void CreateDikeToeAtPolder_GivenDikeToeAtPolder_ReturnsChartDataWithDefaultStyling() + { + // Setup + Point3D dikeToeAtPolder = new Point3D(1.2, 2.3, 4.0); + var surfaceLine = GetSurfaceLineWithGeometry(); surfaceLine.SetDikeToeAtPolderAt(dikeToeAtPolder); // Call ChartData data = PipingChartDataFactory.CreateDikeToeAtPolder(surfaceLine); // Assert Assert.IsInstanceOf(data); - ChartPointData chartPointData = (ChartPointData)data; + ChartPointData chartPointData = (ChartPointData) data; Assert.AreEqual(1, chartPointData.Points.Count()); Assert.AreEqual(PipingDataResources.CharacteristicPoint_DikeToeAtPolder, chartPointData.Name); @@ -460,6 +484,19 @@ AssertEqualStyle(chartPointData.Style, Color.Silver, 8, Color.Transparent, 0, ChartPointSymbol.Circle); } + private static RingtoetsPipingSurfaceLine GetSurfaceLineWithGeometry() + { + var points = new[] + { + new Point3D(1.2, 2.3, 4.0), + new Point3D(2.7, 2.8, 6.0) + }; + + var surfaceLine = new RingtoetsPipingSurfaceLine(); + surfaceLine.SetGeometry(points); + return surfaceLine; + } + private void AssertEqualPointCollections(IEnumerable points, IEnumerable chartPoints) { CollectionAssert.AreEqual(points.Select(p => new Point2D(p.X, p.Y)), chartPoints); @@ -472,7 +509,10 @@ Point2D firstPoint = new Point2D(first.X, first.Y); Point2D lastPoint = new Point2D(last.X, last.Y); - AssertEqualPointCollections(new[] { point.ProjectIntoLocalCoordinates(firstPoint, lastPoint) }, chartPoints); + AssertEqualPointCollections(new[] + { + point.ProjectIntoLocalCoordinates(firstPoint, lastPoint) + }, chartPoints); } private void AssertEqualStyle(ChartLineStyle lineStyle, Color color, int width, DashStyle style) @@ -491,4 +531,4 @@ Assert.AreEqual(symbol, pointStyle.Symbol); } } -} +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs =================================================================== diff -u -rf04895089d34bddb618db8c7001c574428be10c6 -r449e2761ad14af6e84ea5c1a56aea71bc535e8f9 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs (.../PipingInputViewTest.cs) (revision f04895089d34bddb618db8c7001c574428be10c6) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs (.../PipingInputViewTest.cs) (revision 449e2761ad14af6e84ea5c1a56aea71bc535e8f9) @@ -31,7 +31,6 @@ using Ringtoets.Piping.Forms.Properties; using Ringtoets.Piping.Forms.Views; using Ringtoets.Piping.Primitives; - using PipingDataResources = Ringtoets.Piping.Data.Properties.Resources; namespace Ringtoets.Piping.Forms.Test.Views @@ -109,17 +108,7 @@ // Setup using (PipingInputView view = new PipingInputView()) { - var points = new[] - { - new Point3D(1.2, 2.3, 4.0), - new Point3D(2.7, 2.8, 6.0) - }; - - var surfaceLine = new RingtoetsPipingSurfaceLine - { - Name = "Surface line name" - }; - surfaceLine.SetGeometry(points); + var surfaceLine = GetSurfaceLineWithGeometry(); var input = new PipingInput(new GeneralPipingInput()) { SurfaceLine = surfaceLine @@ -191,18 +180,7 @@ // Setup using (PipingInputView view = new PipingInputView()) { - var points = new[] - { - new Point3D(1.2, 2.3, 4.0), - new Point3D(2.7, 2.8, 6.0) - }; - - var surfaceLine = new RingtoetsPipingSurfaceLine() - { - Name = "Surface line name" - - }; - surfaceLine.SetGeometry(points); + var surfaceLine = GetSurfaceLineWithGeometry(); surfaceLine.SetDitchDikeSideAt(new Point3D(1.2, 2.3, 4.0)); surfaceLine.SetBottomDitchDikeSideAt(new Point3D(1.2, 2.3, 4.0)); surfaceLine.SetDitchPolderSideAt(new Point3D(1.2, 2.3, 4.0)); @@ -234,7 +212,7 @@ } [Test] - public void Data_WithoutSurfaceLine_ChartDataSet() + public void Data_WithoutSurfaceLine_CollectionOfEmptyChartDataSet() { // Setup using (PipingInputView view = new PipingInputView()) @@ -368,7 +346,7 @@ [Test] public void UpdateObservers_CalculationUpdatedNotifyObserversOnOldData_NoUpdateInViewData() { - // Setup + // Setup using (PipingInputView view = new PipingInputView()) { var initialName = "Initial name"; @@ -408,17 +386,8 @@ using (PipingInputView view = new PipingInputView()) { var characteristicPoint = new Point3D(1.2, 2.3, 4.0); - var points = new[] - { - characteristicPoint, - new Point3D(2.7, 2.8, 6.0) - }; + var surfaceLine = GetSurfaceLineWithGeometry(); - var surfaceLine = new RingtoetsPipingSurfaceLine - { - Name = "Surface line name" - }; - surfaceLine.SetGeometry(points); surfaceLine.SetDitchDikeSideAt(characteristicPoint); surfaceLine.SetBottomDitchDikeSideAt(characteristicPoint); surfaceLine.SetDitchPolderSideAt(characteristicPoint); @@ -433,27 +402,18 @@ view.Data = pipingInput; ChartLineData oldSurfaceLineChartData = (ChartLineData) view.Chart.Data.List[surfaceLineIndex]; - ChartPointData oldEntryPointChartData = (ChartPointData)view.Chart.Data.List[entryPointIndex]; + ChartPointData oldEntryPointChartData = (ChartPointData) view.Chart.Data.List[entryPointIndex]; ChartPointData oldExitPointChartData = (ChartPointData) view.Chart.Data.List[exitPointIndex]; - ChartPointData oldDitchDikeSideData = (ChartPointData)view.Chart.Data.List[ditchDikeSideIndex]; - ChartPointData oldBottomDitchDikeSideData = (ChartPointData)view.Chart.Data.List[bottomDitchDikeSideIndex]; - ChartPointData oldDitchPolderSideData = (ChartPointData)view.Chart.Data.List[ditchPolderSideIndex]; - ChartPointData oldBottomDitchPolderSideData = (ChartPointData)view.Chart.Data.List[bottomDitchPolderSideIndex]; - ChartPointData oldDikeToeAtPolderData = (ChartPointData)view.Chart.Data.List[dikeToeAtPolderIndex]; - ChartPointData oldDikeToeAtRiverData = (ChartPointData)view.Chart.Data.List[dikeToeAtRiverIndex]; + ChartPointData oldDitchDikeSideData = (ChartPointData) view.Chart.Data.List[ditchDikeSideIndex]; + ChartPointData oldBottomDitchDikeSideData = (ChartPointData) view.Chart.Data.List[bottomDitchDikeSideIndex]; + ChartPointData oldDitchPolderSideData = (ChartPointData) view.Chart.Data.List[ditchPolderSideIndex]; + ChartPointData oldBottomDitchPolderSideData = (ChartPointData) view.Chart.Data.List[bottomDitchPolderSideIndex]; + ChartPointData oldDikeToeAtPolderData = (ChartPointData) view.Chart.Data.List[dikeToeAtPolderIndex]; + ChartPointData oldDikeToeAtRiverData = (ChartPointData) view.Chart.Data.List[dikeToeAtRiverIndex]; var characteristicPoint2 = new Point3D(3.5, 2.3, 8.0); - var points2 = new[] - { - characteristicPoint2, - new Point3D(6.9, 2.0, 2.0) - }; + var surfaceLine2 = GetSecondSurfaceLineWithGeometry(); - var surfaceLine2 = new RingtoetsPipingSurfaceLine - { - Name = "Surface line name" - }; - surfaceLine2.SetGeometry(points2); surfaceLine2.SetDitchDikeSideAt(characteristicPoint2); surfaceLine2.SetBottomDitchDikeSideAt(characteristicPoint2); surfaceLine2.SetDitchPolderSideAt(characteristicPoint2); @@ -467,34 +427,34 @@ pipingInput.NotifyObservers(); // Assert - ChartLineData newSurfaceLineChartData = (ChartLineData)view.Chart.Data.List[surfaceLineIndex]; + ChartLineData newSurfaceLineChartData = (ChartLineData) view.Chart.Data.List[surfaceLineIndex]; Assert.AreNotEqual(oldSurfaceLineChartData, newSurfaceLineChartData); AssertSurfaceLineChartData(surfaceLine2, newSurfaceLineChartData); ChartPointData newEntryPointChartData = (ChartPointData) view.Chart.Data.List[entryPointIndex]; Assert.AreNotEqual(oldEntryPointChartData, newEntryPointChartData); AssertEntryPointLPointchartData(pipingInput, surfaceLine2, newEntryPointChartData); - + ChartPointData newExitPointChartData = (ChartPointData) view.Chart.Data.List[exitPointIndex]; Assert.AreNotEqual(oldExitPointChartData, newExitPointChartData); AssertExitPointLPointchartData(pipingInput, surfaceLine2, newExitPointChartData); - ChartPointData newDitchDikeSideData = (ChartPointData)view.Chart.Data.List[ditchDikeSideIndex]; + ChartPointData newDitchDikeSideData = (ChartPointData) view.Chart.Data.List[ditchDikeSideIndex]; Assert.AreNotEqual(oldDitchDikeSideData, newDitchDikeSideData); - - ChartPointData newBottomDitchDikeSideData = (ChartPointData)view.Chart.Data.List[bottomDitchDikeSideIndex]; + + ChartPointData newBottomDitchDikeSideData = (ChartPointData) view.Chart.Data.List[bottomDitchDikeSideIndex]; Assert.AreNotEqual(oldBottomDitchDikeSideData, newBottomDitchDikeSideData); - - ChartPointData newDitchPolderSideData = (ChartPointData)view.Chart.Data.List[ditchPolderSideIndex]; + + ChartPointData newDitchPolderSideData = (ChartPointData) view.Chart.Data.List[ditchPolderSideIndex]; Assert.AreNotEqual(oldDitchPolderSideData, newDitchPolderSideData); - - ChartPointData newBottomDitchPolderSideData = (ChartPointData)view.Chart.Data.List[bottomDitchPolderSideIndex]; + + ChartPointData newBottomDitchPolderSideData = (ChartPointData) view.Chart.Data.List[bottomDitchPolderSideIndex]; Assert.AreNotEqual(oldBottomDitchPolderSideData, newBottomDitchPolderSideData); - - ChartPointData newDikeToeAtPolderData = (ChartPointData)view.Chart.Data.List[dikeToeAtPolderIndex]; + + ChartPointData newDikeToeAtPolderData = (ChartPointData) view.Chart.Data.List[dikeToeAtPolderIndex]; Assert.AreNotEqual(oldDikeToeAtPolderData, newDikeToeAtPolderData); - - ChartPointData newDikeToeAtRiverData = (ChartPointData)view.Chart.Data.List[dikeToeAtRiverIndex]; + + ChartPointData newDikeToeAtRiverData = (ChartPointData) view.Chart.Data.List[dikeToeAtRiverIndex]; Assert.AreNotEqual(oldDikeToeAtRiverData, newDikeToeAtRiverData); AssertCharacteristicPoints(surfaceLine2, view.Chart.Data.List); @@ -507,17 +467,7 @@ // Setup using (PipingInputView view = new PipingInputView()) { - var points = new[] - { - new Point3D(1.2, 2.3, 4.0), - new Point3D(2.7, 2.8, 6.0) - }; - - var surfaceLine = new RingtoetsPipingSurfaceLine - { - Name = "Surface line name" - }; - surfaceLine.SetGeometry(points); + var surfaceLine = GetSurfaceLineWithGeometry(); var input1 = new PipingInput(new GeneralPipingInput()) { SurfaceLine = surfaceLine @@ -530,15 +480,8 @@ view.Data = input1; - var points2 = new[] - { - new Point3D(3.5, 2.3, 8.0), - new Point3D(6.9, 2.0, 2.0) - }; + var surfaceLine2 = GetSecondSurfaceLineWithGeometry(); - var surfaceLine2 = new RingtoetsPipingSurfaceLine(); - surfaceLine2.SetGeometry(points2); - input2.SurfaceLine = surfaceLine2; // Call @@ -552,20 +495,11 @@ [Test] public void NotifyObservers_DataUpdatedNotifyObserversOnOldData_NoUpdateInViewData() { - // Setup + // Setup using (PipingInputView view = new PipingInputView()) { - var points = new[] - { - new Point3D(1.2, 2.3, 4.0), - new Point3D(2.7, 2.8, 6.0) - }; + var surfaceLine = GetSurfaceLineWithGeometry(); - var surfaceLine = new RingtoetsPipingSurfaceLine - { - Name = "Surface line name" - }; - surfaceLine.SetGeometry(points); var input1 = new PipingInput(new GeneralPipingInput()) { SurfaceLine = surfaceLine @@ -577,15 +511,8 @@ view.Data = input2; - var points2 = new[] - { - new Point3D(3.5, 2.3, 8.0), - new Point3D(6.9, 2.0, 2.0) - }; + var surfaceLine2 = GetSecondSurfaceLineWithGeometry(); - var surfaceLine2 = new RingtoetsPipingSurfaceLine(); - surfaceLine2.SetGeometry(points2); - input1.SurfaceLine = surfaceLine2; // Call @@ -606,6 +533,38 @@ private const int exitPointIndex = 7; private const int entryPointIndex = 8; + private static RingtoetsPipingSurfaceLine GetSurfaceLineWithGeometry() + { + var points = new[] + { + new Point3D(1.2, 2.3, 4.0), + new Point3D(2.7, 2.8, 6.0) + }; + + return GetSurfaceLine(points); + } + + private static RingtoetsPipingSurfaceLine GetSecondSurfaceLineWithGeometry() + { + var points = new[] + { + new Point3D(3.5, 2.3, 8.0), + new Point3D(6.9, 2.0, 2.0) + }; + + return GetSurfaceLine(points); + } + + private static RingtoetsPipingSurfaceLine GetSurfaceLine(Point3D[] points) + { + var surfaceLine = new RingtoetsPipingSurfaceLine + { + Name = "Surface line name" + }; + surfaceLine.SetGeometry(points); + return surfaceLine; + } + private void AssertSurfaceLineChartData(RingtoetsPipingSurfaceLine surfaceLine, ChartData chartData) { Assert.IsInstanceOf(chartData); @@ -623,18 +582,24 @@ Assert.AreEqual(1, entryPointChartData.Points.Count()); Point2D entryPoint = new Point2D(pipingInput.EntryPointL, surfaceLine.GetZAtL(pipingInput.EntryPointL)); - CollectionAssert.AreEqual(new[] { entryPoint }, entryPointChartData.Points); + CollectionAssert.AreEqual(new[] + { + entryPoint + }, entryPointChartData.Points); Assert.AreEqual(Resources.PipingInput_EntryPointL_DisplayName, entryPointChartData.Name); } private void AssertExitPointLPointchartData(PipingInput pipingInput, RingtoetsPipingSurfaceLine surfaceLine, ChartData chartData) { Assert.IsInstanceOf(chartData); - ChartPointData exitPointChartData = (ChartPointData)chartData; + ChartPointData exitPointChartData = (ChartPointData) chartData; Assert.AreEqual(1, exitPointChartData.Points.Count()); Point2D exitPoint = new Point2D(pipingInput.ExitPointL, surfaceLine.GetZAtL(pipingInput.ExitPointL)); - CollectionAssert.AreEqual(new[] { exitPoint }, exitPointChartData.Points); + CollectionAssert.AreEqual(new[] + { + exitPoint + }, exitPointChartData.Points); Assert.AreEqual(Resources.PipingInput_ExitPointL_DisplayName, exitPointChartData.Name); } @@ -645,34 +610,52 @@ Point2D firstPoint = new Point2D(first.X, first.Y); Point2D lastPoint = new Point2D(last.X, last.Y); - var ditchDikeSideData = (ChartPointData)characteristicPoints[ditchDikeSideIndex]; + var ditchDikeSideData = (ChartPointData) characteristicPoints[ditchDikeSideIndex]; Assert.AreEqual(1, ditchDikeSideData.Points.Count()); - CollectionAssert.AreEqual(new[] { surfaceLine.DitchDikeSide.ProjectIntoLocalCoordinates(firstPoint, lastPoint) }, ditchDikeSideData.Points); + CollectionAssert.AreEqual(new[] + { + surfaceLine.DitchDikeSide.ProjectIntoLocalCoordinates(firstPoint, lastPoint) + }, ditchDikeSideData.Points); Assert.AreEqual(PipingDataResources.CharacteristicPoint_DitchDikeSide, ditchDikeSideData.Name); - var bottomDitchDikeSideData = (ChartPointData)characteristicPoints[bottomDitchDikeSideIndex]; + var bottomDitchDikeSideData = (ChartPointData) characteristicPoints[bottomDitchDikeSideIndex]; Assert.AreEqual(1, bottomDitchDikeSideData.Points.Count()); - CollectionAssert.AreEqual(new[] { surfaceLine.BottomDitchDikeSide.ProjectIntoLocalCoordinates(firstPoint, lastPoint) }, bottomDitchDikeSideData.Points); + CollectionAssert.AreEqual(new[] + { + surfaceLine.BottomDitchDikeSide.ProjectIntoLocalCoordinates(firstPoint, lastPoint) + }, bottomDitchDikeSideData.Points); Assert.AreEqual(PipingDataResources.CharacteristicPoint_BottomDitchDikeSide, bottomDitchDikeSideData.Name); - var ditchPolderSideData = (ChartPointData)characteristicPoints[ditchPolderSideIndex]; + var ditchPolderSideData = (ChartPointData) characteristicPoints[ditchPolderSideIndex]; Assert.AreEqual(1, ditchPolderSideData.Points.Count()); - CollectionAssert.AreEqual(new[] { surfaceLine.DitchPolderSide.ProjectIntoLocalCoordinates(firstPoint, lastPoint) }, ditchPolderSideData.Points); + CollectionAssert.AreEqual(new[] + { + surfaceLine.DitchPolderSide.ProjectIntoLocalCoordinates(firstPoint, lastPoint) + }, ditchPolderSideData.Points); Assert.AreEqual(PipingDataResources.CharacteristicPoint_DitchPolderSide, ditchPolderSideData.Name); - var bottomDitchPolderSideData = (ChartPointData)characteristicPoints[bottomDitchPolderSideIndex]; + var bottomDitchPolderSideData = (ChartPointData) characteristicPoints[bottomDitchPolderSideIndex]; Assert.AreEqual(1, bottomDitchPolderSideData.Points.Count()); - CollectionAssert.AreEqual(new[] { surfaceLine.BottomDitchPolderSide.ProjectIntoLocalCoordinates(firstPoint, lastPoint) }, bottomDitchPolderSideData.Points); + CollectionAssert.AreEqual(new[] + { + surfaceLine.BottomDitchPolderSide.ProjectIntoLocalCoordinates(firstPoint, lastPoint) + }, bottomDitchPolderSideData.Points); Assert.AreEqual(PipingDataResources.CharacteristicPoint_BottomDitchPolderSide, bottomDitchPolderSideData.Name); - var dikeToeAtPolderData = (ChartPointData)characteristicPoints[dikeToeAtPolderIndex]; + var dikeToeAtPolderData = (ChartPointData) characteristicPoints[dikeToeAtPolderIndex]; Assert.AreEqual(1, dikeToeAtPolderData.Points.Count()); - CollectionAssert.AreEqual(new[] { surfaceLine.DikeToeAtPolder.ProjectIntoLocalCoordinates(firstPoint, lastPoint) }, dikeToeAtPolderData.Points); + CollectionAssert.AreEqual(new[] + { + surfaceLine.DikeToeAtPolder.ProjectIntoLocalCoordinates(firstPoint, lastPoint) + }, dikeToeAtPolderData.Points); Assert.AreEqual(PipingDataResources.CharacteristicPoint_DikeToeAtPolder, dikeToeAtPolderData.Name); - var dikeToeAtRiverData = (ChartPointData)characteristicPoints[dikeToeAtRiverIndex]; + var dikeToeAtRiverData = (ChartPointData) characteristicPoints[dikeToeAtRiverIndex]; Assert.AreEqual(1, dikeToeAtRiverData.Points.Count()); - CollectionAssert.AreEqual(new[] { surfaceLine.DikeToeAtRiver.ProjectIntoLocalCoordinates(firstPoint, lastPoint) }, dikeToeAtRiverData.Points); + CollectionAssert.AreEqual(new[] + { + surfaceLine.DikeToeAtRiver.ProjectIntoLocalCoordinates(firstPoint, lastPoint) + }, dikeToeAtRiverData.Points); Assert.AreEqual(PipingDataResources.CharacteristicPoint_DikeToeAtRiver, dikeToeAtRiverData.Name); } }