An object storing test data that is to be used in other tests.
        public static void polygon_xor(PolyPairTestData testData)
        {
            Console.WriteLine(testData.Name);

            if (testData.Name == "Fuzzed: 3")
            {
                Console.WriteLine("Skipping " + testData.Name + " ...need to test this one another way.");
                return;
            }

            var result = _xorOperation.Xor(testData.A, testData.B) as Polygon2;

            if (null != testData.R)
            {
                Assert.NotNull(result);
                testData.R.SpatiallyEqual(result).Should().BeTrue("Forward case failed: {0} ∩ {1} ≠ {2}", testData.A, testData.B, PolygonToString(result));
            }
            else
            {
                Assert.Null(result);
            }

            result = _xorOperation.Xor(testData.B, testData.A) as Polygon2;
            if (null != testData.R)
            {
                Assert.NotNull(result);
                testData.R.SpatiallyEqual(result).Should().BeTrue("Reverse case failed: {0} ∩ {1} ≠ {2}", testData.B, testData.A, PolygonToString(result));
            }
            else
            {
                Assert.Null(result);
            }
        }
 public PolyPairTestData(PolyPairTestData data, Polygon2 result) {
     Name = data.Name;
     A = new Polygon2(data.A);
     B = new Polygon2(data.B);
     R = null == result ? data.R : new Polygon2(result);
     CrossingPoints = (data.CrossingPoints ?? Enumerable.Empty<Point2>()).ToList();
 }
Beispiel #3
0
        public static void polygon_intersection_point_crossings(PolyPairTestData testData)
        {
            if (testData.Name == "Fuzzed: 3")
            {
                return; // NOTE: we must test this one a different way
            }
            Console.WriteLine(testData.Name);

            var result = _intersectionOperation.FindPointCrossings(testData.A, testData.B);

            Assert.NotNull(result);
            Console.WriteLine("{0} crossing points", result.Count);

            PolyOperationTestUtility.AssertEqual(
                testData.CrossingPoints.OrderBy(p => p),
                result.Select(r => r.Point).OrderBy(p => p),
                (x, y) => Assert.True(PointsAlmostEqual(x, y), "Points not equal."));

            result = _intersectionOperation.FindPointCrossings(testData.B, testData.A);
            Assert.NotNull(result);

            PolyOperationTestUtility.AssertEqual(
                testData.CrossingPoints.OrderBy(p => p),
                result.Select(r => r.Point).OrderBy(p => p),
                (x, y) => Assert.True(PointsAlmostEqual(x, y), "Points not equal."));
        }
        public static void polygon_intersection(PolyPairTestData testData) {
            Console.WriteLine(testData.Name);

            if (testData.Name == "Fuzzed: 3") {
                Console.WriteLine("Skipping " + testData.Name + " ...need to test this one another way.");
                return;
            }

            var result = _intersectionOperation.Intersect(testData.A, testData.B) as Polygon2;
            if (null != testData.R) {
                Assert.NotNull(result);
                testData.R.SpatiallyEqual(result).Should().BeTrue("Forward case failed: {0} ∩ {1} ≠ {2}", testData.A, testData.B, PolygonToString(result));
            }
            else {
                Assert.Null(result);
            }

            result = _intersectionOperation.Intersect(testData.B, testData.A) as Polygon2;
            if (null != testData.R) {
                Assert.NotNull(result);
                if (testData.Name == "Chess 4 (2 Fills and 2 Holes)")
                    Assert.Equal(testData.R.GetArea(), result.GetArea()); // TODO: pinch self intersecting polygons
                else if (testData.Name == "Chess 9 (5 Fills and 4 Holes)")
                    Assert.Equal(testData.R.GetArea(), result.GetArea()); // TODO: pinch self intersecting polygons
                else
                    testData.R.SpatiallyEqual(result).Should().BeTrue("Reverse case failed: {0} ∩ {1} ≠ {2}", testData.B, testData.A, PolygonToString(result));
            }
            else {
                Assert.Null(result);
            }
        }
        public static void polygon_xor(PolyPairTestData testData) {
            Console.WriteLine(testData.Name);

            if (testData.Name == "Fuzzed: 3") {
                Console.WriteLine("Skipping " + testData.Name + " ...need to test this one another way.");
                return;
            }

            var result = _xorOperation.Xor(testData.A, testData.B) as Polygon2;
            if (null != testData.R) {
                Assert.NotNull(result);
                testData.R.SpatiallyEqual(result).Should().BeTrue("Forward case failed: {0} ∩ {1} ≠ {2}", testData.A, testData.B, PolygonToString(result));
            }
            else {
                Assert.Null(result);
            }

            result = _xorOperation.Xor(testData.B, testData.A) as Polygon2;
            if (null != testData.R) {
                Assert.NotNull(result);
                testData.R.SpatiallyEqual(result).Should().BeTrue("Reverse case failed: {0} ∩ {1} ≠ {2}", testData.B, testData.A, PolygonToString(result));
            }
            else {
                Assert.Null(result);
            }
        }
