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

            var blockers = new[] { new Position(2, 2), new Position(3, 2), new Position(4, 2) }.ToList();
            IList <Position> result = creator.GetRasterLinePermissive(start.x, start.y, end.x, end.y, position => !blockers.Contains(position), -1);

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

            var blockers = new[] { new Position(1, 2) }.ToList();
            IList <Position> result = creator.GetRasterLinePermissive(start.x, start.y, end.x, end.y, position => !blockers.Contains(position), -1);

            result.Should().BeEquivalentTo(new[] { new Position(1, 1), new Position(1, 2) },
                                           options => options.WithStrictOrdering());
        }
Beispiel #3
0
        public void Permissive_WallCanBeAvoidedBySecondaryChoices_ReturnsCorrectFullLine()
        {
            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.GetRasterLinePermissive(start.x, start.y, end.x, end.y, position => position != blocker, -1);

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