public void TryFindPathAvoiding_NoPathExists_ReturnsNull() { string mapRepresentation = @"############################################### #..........#......................##..........# #..........#..........##..........##..........# #..........#..........##..........##..........# #..........#..........##..........##..........# #.....................##......................# ###############################################"; IMapCreationStrategy <Map> mapCreationStrategy = new StringDeserializeMapCreationStrategy <Map>(mapRepresentation); IMap map = Map.Create(mapCreationStrategy); GoalMap goalMap = new GoalMap(map); goalMap.AddGoal(2, 2, 0); goalMap.AddObstacle(2, 1); goalMap.AddObstacle(1, 1); Path path = goalMap.TryFindPathAvoidingGoals(1, 1); Assert.AreEqual(null, path); }
public void TryFindPathAvoiding_BoxedInCornerWithObstacle_ExpectedPath() { string mapRepresentation = @"############################################### #..........#......................##..........# #..........#..........##..........##..........# #..........#..........##..........##..........# #..........#..........##..........##..........# #.....................##......................# ###############################################"; IMapCreationStrategy <Map> mapCreationStrategy = new StringDeserializeMapCreationStrategy <Map>(mapRepresentation); IMap map = Map.Create(mapCreationStrategy); GoalMap goalMap = new GoalMap(map); goalMap.AddGoal(2, 2, 0); goalMap.AddObstacle(2, 1); Path path = goalMap.TryFindPathAvoidingGoals(1, 1); Assert.AreEqual(61, path.Length); Assert.AreEqual(map.GetCell(1, 2), path.StepForward()); Assert.AreEqual(map.GetCell(1, 1), path.Start); Assert.AreEqual(map.GetCell(45, 1), path.End); }