Beispiel #6
0
        public static void polygon_union(PolyPairTestData testData)
        {
            Console.WriteLine(testData.Name);

            if (testData.Name == "Nested: hole within a fill, not touching")
            {
                return; // infinite spaaaaaaaace
            }

            var result = _unionOperation.Union(testData.A, testData.B) as Polygon2;

            if (null != testData.R)
            {
                Assert.NotNull(result);
                testData.R.SpatiallyEqual(result).Should().BeTrue("Forward case failed: {0} u {1} ≠ {2}", testData.A, testData.B, PolygonToString(result));
            }
            else
            {
                Assert.Null(result);
            }

            result = _unionOperation.Union(testData.B, testData.A) as Polygon2;
            if (null != testData.R)
            {
                Assert.NotNull(result);
                testData.R.SpatiallyEqual(result).Should().BeTrue("Reverse case failed: {0} u {1} ≠ {2}", testData.B, testData.A, PolygonToString(result));
            }
            else
            {
                Assert.Null(result);
            }
        }
        public static void polygon_union(PolyPairTestData testData) {
            Console.WriteLine(testData.Name);

            if (testData.Name == "Nested: hole within a fill, not touching") {
                return; // infinite spaaaaaaaace
            }

            var result = _unionOperation.Union(testData.A, testData.B) as Polygon2;
            if (null != testData.R) {
                Assert.NotNull(result);
                testData.R.SpatiallyEqual(result).Should().BeTrue("Forward case failed: {0} u {1} ≠ {2}", testData.A, testData.B, PolygonToString(result));
            }
            else {
                Assert.Null(result);
            }

            result = _unionOperation.Union(testData.B, testData.A) as Polygon2;
            if (null != testData.R) {
                Assert.NotNull(result);
                testData.R.SpatiallyEqual(result).Should().BeTrue("Reverse case failed: {0} u {1} ≠ {2}", testData.B, testData.A, PolygonToString(result));
            }
            else {
                Assert.Null(result);
            }
        }
 public PolyPairTestData(PolyPairTestData data, Polygon2 result)
 {
     Name           = data.Name;
     A              = new Polygon2(data.A);
     B              = new Polygon2(data.B);
     R              = null == result ? data.R : new Polygon2(result);
     CrossingPoints = (data.CrossingPoints ?? Enumerable.Empty <Point2>()).ToList();
 }
        public static void polygon_difference(PolyPairTestData testData) {
            Console.WriteLine(testData.Name);

            var result = _differenceOperation.Difference(testData.A, testData.B) as Polygon2;
            if (null != testData.R) {
                Assert.NotNull(result);
                testData.R.SpatiallyEqual(result).Should().BeTrue("Failed: {0} - {1} ≠ {2}", testData.A, testData.B, PolygonToString(result));
            }
            else {
                Assert.Null(result);
            }
        }
        public static void polygon_intersection_reverse_winding(PolyPairTestData testData)
        {
            Console.WriteLine(testData.Name);

            var a = ReverseWinding(testData.A);
            var b = ReverseWinding(testData.B);
            var r = ReverseWinding(testData.R);

            if (testData.Name == "Fuzzed: 3")
            {
                Console.WriteLine("Skipping " + testData.Name + " ...need to test this one another way.");
                return;
            }

            var result = _intersectionOperation.Intersect(a, b) as Polygon2;

            if (null != r)
            {
                Assert.NotNull(result);
                r.SpatiallyEqual(result).Should().BeTrue("Forward case failed: {0} ∩ {1} ≠ {2}", a, b, PolygonToString(result));
            }
            else
            {
                Assert.Null(result);
            }

            result = _intersectionOperation.Intersect(b, a) as Polygon2;
            if (null != r)
            {
                Assert.NotNull(result);

                if (testData.Name == "Chess 4 (2 Fills and 2 Holes)")
                {
                    Assert.Equal(r.GetArea(), result.GetArea()); // TODO: pinch self intersecting polygons
                }
                else if (testData.Name == "Chess 9 (5 Fills and 4 Holes)")
                {
                    Assert.Equal(r.GetArea(), result.GetArea()); // TODO: pinch self intersecting polygons
                }
                else
                {
                    r.SpatiallyEqual(result).Should().BeTrue("Reverse case failed: {0} ∩ {1} ≠ {2}", b, a, PolygonToString(result));
                }
            }
            else
            {
                Assert.Null(result);
            }
        }
        public static void polygon_difference(PolyPairTestData testData)
        {
            Console.WriteLine(testData.Name);

            var result = _differenceOperation.Difference(testData.A, testData.B) as Polygon2;

            if (null != testData.R)
            {
                Assert.NotNull(result);
                testData.R.SpatiallyEqual(result).Should().BeTrue("Failed: {0} - {1} ≠ {2}", testData.A, testData.B, PolygonToString(result));
            }
            else
            {
                Assert.Null(result);
            }
        }
        public static void polygon_intersection_point_crossings(PolyPairTestData testData) {
            if (testData.Name == "Fuzzed: 3")
                return; // NOTE: we must test this one a different way

            Console.WriteLine(testData.Name);

            var result = _intersectionOperation.FindPointCrossings(testData.A, testData.B);

            Assert.NotNull(result);
            Console.WriteLine("{0} crossing points", result.Count);

            PolyOperationTestUtility.AssertEqual(
                testData.CrossingPoints.OrderBy(p => p),
                result.Select(r => r.Point).OrderBy(p => p),
                (x, y) => Assert.True(PointsAlmostEqual(x, y), "Points not equal."));

            result = _intersectionOperation.FindPointCrossings(testData.B, testData.A);
            Assert.NotNull(result);

            PolyOperationTestUtility.AssertEqual(
                testData.CrossingPoints.OrderBy(p => p),
                result.Select(r => r.Point).OrderBy(p => p),
                (x, y) => Assert.True(PointsAlmostEqual(x, y), "Points not equal."));
        }