Пример #1
0
        public void GetClosestRectangleThatDoesNotIntersectWithOthers_ShouldReturnClosestPossibleRectangle()
        {
            var possibleLocation = new Point(-5, 5);
            var size             = new Size(3, 2);
            var center           = new Point(0, 0);
            var expectedResult   = new Rectangle(new Point(-3, 0), size);

            var result = RectangleUtils.GetClosestRectangleThatDoesNotIntersectWithOthers(
                possibleLocation, size, center, new List <Rectangle>());

            result.Should().Be(expectedResult);
        }
Пример #2
0
        public void GetClosestRectangleThatDoesNotIntersectWithOthers_ShouldBeNull_WhenAllPossibleRectanglesIntersected()
        {
            var possibleLocation = new Point(0, 1);
            var size             = new Size(3, 2);
            var center           = new Point(0, 0);
            var rectangles       = new List <Rectangle>
            {
                new Rectangle(new Point(0, -1), new Size(7, 1)),
                new Rectangle(new Point(-6, 1), new Size(5, 3)),
                new Rectangle(new Point(-4, -2), new Size(3, 2)),
                new Rectangle(new Point(1, 1), new Size(3, 1))
            };

            var result = RectangleUtils.GetClosestRectangleThatDoesNotIntersectWithOthers(
                possibleLocation, size, center, rectangles);

            result.Should().BeNull();
        }