Beispiel #1
0
        public void FindRoute_FromToHaveSimilarX_ReturnsVerticalRoute()
        {
            // arrange
            var service = new PathfindingService();

            var map = new[, ]
            {
                { 0, 0 },
                { 0, 0 },
                { 0, 0 },
                { 0, 0 },
                { 0, 0 }
            };

            // act
            var route = service.FindRoute(new Vector2Int(0, 0), new Vector2Int(3, 0), new MapMock(map));

            // assert
            CollectionAssert.AreEquivalent(new[]
            {
                new Vector2Int(0, 0),
                new Vector2Int(1, 0),
                new Vector2Int(2, 0),
                new Vector2Int(3, 0)
            },
                                           route);
        }
Beispiel #2
0
        public void FindRoute_DeadEndBetweenFromAndTo_ReturnsRouteWithShortcutToDeadEndExit()
        {
            // arrange
            var service = new PathfindingService();

            var map = new[, ]
            {
                { 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 1, 0, 0 },
                { 0, 0, 0, 1, 0, 0 },
                { 0, 1, 1, 1, 0, 0 },
                { 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0 },
            };

            // act
            var route = service.FindRoute(new Vector2Int(0, 0), new Vector2Int(4, 4), new MapMock(map));

            // assert
            CollectionAssert.AreEquivalent(new[]
            {
                new Vector2Int(0, 0),
                new Vector2Int(0, 1),
                new Vector2Int(0, 2),
                new Vector2Int(0, 3),
                new Vector2Int(0, 4),
                new Vector2Int(1, 4),
                new Vector2Int(2, 4),
                new Vector2Int(3, 4),
                new Vector2Int(4, 4),
            },
                                           route);
        }
Beispiel #3
0
        public void FindRoute_FromToHaveOppositeXY_ReturnsDiagonalWithStepsRoute()
        {
            // arrange
            var service = new PathfindingService();

            var map = new[, ]
            {
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
            };

            // act
            var route = service.FindRoute(new Vector2Int(0, 0), new Vector2Int(3, 3), new MapMock(map));

            // assert
            CollectionAssert.AreEquivalent(new[]
            {
                new Vector2Int(0, 0),
                new Vector2Int(0, 1),
                new Vector2Int(0, 2),
                new Vector2Int(1, 2),
                new Vector2Int(2, 2),
                new Vector2Int(2, 3),
                new Vector2Int(3, 3)
            },
                                           route);
        }
Beispiel #4
0
        public void FindRoute_FromToAreTheSame_ReturnsOneStep()
        {
            // arrange
            var service = new PathfindingService();

            var map = new[, ]
            {
                { 0, 0 },
                { 0, 0 }
            };

            // act
            var route = service.FindRoute(new Vector2Int(0, 0), new Vector2Int(0, 0), new MapMock(map));

            // assert
            CollectionAssert.AreEquivalent(new[] { new Vector2Int(0, 0) }, route);
        }
Beispiel #5
0
        public void FindRoute_FromToHas1CellDistance_ReturnsTwoSteps()
        {
            // arrange
            var service = new PathfindingService();

            var map = new[, ]
            {
                { 0, 0 },
                { 0, 0 }
            };

            // act
            var route = service.FindRoute(new Vector2Int(0, 0), new Vector2Int(0, 1), new MapMock(map));

            // assert
            CollectionAssert.AreEquivalent(new[]
            {
                new Vector2Int(0, 0),
                new Vector2Int(0, 1)
            },
                                           route);
        }