Пример #1
0
        public void GetEuclideanDistanceToPoint_PointIsNull_ThrowArgumentNullException()
        {
            // Setup
            var segment = new Segment2D(new Point2D(1.2, 3.5), new Point2D(8.13, 21.34));

            // Call
            TestDelegate call = () => segment.GetEuclideanDistanceToPoint(null);

            // Assert
            Assert.Throws <ArgumentNullException>(call);
        }
Пример #2
0
        public void GetEuclideanDistanceToPoint_PointOnSecondPoint_ReturnZero()
        {
            // Setup
            var segment = new Segment2D(new Point2D(1.2, 3.5), new Point2D(8.13, 21.34));

            // Call
            double euclideanDistance = segment.GetEuclideanDistanceToPoint(segment.SecondPoint);

            // Assert
            Assert.AreEqual(0, euclideanDistance);
        }
Пример #3
0
        public void GetEuclideanDistanceToPoint_LinePerpendicularToSegmentIsClosest_ReturnExpectedDistance(
            double x, double y, double expectedDistance)
        {
            // Setup
            var point   = new Point2D(x, y);
            var segment = new Segment2D(new Point2D(1.1, 2.2), new Point2D(3.3, 4.4));

            // Call
            double actualDistance = segment.GetEuclideanDistanceToPoint(point);

            // Assert
            Assert.AreEqual(expectedDistance, actualDistance, 1e-6);
        }
Пример #4
0
        public void GetEuclideanDistanceToPoint_SecondPointIsClosest_ReturnExpectedDistance(
            double x, double y)
        {
            // Setup
            var point   = new Point2D(x, y);
            var segment = new Segment2D(new Point2D(1.1, 2.2), new Point2D(3.3, 4.4));

            // Call
            double actualDistance = segment.GetEuclideanDistanceToPoint(point);

            // Assert
            double expectedDistance = point.GetEuclideanDistanceTo(segment.SecondPoint);

            Assert.AreEqual(expectedDistance, actualDistance);
        }