Exemple #1
0
        public void Rectangles_OverlappingArea_ShouldReturnCorrect(double x1, double y1, double w1, double h1, double x2, double y2, double w2, double h2, double expected)
        {
            var rectangle1 = new Rectangle(x1, y1, w1, h1);
            var rectangle2 = new Rectangle(x2, y2, w2, h2);
            var opreation  = new UnrotatedRectangleOperation();

            var result = opreation.OverlappingArea(rectangle1, rectangle2);

            result.Should().Be(expected);
        }
Exemple #2
0
        public void Rectangles_ManhattanDistance_ShouldReturnCorrect(double x1, double y1, double w1, double h1, double x2, double y2, double w2, double h2, double expected)
        {
            var rectangle1 = new Rectangle(x1, y1, w1, h1);
            var rectangle2 = new Rectangle(x2, y2, w2, h2);
            var opreation  = new UnrotatedRectangleOperation();

            var result = opreation.ManhattanDistanceOfCenters(rectangle1, rectangle2);

            result.Should().Be(expected);
        }
Exemple #3
0
        public void IntersectedRectangles_DoOverlap_ShouldReturnTrue(double x1, double y1, double w1, double h1, double x2, double y2, double w2, double h2)
        {
            var rectangle1   = new Rectangle(x1, y1, w1, h1);
            var rectangle2   = new Rectangle(x2, y2, w2, h2);
            var intersection = new UnrotatedRectangleOperation();

            var result = intersection.DoOverlap(rectangle1, rectangle2);

            result.Should().BeTrue();
        }
Exemple #4
0
        public void DisjunctRectangles_WithIntersectedMargins_DoOverlap_ShouldReturnTrue(double x1, double y1, double w1, double h1, double x2, double y2, double w2, double h2)
        {
            var rectangle1 = new Rectangle(x1, y1, w1, h1);

            rectangle1.MarginWidth = 1;
            var rectangle2 = new Rectangle(x2, y2, w2, h2);

            rectangle2.MarginWidth = 1;
            var intersection = new UnrotatedRectangleOperation();

            var result = intersection.DoOverlapWithMargin(rectangle1, rectangle2);

            result.Should().BeTrue();
        }