public void BentleyOttmannAlgorithmIntersectionTest()
        {
            // single line, no intersection
            IReadOnlyList <Coordinate> intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new Coordinate(10, 10),
                new Coordinate(20, 20)
            });

            intersections.ShouldBeEmpty();

            // single line string, one intersection
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new Coordinate(10, 10),
                new Coordinate(20, 20),
                new Coordinate(15, 20),
                new Coordinate(15, 10)
            });

            intersections.ShouldBe(new[] { new Coordinate(15, 15) });

            // multiple lines, no intersection
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new[]
                {
                    new Coordinate(10, 10),
                    new Coordinate(20, 20)
                },
                new[]
                {
                    new Coordinate(0, 0),
                    new Coordinate(10, 0)
                }
            });

            intersections.ShouldBeEmpty();

            // multiple lines, one intersection
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new[]
                {
                    new Coordinate(10, 10),
                    new Coordinate(20, 20)
                },
                new[]
                {
                    new Coordinate(0, 0),
                    new Coordinate(10, 10)
                }
            });

            intersections.ShouldBe(new[] { new Coordinate(10, 10) });

            // multiple lines, one intersection
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new[]
                {
                    new Coordinate(10, 10),
                    new Coordinate(20, 20)
                },
                new[]
                {
                    new Coordinate(15, 20),
                    new Coordinate(15, 10)
                }
            });

            intersections.ShouldBe(new[] { new Coordinate(15, 15) });

            // multiple lines, multiple intersections
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new[]
                {
                    new Coordinate(-10, 0),
                    new Coordinate(10, 0)
                },
                new[]
                {
                    new Coordinate(-10, -10),
                    new Coordinate(10, 10)
                },
                new[]
                {
                    new Coordinate(3, 5),
                    new Coordinate(10, 5)
                },
                new[]
                {
                    new Coordinate(4, 8),
                    new Coordinate(10, 8)
                }
            });

            intersections.ShouldBe(new[]
            {
                new Coordinate(0, 0),
                new Coordinate(5, 5),
                new Coordinate(8, 8),
            });

            // multiple lines, multiple intersections
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new[]
                {
                    new Coordinate(-5, 0),
                    new Coordinate(5, 0)
                },
                new[]
                {
                    new Coordinate(0, -2),
                    new Coordinate(8, 2)
                },
                new[]
                {
                    new Coordinate(1, -3),
                    new Coordinate(3, 3)
                }
            });

            intersections.Count.ShouldBe(3);
            intersections[0].X.ShouldBe(1.6, 0.0001);
            intersections[0].Y.ShouldBe(-1.2, 0.0001);
            intersections[1].X.ShouldBe(2, 0.0001);
            intersections[1].Y.ShouldBe(0, 0.0001);
            intersections[2].X.ShouldBe(4, 0.0001);
            intersections[2].Y.ShouldBe(0, 0.0001);

            // multiple lines, multiple intersections in the same coordinate
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new[]
                {
                    new Coordinate(-5, 0),
                    new Coordinate(5, 0)
                },
                new[]
                {
                    new Coordinate(0, 5),
                    new Coordinate(5, 0)
                },
                new[]
                {
                    new Coordinate(4, -1),
                    new Coordinate(5, 0)
                }
            });

            intersections.ShouldBe(new[]
            {
                new Coordinate(5, 0),
                new Coordinate(5, 0),
                new Coordinate(5, 0),
            });

            // multiple lines, multiple intersections in the same coordinate
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new[]
                {
                    new Coordinate(10, 0),
                    new Coordinate(10, 10),
                    new Coordinate(0, 10)
                },
                new[]
                {
                    new Coordinate(10, 20),
                    new Coordinate(10, 10),
                    new Coordinate(20, 10)
                }
            });

            intersections.ShouldBe(new[]
            {
                new Coordinate(10, 10),
                new Coordinate(10, 10),
                new Coordinate(10, 10),
                new Coordinate(10, 10),
            });

            // multiple lines, multiple intersections (even in the same coordinate)
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new[]
                {
                    new Coordinate(0, 0),
                    new Coordinate(10, 0),
                    new Coordinate(10, 10),
                    new Coordinate(0, 10),
                },
                new[]
                {
                    new Coordinate(20, 0),
                    new Coordinate(10, 0),
                    new Coordinate(10, 10),
                    new Coordinate(20, 10),
                }
            });

            intersections.ShouldBe(new[]
            {
                new Coordinate(10, 0),
                new Coordinate(10, 0),
                new Coordinate(10, 0),
                new Coordinate(10, 0),
                new Coordinate(10, 10),
                new Coordinate(10, 10),
                new Coordinate(10, 10),
                new Coordinate(10, 10),
            });

            // single polygon, no intersection
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new Coordinate(0, 0),
                new Coordinate(10, 0),
                new Coordinate(10, 10),
                new Coordinate(0, 10),
                new Coordinate(0, 0)
            });

            intersections.ShouldBeEmpty();

            // single polygon, multiple intersections
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new Coordinate(-1, 1),
                new Coordinate(1, -1),
                new Coordinate(11, -1),
                new Coordinate(13, 1),
                new Coordinate(13, 6),
                new Coordinate(11, 8),
                new Coordinate(8, 8),
                new Coordinate(6, 6),
                new Coordinate(7, 3),
                new Coordinate(9, 1),
                new Coordinate(11, 3),
                new Coordinate(9, 5),
                new Coordinate(3, 5),
                new Coordinate(1, 3),
                new Coordinate(3, 1),
                new Coordinate(5, 3),
                new Coordinate(6, 6),
                new Coordinate(4, 8),
                new Coordinate(1, 8),
                new Coordinate(-1, 6),
                new Coordinate(-1, 1)
            });

            intersections.Select(this.RoundCoordinate).ShouldBe(new[]
            {
                new Coordinate(5.66667, 5),
                new Coordinate(6, 6),
                new Coordinate(6, 6),
                new Coordinate(6, 6),
                new Coordinate(6, 6),
                new Coordinate(6.33333, 5)
            });

            // multiple polygons, no intersection
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new[]
                {
                    new Coordinate(0, 0),
                    new Coordinate(10, 0),
                    new Coordinate(10, 10),
                    new Coordinate(0, 10),
                    new Coordinate(0, 0)
                },
                new[]
                {
                    new Coordinate(15, 0),
                    new Coordinate(20, 0),
                    new Coordinate(20, 5),
                    new Coordinate(15, 5),
                    new Coordinate(15, 0)
                }
            });

            intersections.ShouldBeEmpty();

            // multiple polygons, multiple intersections in the same coordinate
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new[]
                {
                    new Coordinate(0, 0),
                    new Coordinate(10, 0),
                    new Coordinate(10, 10),
                    new Coordinate(0, 10),
                    new Coordinate(0, 0)
                },
                new[]
                {
                    new Coordinate(10, 10),
                    new Coordinate(20, 10),
                    new Coordinate(20, 20),
                    new Coordinate(10, 20),
                    new Coordinate(10, 10)
                }
            });

            intersections.ShouldBe(new[]
            {
                new Coordinate(10, 10),
                new Coordinate(10, 10),
                new Coordinate(10, 10),
                new Coordinate(10, 10),
            });

            // multiple polygons, multiple intersections
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new[]
                {
                    new Coordinate(0, 0),
                    new Coordinate(10, 0),
                    new Coordinate(10, 10),
                    new Coordinate(0, 10),
                    new Coordinate(0, 0)
                },
                new[]
                {
                    new Coordinate(5, 5),
                    new Coordinate(15, 5),
                    new Coordinate(15, 15),
                    new Coordinate(5, 15),
                    new Coordinate(5, 5)
                }
            });

            intersections.ShouldBe(new[]
            {
                new Coordinate(5, 10),
                new Coordinate(10, 5),
            });

            // multiple polygons, multiple intersections
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new[]
                {
                    new Coordinate(0, 0),
                    new Coordinate(10, 0),
                    new Coordinate(10, 10),
                    new Coordinate(0, 10),
                    new Coordinate(0, 0)
                },
                new[]
                {
                    new Coordinate(-10, -5),
                    new Coordinate(10, -5),
                    new Coordinate(0, 5),
                    new Coordinate(-10, -5)
                }
            });

            intersections.ShouldBe(new[]
            {
                new Coordinate(0, 5),
                new Coordinate(0, 5),
                new Coordinate(5, 0),
            });

            // multiple polygons, multiple intersections (even in the same coordinate)

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new[]
                {
                    new Coordinate(0, 0),
                    new Coordinate(8, 0),
                    new Coordinate(8, 8),
                    new Coordinate(0, 8),
                    new Coordinate(0, 0)
                },
                new[]
                {
                    new Coordinate(8, 0),
                    new Coordinate(14, 0),
                    new Coordinate(14, 8),
                    new Coordinate(8, 8),
                    new Coordinate(8, 0)
                }
            });

            intersections.ShouldBe(new[]
            {
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
            });

            // the previous scenario with one less coordinate
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new[]
                {
                    new Coordinate(0, 0),
                    new Coordinate(8, 0),
                    new Coordinate(8, 8),
                    new Coordinate(0, 8),
                    new Coordinate(0, 0)
                },
                new[]
                {
                    new Coordinate(8, 0),
                    new Coordinate(14, 0),
                    new Coordinate(8, 8),
                    new Coordinate(8, 0)
                }
            });

            intersections.ShouldBe(new[]
            {
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
            });

            // the previous scenario with an additional polygon
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new[]
                {
                    new Coordinate(0, 0),
                    new Coordinate(8, 0),
                    new Coordinate(8, 8),
                    new Coordinate(0, 8),
                    new Coordinate(0, 0)
                },
                new[]
                {
                    new Coordinate(8, 0),
                    new Coordinate(14, 0),
                    new Coordinate(8, 8),
                    new Coordinate(8, 0)
                },
                new[]
                {
                    new Coordinate(-2, 6),
                    new Coordinate(14, 6),
                    new Coordinate(4, 14),
                    new Coordinate(-2, 6)
                }
            });

            intersections.ShouldBe(new[]
            {
                new Coordinate(0, 6),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 6),
                new Coordinate(8, 6),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(9.5, 6),
            });

            // the previous scenario with additional polygons
            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new[]
                {
                    new Coordinate(0, 0),
                    new Coordinate(8, 0),
                    new Coordinate(8, 8),
                    new Coordinate(0, 8),
                    new Coordinate(0, 0)
                },
                new[]
                {
                    new Coordinate(8, 0),
                    new Coordinate(14, 0),
                    new Coordinate(8, 8),
                    new Coordinate(8, 0)
                },
                new[]
                {
                    new Coordinate(-4, -6),
                    new Coordinate(4, -6),
                    new Coordinate(4, 2),
                    new Coordinate(-4, 2),
                    new Coordinate(-4, -6)
                },
                new[]
                {
                    new Coordinate(-2, 6),
                    new Coordinate(14, 6),
                    new Coordinate(4, 14),
                    new Coordinate(-2, 6)
                },
                new[]
                {
                    new Coordinate(2, 1),
                    new Coordinate(6, 1),
                    new Coordinate(6, 13),
                    new Coordinate(2, 13),
                    new Coordinate(2, 1)
                }
            });

            intersections.Select(this.RoundCoordinate).ShouldBe(new[]
            {
                new Coordinate(0, 2),
                new Coordinate(0, 6),
                new Coordinate(2, 2),
                new Coordinate(2, 6),
                new Coordinate(2, 8),
                new Coordinate(2, 11.33333),
                new Coordinate(3.25, 13),
                new Coordinate(4, 0),
                new Coordinate(4, 1),
                new Coordinate(5.25, 13),
                new Coordinate(6, 6),
                new Coordinate(6, 8),
                new Coordinate(6, 12.4),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 6),
                new Coordinate(8, 6),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(9.5, 6),
            });
        }
        public void BentleyOttmannAlgorithmIntersectionTest()
        {
            // single line, no intersection

            IList <Coordinate> intersections = BentleyOttmannAlgorithm.Intersection(new List <Coordinate>
            {
                new Coordinate(10, 10),
                new Coordinate(20, 20)
            });

            Assert.IsEmpty(intersections);


            // single linestring, one intersection

            intersections = BentleyOttmannAlgorithm.Intersection(new List <Coordinate>
            {
                new Coordinate(10, 10),
                new Coordinate(20, 20),
                new Coordinate(15, 20),
                new Coordinate(15, 10)
            });

            Assert.AreEqual(new[] { new Coordinate(15, 15) }, intersections);


            // multiple lines, no intersection

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new List <Coordinate>
                {
                    new Coordinate(10, 10),
                    new Coordinate(20, 20)
                },
                new List <Coordinate>
                {
                    new Coordinate(0, 0),
                    new Coordinate(10, 0)
                }
            });

            Assert.IsEmpty(intersections);


            // multiple lines, one intersection

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new List <Coordinate>
                {
                    new Coordinate(10, 10),
                    new Coordinate(20, 20)
                },
                new List <Coordinate>
                {
                    new Coordinate(0, 0),
                    new Coordinate(10, 10)
                }
            });

            Assert.AreEqual(new[] { new Coordinate(10, 10) }, intersections);


            // multiple lines, one intersection

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new List <Coordinate>
                {
                    new Coordinate(10, 10),
                    new Coordinate(20, 20)
                },
                new List <Coordinate>
                {
                    new Coordinate(15, 20),
                    new Coordinate(15, 10)
                }
            });

            Assert.AreEqual(new[] { new Coordinate(15, 15) }, intersections);


            // multiple lines, multiple intersections

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new List <Coordinate>
                {
                    new Coordinate(-10, 0),
                    new Coordinate(10, 0)
                },
                new List <Coordinate>
                {
                    new Coordinate(-10, -10),
                    new Coordinate(10, 10)
                },
                new List <Coordinate>
                {
                    new Coordinate(3, 5),
                    new Coordinate(10, 5)
                },
                new List <Coordinate>
                {
                    new Coordinate(4, 8),
                    new Coordinate(10, 8)
                }
            });

            Assert.AreEqual(new[]
            {
                new Coordinate(0, 0),
                new Coordinate(5, 5),
                new Coordinate(8, 8),
            }, intersections);


            // multiple lines, multiple intersections

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new List <Coordinate>
                {
                    new Coordinate(-5, 0),
                    new Coordinate(5, 0)
                },
                new List <Coordinate>
                {
                    new Coordinate(0, -2),
                    new Coordinate(8, 2)
                },
                new List <Coordinate>
                {
                    new Coordinate(1, -3),
                    new Coordinate(3, 3)
                }
            });

            Assert.AreEqual(intersections.Count, 3);
            Assert.AreEqual(intersections[0].X, 1.6, 0.0001);
            Assert.AreEqual(intersections[0].Y, -1.2, 0.0001);
            Assert.AreEqual(intersections[1].X, 2, 0.0001);
            Assert.AreEqual(intersections[1].Y, 0, 0.0001);
            Assert.AreEqual(intersections[2].X, 4, 0.0001);
            Assert.AreEqual(intersections[2].Y, 0, 0.0001);


            // multiple lines, multiple intersections in the same coordinate

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new List <Coordinate>
                {
                    new Coordinate(-5, 0),
                    new Coordinate(5, 0)
                },
                new List <Coordinate>
                {
                    new Coordinate(0, 5),
                    new Coordinate(5, 0)
                },
                new List <Coordinate>
                {
                    new Coordinate(4, -1),
                    new Coordinate(5, 0)
                }
            });

            Assert.AreEqual(new[]
            {
                new Coordinate(5, 0),
                new Coordinate(5, 0),
                new Coordinate(5, 0),
            }, intersections);


            // multiple lines, multiple intersections in the same coordinate

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new List <Coordinate>
                {
                    new Coordinate(10, 0),
                    new Coordinate(10, 10),
                    new Coordinate(0, 10)
                },
                new List <Coordinate>
                {
                    new Coordinate(10, 20),
                    new Coordinate(10, 10),
                    new Coordinate(20, 10)
                }
            });

            Assert.AreEqual(new[]
            {
                new Coordinate(10, 10),
                new Coordinate(10, 10),
                new Coordinate(10, 10),
                new Coordinate(10, 10),
            }, intersections);


            // multiple lines, multiple intersections (even in the same coordinate)

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                new List <Coordinate>
                {
                    new Coordinate(0, 0),
                    new Coordinate(10, 0),
                    new Coordinate(10, 10),
                    new Coordinate(0, 10),
                },
                new List <Coordinate>
                {
                    new Coordinate(20, 0),
                    new Coordinate(10, 0),
                    new Coordinate(10, 10),
                    new Coordinate(20, 10),
                }
            });

            Assert.AreEqual(new[]
            {
                new Coordinate(10, 0),
                new Coordinate(10, 0),
                new Coordinate(10, 0),
                new Coordinate(10, 0),
                new Coordinate(10, 10),
                new Coordinate(10, 10),
                new Coordinate(10, 10),
                new Coordinate(10, 10),
            }, intersections);


            // single polygon, no intersection

            intersections = BentleyOttmannAlgorithm.Intersection(
                _factory.CreatePolygon(
                    _factory.CreatePoint(0, 0),
                    _factory.CreatePoint(10, 0),
                    _factory.CreatePoint(10, 10),
                    _factory.CreatePoint(0, 10))
                .Shell.Coordinates);

            Assert.IsEmpty(intersections);


            // single polygon, multiple intersections

            intersections = BentleyOttmannAlgorithm.Intersection(new List <Coordinate>
            {
                new Coordinate(-1, 1),
                new Coordinate(1, -1),
                new Coordinate(11, -1),
                new Coordinate(13, 1),
                new Coordinate(13, 6),
                new Coordinate(11, 8),
                new Coordinate(8, 8),
                new Coordinate(6, 6),
                new Coordinate(7, 3),
                new Coordinate(9, 1),
                new Coordinate(11, 3),
                new Coordinate(9, 5),
                new Coordinate(3, 5),
                new Coordinate(1, 3),
                new Coordinate(3, 1),
                new Coordinate(5, 3),
                new Coordinate(6, 6),
                new Coordinate(4, 8),
                new Coordinate(1, 8),
                new Coordinate(-1, 6),
                new Coordinate(-1, 1)
            });

            Assert.AreEqual(new[]
            {
                new Coordinate(5.66667, 5),
                new Coordinate(6, 6),
                new Coordinate(6, 6),
                new Coordinate(6, 6),
                new Coordinate(6, 6),
                new Coordinate(6.33333, 5)
            }, intersections.Select(RoundCoordinate));


            // multiple polygons, no intersection

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                _factory.CreatePolygon(
                    _factory.CreatePoint(0, 0),
                    _factory.CreatePoint(10, 0),
                    _factory.CreatePoint(10, 10),
                    _factory.CreatePoint(0, 10))
                .Shell.Coordinates,
                _factory.CreatePolygon(
                    _factory.CreatePoint(15, 0),
                    _factory.CreatePoint(20, 0),
                    _factory.CreatePoint(20, 5),
                    _factory.CreatePoint(15, 5))
                .Shell.Coordinates
            });

            Assert.IsEmpty(intersections);


            // multiple polygons, multiple intersections in the same coordinate

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                _factory.CreatePolygon(
                    _factory.CreatePoint(0, 0),
                    _factory.CreatePoint(10, 0),
                    _factory.CreatePoint(10, 10),
                    _factory.CreatePoint(0, 10))
                .Shell.Coordinates,
                _factory.CreatePolygon(
                    _factory.CreatePoint(10, 10),
                    _factory.CreatePoint(20, 10),
                    _factory.CreatePoint(20, 20),
                    _factory.CreatePoint(10, 20))
                .Shell.Coordinates
            });

            Assert.AreEqual(new[]
            {
                new Coordinate(10, 10),
                new Coordinate(10, 10),
                new Coordinate(10, 10),
                new Coordinate(10, 10),
            }, intersections);


            // multiple polygons, multiple intersections

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                _factory.CreatePolygon(
                    _factory.CreatePoint(0, 0),
                    _factory.CreatePoint(10, 0),
                    _factory.CreatePoint(10, 10),
                    _factory.CreatePoint(0, 10))
                .Shell.Coordinates,
                _factory.CreatePolygon(
                    _factory.CreatePoint(5, 5),
                    _factory.CreatePoint(15, 5),
                    _factory.CreatePoint(15, 15),
                    _factory.CreatePoint(5, 15))
                .Shell.Coordinates
            });

            Assert.AreEqual(new[]
            {
                new Coordinate(5, 10),
                new Coordinate(10, 5),
            }, intersections);


            // multiple polygons, multiple intersections

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                _factory.CreatePolygon(
                    _factory.CreatePoint(0, 0),
                    _factory.CreatePoint(10, 0),
                    _factory.CreatePoint(10, 10),
                    _factory.CreatePoint(0, 10))
                .Shell.Coordinates,
                _factory.CreatePolygon(
                    _factory.CreatePoint(-10, -5),
                    _factory.CreatePoint(10, -5),
                    _factory.CreatePoint(0, 5))
                .Shell.Coordinates
            });

            Assert.AreEqual(new[]
            {
                new Coordinate(0, 5),
                new Coordinate(0, 5),
                new Coordinate(5, 0),
            }, intersections);


            // multiple polygons, multiple intersections (even in the same coordinate)

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                _factory.CreatePolygon(
                    _factory.CreatePoint(0, 0),
                    _factory.CreatePoint(8, 0),
                    _factory.CreatePoint(8, 8),
                    _factory.CreatePoint(0, 8))
                .Shell.Coordinates,
                _factory.CreatePolygon(
                    _factory.CreatePoint(8, 0),
                    _factory.CreatePoint(14, 0),
                    _factory.CreatePoint(14, 8),
                    _factory.CreatePoint(8, 8))
                .Shell.Coordinates,
            });

            Assert.AreEqual(new[]
            {
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
            }, intersections);


            // the previous scenario with one less coordinate

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                _factory.CreatePolygon(
                    _factory.CreatePoint(0, 0),
                    _factory.CreatePoint(8, 0),
                    _factory.CreatePoint(8, 8),
                    _factory.CreatePoint(0, 8))
                .Shell.Coordinates,
                _factory.CreatePolygon(
                    _factory.CreatePoint(8, 0),
                    _factory.CreatePoint(14, 0),
                    _factory.CreatePoint(8, 8))
                .Shell.Coordinates,
            });

            Assert.AreEqual(new[]
            {
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
            }, intersections);


            // the previous scenario with an additional polygon

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                _factory.CreatePolygon(
                    _factory.CreatePoint(0, 0),
                    _factory.CreatePoint(8, 0),
                    _factory.CreatePoint(8, 8),
                    _factory.CreatePoint(0, 8))
                .Shell.Coordinates,
                _factory.CreatePolygon(
                    _factory.CreatePoint(8, 0),
                    _factory.CreatePoint(14, 0),
                    _factory.CreatePoint(8, 8))
                .Shell.Coordinates,
                _factory.CreatePolygon(
                    _factory.CreatePoint(-2, 6),
                    _factory.CreatePoint(14, 6),
                    _factory.CreatePoint(4, 14))
                .Shell.Coordinates
            });

            Assert.AreEqual(new[]
            {
                new Coordinate(0, 6),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 6),
                new Coordinate(8, 6),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(9.5, 6),
            }, intersections);


            // the previous scenario with additional polygons

            intersections = BentleyOttmannAlgorithm.Intersection(new[]
            {
                _factory.CreatePolygon(
                    _factory.CreatePoint(0, 0),
                    _factory.CreatePoint(8, 0),
                    _factory.CreatePoint(8, 8),
                    _factory.CreatePoint(0, 8))
                .Shell.Coordinates,
                _factory.CreatePolygon(
                    _factory.CreatePoint(8, 0),
                    _factory.CreatePoint(14, 0),
                    _factory.CreatePoint(8, 8))
                .Shell.Coordinates,
                _factory.CreatePolygon(
                    _factory.CreatePoint(-4, -6),
                    _factory.CreatePoint(4, -6),
                    _factory.CreatePoint(4, 2),
                    _factory.CreatePoint(-4, 2))
                .Shell.Coordinates,
                _factory.CreatePolygon(
                    _factory.CreatePoint(-2, 6),
                    _factory.CreatePoint(14, 6),
                    _factory.CreatePoint(4, 14))
                .Shell.Coordinates,
                _factory.CreatePolygon(
                    _factory.CreatePoint(2, 1),
                    _factory.CreatePoint(6, 1),
                    _factory.CreatePoint(6, 13),
                    _factory.CreatePoint(2, 13))
                .Shell.Coordinates
            });

            Assert.AreEqual(new[]
            {
                new Coordinate(0, 2),
                new Coordinate(0, 6),
                new Coordinate(2, 2),
                new Coordinate(2, 6),
                new Coordinate(2, 8),
                new Coordinate(2, 11.33333),
                new Coordinate(3.25, 13),
                new Coordinate(4, 0),
                new Coordinate(4, 1),
                new Coordinate(5.25, 13),
                new Coordinate(6, 6),
                new Coordinate(6, 8),
                new Coordinate(6, 12.4),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 0),
                new Coordinate(8, 6),
                new Coordinate(8, 6),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(8, 8),
                new Coordinate(9.5, 6),
            }, intersections.Select(RoundCoordinate));
        }