public void ReturnCorrectPath_OnEmptyDungeon() { var textMap = new[] { "P ", "CE" }; var map = Map.FromLines(textMap); var path = DungeonTask.FindShortestPath(map); Assert.AreEqual(new[] { MoveDirection.Down, MoveDirection.Right }, path); }
public void ReturnEmptyPath_WhenNoPathToExit() { var textMap = new[] { "P#", "#E" }; var map = Map.FromLines(textMap); var path = DungeonTask.FindShortestPath(map); Assert.AreEqual(new MoveDirection[0], path); }
public void ReturnPathToExit_IfNoChests() { var textMap = new[] { "PE", " " }; var map = Map.FromLines(textMap); var path = DungeonTask.FindShortestPath(map); Assert.AreEqual(new[] { MoveDirection.Right }, path); }
public void ReturnCorrectPaths_OnEmptyDungeon() { var textMap = new[] { "P ", "C " }; var map = Map.FromLines(textMap); var expectedLengths = new[] { 2 }; var paths = GetPaths(map); AssertPaths(paths, map, expectedLengths); }
public void ReturnNoPaths_WhenNoPathsToChests() { var textMap = new[] { "P ", "##", "C " }; var map = Map.FromLines(textMap); var paths = GetPaths(map); Assert.IsEmpty(paths); }
public void Return_ShortestPath2() { var textMap = new[] { "ECC", " P ", "CCC" }; var map = Map.FromLines(textMap); var path = DungeonTask.FindShortestPath(map); Assert.AreEqual(new[] { MoveDirection.Up, MoveDirection.Left }, path); }
public void ReturnPathToExit_IfChestIsUnreachable() { var textMap = new[] { "PE#", "###", "C " }; var map = Map.FromLines(textMap); var path = DungeonTask.FindShortestPath(map); Assert.AreEqual(new[] { MoveDirection.Right }, path); }
public void ReturnCorrectPath_OnSimpleDungeon() { var textMap = new[] { "P #", "#C#", "E " }; var map = Map.FromLines(textMap); var path = My_DungeonTask.FindShortestPath(map); Assert.AreEqual(new[] { MoveDirection.Right, MoveDirection.Down, MoveDirection.Down, MoveDirection.Left }, path); }
public void Return_ShortestPaths2() { var textMap = new[] { " C ", "CPC", " C " }; var map = Map.FromLines(textMap); var expectedLengths = new[] { 2, 2, 2, 2 }; var paths = GetPaths(map); AssertPaths(paths, map, expectedLengths); }
public void Return_ShortestPaths1() { var textMap = new[] { " ", " P ", " C " }; var map = Map.FromLines(textMap); var expectedLengths = new[] { 2 }; var paths = GetPaths(map); AreValidPaths(paths, map, expectedLengths); }
public void ReturnCorrectPaths_OnSimpleDungeon() { var textMap = new[] { "P #", "# #", "C " }; var map = Map.FromLines(textMap); var expectedLengths = new[] { 5 }; var paths = GetPaths(map); AreValidPaths(paths, map, expectedLengths); }
public void Return_ShortestPaths3() { var textMap = new[] { "CC", "CP", }; var map = Map.FromLines(textMap); var expectedLengths = new[] { 3, 2, 2 }; var paths = GetPaths(map) .OrderByDescending(x => x.Count) .ToArray(); AssertPaths(paths, map, expectedLengths); }
public void WorksCorrect_ShortestPaths_OnManyCalls() { var miniMap = Map.FromLines(new[] { " C ", "CPC", " C " }); var miniPaths = GetPaths(miniMap); AssertPaths(miniPaths, miniMap, new[] { 2, 2, 2, 2 }); var map = Map.FromText(Properties.Resources.BigTestDungeon); var paths = GetPaths(map) .OrderByDescending(x => x.Count) .ToArray(); AssertPaths(paths, map, new[] { 170, 156, 144, 137, 84 }); }