Beispiel #1
0
        public void NoConstraints_ReturnsCorrectFullLine()
        {
            Position start   = new Position(1, 1);
            Position end     = new Position(4, 3);
            var      creator = new BresenhamLineCreator();

            IList <Position> result = creator.GetRasterLine(start.x, start.y, end.x, end.y);

            result.Should().BeEquivalentTo(new[] { new Position(1, 1), new Position(2, 2), new Position(3, 2), new Position(4, 3) },
                                           options => options.WithStrictOrdering());
        }
Beispiel #2
0
        public void LineWithObstacleAndLimitAndLimitIsAfterObstacle_ReturnsLineTerminatedOnObstacle()
        {
            Position start   = new Position(1, 1);
            Position end     = new Position(4, 3);
            var      creator = new BresenhamLineCreator();
            Position blocker = new Position(2, 2);

            IList <Position> result = creator.GetRasterLine(start.x, start.y, end.x, end.y, 500, position => position != blocker, true);

            result.Should().BeEquivalentTo(new[] { new Position(1, 1), new Position(2, 2) },
                                           options => options.WithStrictOrdering());
        }
Beispiel #3
0
        public void LineWithObstacleAndDoesNotAllowFinishOnBlocker_ReturnsLineFinishingBeforeBlocker()
        {
            Position start   = new Position(1, 1);
            Position end     = new Position(4, 3);
            var      creator = new BresenhamLineCreator();
            Position blocker = new Position(2, 2);

            IList <Position> result = creator.GetRasterLine(start.x, start.y, end.x, end.y, position => position != blocker, false);

            result.Should().BeEquivalentTo(new[] { new Position(1, 1) },
                                           options => options.WithStrictOrdering());
        }
Beispiel #4
0
        public void LineWithLimitZero_ReturnsEmptyLine()
        {
            Position start   = new Position(1, 1);
            Position end     = new Position(4, 3);
            var      creator = new BresenhamLineCreator();
            int      limit   = 0;

            IList <Position> result = creator.GetRasterLine(start.x, start.y, end.x, end.y, limit);

            result.Should().BeEquivalentTo(new Position[] {},
                                           options => options.WithStrictOrdering());
        }
Beispiel #5
0
        public void LineWithPositiveLimit_ReturnsLineWithProperLength()
        {
            Position start   = new Position(1, 1);
            Position end     = new Position(4, 3);
            var      creator = new BresenhamLineCreator();
            int      limit   = 3;

            IList <Position> result = creator.GetRasterLine(start.x, start.y, end.x, end.y, limit);

            result.Should().BeEquivalentTo(new[] { new Position(1, 1), new Position(2, 2), new Position(3, 2) },
                                           options => options.WithStrictOrdering());
        }