コード例 #1
0
        public void TestFindFarthestInOnePoint()
        {
            Point point = new Point(100, 100);

            FindPairResult result = PointsDistances.FindFarthestPair(new[] { point });

            Assert.That(result.Point1, Is.EqualTo(point));
            Assert.That(result.Point2, Is.EqualTo(point));
            Assert.That(result.Distance, Is.EqualTo(0.0));
        }
コード例 #2
0
        public void TestFindFarthestInTenPoints()
        {
            List <Point> points = Enumerable.Range(0, 10)
                                  .Select(a => new Point(-1 * a * a, -1 * a * a))
                                  .ToList();
            var expectedResult = new[] { points.First(), points.Last() };

            FindPairResult result = PointsDistances.FindFarthestPair(points);

            CollectionAssert.AreEquivalent(expectedResult, new[] { result.Point1, result.Point2 });
        }
コード例 #3
0
        public void TestFindFarthestInThreePoints()
        {
            Point point1 = new Point(10, 0);
            Point point2 = new Point(20, 0);
            Point point3 = new Point(100, 100);

            FindPairResult result = PointsDistances.FindFarthestPair(new[] { point1, point2, point3 });

            Assert.That(result.Point1, Is.EqualTo(point1));
            Assert.That(result.Point2, Is.EqualTo(point3));
        }
コード例 #4
0
        public void TestFindFarthestInTwoPints()
        {
            Point point1 = new Point(10, 0);
            Point point2 = new Point(20, 0);

            FindPairResult result = PointsDistances.FindFarthestPair(new[] { point1, point2 });

            Assert.That(result.Point1, Is.EqualTo(point1));
            Assert.That(result.Point2, Is.EqualTo(point2));
            Assert.That(result.Distance, Is.EqualTo(10.0));
        }
コード例 #5
0
 public void TestFindFarthestInEmptyList()
 {
     PointsDistances.FindFarthestPair(new Point[0]);
 }
コード例 #6
0
 public void TestFindFarthestInNullList()
 {
     PointsDistances.FindFarthestPair(null);
 }