Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        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 });
        }