using Deltares.Geometry; using NUnit.Framework; namespace Deltares.Geotechnics.WaternetCreator.Tests { [TestFixture] public class LineHelperTests { [Test] public void GetIntersectPointTest() { var line1 = new Line(); line1.BeginPoint = new GeometryPoint(0.0, 0, 0.0); line1.EndPoint = new GeometryPoint(10.0, 0, 0.0); var line2 = new Line(); line2.BeginPoint = new GeometryPoint(0.0, 0, -5.0); line2.EndPoint = new GeometryPoint(10.0, 0, 5.0); GeometryPoint isp = LineHelper.GetIntersectPoint(line1, line2, PointType.XZ); Assert.AreEqual(5.0, isp.X); Assert.AreEqual(0.0, isp.Z); } [Test] public void GetIntersectPointTestInvalidInputReturnsNaN() { var line1 = new Line(); line1.BeginPoint = new GeometryPoint(); line1.EndPoint = new GeometryPoint(); var line2 = new Line(); line2.BeginPoint = new GeometryPoint(0.0, 0, 0.0); line2.EndPoint = new GeometryPoint(10.0, 0, 5.0); GeometryPoint isp = LineHelper.GetIntersectPoint(line1, line2, PointType.XZ); Assert.AreEqual(double.NaN, isp.X); Assert.AreEqual(double.NaN, isp.Z); } [Test] public void GetIntersectPointTestReturnsBeginPoint() { var line1 = new Line(); line1.BeginPoint = new GeometryPoint(0.0, 0, 0.0); line1.EndPoint = new GeometryPoint(10.0, 0, 0.0); var line2 = new Line(); line2.BeginPoint = new GeometryPoint(0.0, 0, 0.0); line2.EndPoint = new GeometryPoint(10.0, 0, 5.0); GeometryPoint isp = LineHelper.GetIntersectPoint(line1, line2, PointType.XZ); Assert.AreEqual(0.0, isp.X); Assert.AreEqual(0.0, isp.Z); } [Test] public void GetIntersectPointTestReturnsNaN() { var line1 = new Line(); line1.BeginPoint = new GeometryPoint(0.0, 0, 0.0); line1.EndPoint = new GeometryPoint(10.0, 0, 0.0); var line2 = new Line(); line2.BeginPoint = new GeometryPoint(0.0, 0, -5.0); line2.EndPoint = new GeometryPoint(10.0, 0, -5.0); GeometryPoint isp = LineHelper.GetIntersectPoint(line1, line2, PointType.XZ); Assert.AreEqual(double.NaN, isp.X); Assert.AreEqual(double.NaN, isp.Z); } } }