Exemple #1
0
        public async Task Run_GridGraphAndLinePath_PathFound()
        {
            // ARRAGE
            var map = await CreateGridOpenMapAsync().ConfigureAwait(false);

            var expectedPath = new IGraphNode[]
            {
                map.Nodes.SelectByHexCoords(1, 1),
                map.Nodes.SelectByHexCoords(2, 2),
                map.Nodes.SelectByHexCoords(2, 3),
                map.Nodes.SelectByHexCoords(3, 4),
                map.Nodes.SelectByHexCoords(3, 5),
                map.Nodes.SelectByHexCoords(4, 6)
            };

            var context = CreatePathFindingContext(map);

            var astar = new AStar(context, expectedPath.First(), expectedPath.Last());

            // ACT
            var factState = astar.Run();

            // ASSERT

            factState.Should().Be(State.GoalFound);

            var factPath = astar.GetPath();

            factPath.Should().BeEquivalentTo(expectedPath);
        }