Index: DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/PolyLineTest.cs =================================================================== diff -u -r4047 -r4070 --- DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/PolyLineTest.cs (.../PolyLineTest.cs) (revision 4047) +++ DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/PolyLineTest.cs (.../PolyLineTest.cs) (revision 4070) @@ -19,21 +19,22 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Collections.Generic; +using Deltares.Dam.Data; using Deltares.Geometry; +using NUnit.Framework; namespace Deltares.Dam.Tests { - using NUnit.Framework; - using Data; - [TestFixture] public class PolyLineTest { [SetUp] - public void FixtureSetup() - { - } + public void FixtureSetup() {} + [TearDown] + public void FixtureTearDown() {} + [Test] public void LineWithoutPointsShouldNotExist() { @@ -54,50 +55,53 @@ { var polyLine = new PolyLine(); polyLine.Points.Add(new GeometryPoint()); - polyLine.Points.Add(new GeometryPoint() { X = 1.0 }); + polyLine.Points.Add(new GeometryPoint + { + X = 1.0 + }); Assert.IsTrue(polyLine.Exists()); } [Test] public void CheckIfLineWithAscendingXIsEvaluatedCorrectlyAsAscending() { - var polyLine = CreateStrictAscendingPolyLine(); + PolyLine polyLine = CreateStrictAscendingPolyLine(); Assert.IsTrue(polyLine.IsXAscending()); } [Test] public void CheckIfLineWithNotStrictAscendingXIsEvaluatedCorrectlyAsAscending() { - var polyLine = CreateNotStrictAscendingPolyLine(); + PolyLine polyLine = CreateNotStrictAscendingPolyLine(); Assert.IsTrue(polyLine.IsXAscending()); } [Test] public void CheckIfLineWithNotStrictAscendingXIsEvaluatedCorrectlyAsNotStrictAscending() { - var polyLine = CreateNotStrictAscendingPolyLine(); + PolyLine polyLine = CreateNotStrictAscendingPolyLine(); Assert.IsFalse(polyLine.IsXStrictAscending()); } [Test] public void CheckIfLineWithNotAscendingXIsEvaluatedCorrectlyAsNotAscending() { - var polyLine = CreateNotAscendingPolyLine(); + PolyLine polyLine = CreateNotAscendingPolyLine(); Assert.IsFalse(polyLine.IsXAscending()); } [Test] public void ThrowsExceptionOnNotStrictAscendingXPolylineYFromXCalculation() { - var polyLine = CreateNotAscendingPolyLine(); + PolyLine polyLine = CreateNotAscendingPolyLine(); Assert.That(() => polyLine.YFromX(1.0), Throws.InstanceOf()); } [Test] public void CheckIfYFromXEvaluatesCorrectly() { const double cTolerance = 0.0001; - var polyLine = CreateStrictAscendingPolyLine(); + PolyLine polyLine = CreateStrictAscendingPolyLine(); Assert.AreEqual(5.0, polyLine.YFromX(1.0), cTolerance); Assert.AreEqual(9.0, polyLine.YFromX(4.0), cTolerance); } @@ -106,7 +110,7 @@ public void CheckIfYFromXEvaluatesCorrectlyWithOutOfBoundsXValues() { const double cTolerance = 0.0001; - var polyLine = CreateStrictAscendingPolyLine(); + PolyLine polyLine = CreateStrictAscendingPolyLine(); Assert.AreEqual(0.0, polyLine.YFromX(-3.0), cTolerance); Assert.AreEqual(7.0, polyLine.YFromX(10.0), cTolerance); } @@ -118,7 +122,7 @@ public void CheckIfYFromXEvaluatesCorrectlyWithNotStrictAscendingPolyLine() { const double cTolerance = 0.0001; - var polyLine = CreateNotStrictAscendingPolyLine(); + PolyLine polyLine = CreateNotStrictAscendingPolyLine(); Assert.AreEqual(5.0, polyLine.YFromX(1.0), cTolerance); Assert.AreEqual(10.0, polyLine.YFromX(3.0), cTolerance); } @@ -129,8 +133,8 @@ [Test] public void EqualsReturnsFalseWithUnequalLines() { - var polyLine1 = CreateStrictAscendingPolyLine(); - var polyLine2 = CreateNotStrictAscendingPolyLine(); + PolyLine polyLine1 = CreateStrictAscendingPolyLine(); + PolyLine polyLine2 = CreateNotStrictAscendingPolyLine(); Assert.IsFalse(polyLine1.Equals(polyLine2)); } @@ -140,7 +144,7 @@ [Test] public void CheckIfDeleteCoinsidingPointsReturnsLessPoints() { - var polyLine1 = CreateStrictAscendingPolyLine(); + PolyLine polyLine1 = CreateStrictAscendingPolyLine(); polyLine1.Points.Add(polyLine1.Points[0]); int currentLength = polyLine1.Points.Count; polyLine1.DeleteCoinsidingPoints(); @@ -153,8 +157,8 @@ [Test] public void EqualsReturnsTrueWithEqualLines() { - var polyLine1 = CreateStrictAscendingPolyLine(); - var polyLine2 = CreateStrictAscendingPolyLine(); + PolyLine polyLine1 = CreateStrictAscendingPolyLine(); + PolyLine polyLine2 = CreateStrictAscendingPolyLine(); Assert.IsTrue(polyLine1.Equals(polyLine2)); } @@ -164,9 +168,13 @@ [Test] public void TestOnePointIntersectionPointsXzWithLineXz() { - var polyLine1 = CreateIntersectPolyLine(); - var line = new Line { BeginPoint = new GeometryPoint(-5, 0, -1), EndPoint = new GeometryPoint(5, 0, -1) }; - var intersectionPoints = polyLine1.IntersectionPointsXzWithLineXz(line); + PolyLine polyLine1 = CreateIntersectPolyLine(); + var line = new Line + { + BeginPoint = new GeometryPoint(-5, 0, -1), + EndPoint = new GeometryPoint(5, 0, -1) + }; + IList intersectionPoints = polyLine1.IntersectionPointsXzWithLineXz(line); Assert.IsTrue(intersectionPoints.Count == 1); Assert.AreEqual(intersectionPoints[0].X, 1.0, GeometryPoint.Precision); Assert.AreEqual(intersectionPoints[0].Z, -1.0, GeometryPoint.Precision); @@ -175,18 +183,26 @@ [Test] public void TestNoPointIntersectionPointsXzWithLineXz() { - var polyLine1 = CreateIntersectPolyLine(); - var line = new Line { BeginPoint = new GeometryPoint(-5, 0, -1), EndPoint = new GeometryPoint(-3, 0, -1) }; - var intersectionPoints = polyLine1.IntersectionPointsXzWithLineXz(line); - Assert.IsTrue(intersectionPoints.Count == 0); + PolyLine polyLine1 = CreateIntersectPolyLine(); + var line = new Line + { + BeginPoint = new GeometryPoint(-5, 0, -1), + EndPoint = new GeometryPoint(-3, 0, -1) + }; + IList intersectionPoints = polyLine1.IntersectionPointsXzWithLineXz(line); + Assert.IsTrue(intersectionPoints.Count == 0); } [Test] public void TestTwoPointIntersectionPointsXzWithLineXz() { - var polyLine1 = CreateIntersectPolyLine(); - var line = new Line { BeginPoint = new GeometryPoint(-5, 0, -1), EndPoint = new GeometryPoint(15, 0, -1) }; - var intersectionPoints = polyLine1.IntersectionPointsXzWithLineXz(line); + PolyLine polyLine1 = CreateIntersectPolyLine(); + var line = new Line + { + BeginPoint = new GeometryPoint(-5, 0, -1), + EndPoint = new GeometryPoint(15, 0, -1) + }; + IList intersectionPoints = polyLine1.IntersectionPointsXzWithLineXz(line); Assert.IsTrue(intersectionPoints.Count == 2); Assert.AreEqual(intersectionPoints[0].X, 1.0, GeometryPoint.Precision); Assert.AreEqual(intersectionPoints[0].Z, -1.0, GeometryPoint.Precision); @@ -197,9 +213,20 @@ private PolyLine CreateStrictAscendingPolyLine() { var polyLine = new PolyLine(); - polyLine.Points.Add(new GeometryPoint() { X = -1.0}); - polyLine.Points.Add(new GeometryPoint() { X = 3.0, Y = 10.0}); - polyLine.Points.Add(new GeometryPoint() { X = 6.0, Y = 7.0}); + polyLine.Points.Add(new GeometryPoint + { + X = -1.0 + }); + polyLine.Points.Add(new GeometryPoint + { + X = 3.0, + Y = 10.0 + }); + polyLine.Points.Add(new GeometryPoint + { + X = 6.0, + Y = 7.0 + }); return polyLine; } @@ -226,17 +253,26 @@ private PolyLine CreateNotStrictAscendingPolyLine() { var polyLine = new PolyLine(); - polyLine.Points.Add(new GeometryPoint() { X = -1.0 }); - polyLine.Points.Add(new GeometryPoint() { X = 3.0, Y = 10.0 }); - polyLine.Points.Add(new GeometryPoint() { X = 3.0, Y = 6.0 }); - polyLine.Points.Add(new GeometryPoint() { X = 6.0, Y = 7.0 }); + polyLine.Points.Add(new GeometryPoint + { + X = -1.0 + }); + polyLine.Points.Add(new GeometryPoint + { + X = 3.0, + Y = 10.0 + }); + polyLine.Points.Add(new GeometryPoint + { + X = 3.0, + Y = 6.0 + }); + polyLine.Points.Add(new GeometryPoint + { + X = 6.0, + Y = 7.0 + }); return polyLine; } - - - [TearDown] - public void FixtureTearDown() - { - } } } \ No newline at end of file