Beispiel #1
0
        public void DistanceTo_of_Vector2_and_Box2_is_correct
            ([ValueSource(typeof(GeometryTestUtils), "Distance_of_Vector2_and_Box2_TestCases")] GeometryTestUtils.Distance_of_Vector2_and_Box2_TestCase testCase)
        {
            var result = testCase.Point.DistanceTo(testCase.Box);

            Expect(result, Is.EqualTo(testCase.Distance).Within(_tolerance));
        }
        public void DistanceTo_of_Vector2_and_IClosedPolyline_is_correct_for_a_Box2
            ([ValueSource(typeof(GeometryTestUtils), "Distance_of_Vector2_and_Box2_TestCases")] GeometryTestUtils.Distance_of_Vector2_and_Box2_TestCase testCase)
        {
            var result = testCase.Point.DistanceTo((IClosedPolyline)testCase.Box);

            if (testCase.Distance > 0) // skipping interior test cases in which Box2 behavior is different (it is considered to be filled)
            {
                Expect(result, Is.EqualTo(testCase.Distance).Within(_tolerance));
            }
        }
        public void FindClosestPoint_is_correct_for_a_Box2
            ([ValueSource(typeof(GeometryTestUtils), "Distance_of_Vector2_and_Box2_TestCases")] GeometryTestUtils.Distance_of_Vector2_and_Box2_TestCase testCase)
        {
            Vector2 closetPoint;
            double  distance2;

            testCase.Box.FindClosestPoint(testCase.Point, out closetPoint, out distance2);

            if (testCase.Distance > 0) // skipping interior test cases in which Box2 behavior is different (it is considered to be filled)
            {
                Expect(Math.Sqrt(distance2), Is.EqualTo(testCase.Distance).Within(_tolerance));
                Expect(Vector2.Distance(closetPoint, testCase.ClosestPoint), Is.LessThan(_tolerance));
            }
        }