Esempio n. 1
0
        public void GetShortestPath_NoMonster_PathIsShortest()
        {
            MazeFactory factory = new MazeFactory(Mock.Of <IPonyAPIClient>());
            Maze        maze    = factory.FromJson(mazeJson);

            maze.Domokun.Position = new Point(-1, -1);
            solver = new MazePathfinder();


            Path path = solver.Solve(maze);

            Path expectedPath = new Path {
                Source = maze.Pony.Position, Destination = maze.EndPoint
            };

            expectedPath.Steps = new List <Point>
            {
                new Point(4, 4),
                new Point(4, 3),
                new Point(4, 2),
                new Point(5, 2),
                new Point(6, 2),
                new Point(6, 1),
                new Point(5, 1),
                new Point(4, 1),
                new Point(4, 0),
                new Point(3, 0),
                new Point(3, 1),
            };

            Assert.AreEqual(maze.MazeId, path.MazeId);
            Assert.AreEqual(expectedPath.Steps, path.Steps.Take(11));
            Assert.AreEqual(81, path.Length);
            Assert.AreEqual(maze.Pony.Position, path.Source);
            Assert.AreEqual(maze.EndPoint, path.Destination);
            Assert.AreEqual(maze.EndPoint, path.Steps.Last());
        }