Esempio n. 1
0
        public void FindPaths_SmallMapWithTwoGoalsOfEqualWeightAndDistance_Finds2PathsWith6Points()
        {
            string mapRepresentation = @"########
                                      #....#.#
                                      #.#..#.#
                                      #.#..#.#
                                      #......#
                                      ########";
            IMapCreationStrategy <Map> mapCreationStrategy = new StringDeserializeMapCreationStrategy <Map>(mapRepresentation);
            IMap map = Map.Create(mapCreationStrategy);

            GoalMap goalMap = new GoalMap(map);

            goalMap.AddGoal(1, 1, 0);
            goalMap.AddGoal(6, 1, 0);
            ReadOnlyCollection <Path> paths = goalMap.FindPaths(3, 4);

            string expectedGoalMapRepresentation = @"#    #    #    #    #    #    #    #
                                                  #    0    1    2    3    #    0    #
                                                  #    1    #    3    4    #    1    #
                                                  #    2    #    4    5    #    2    #
                                                  #    3    4    5    5    4    3    #
                                                  #    #    #    #    #    #    #    #";

            Assert.AreEqual(RemoveWhiteSpace(expectedGoalMapRepresentation), RemoveWhiteSpace(goalMap.ToString()));
            Assert.AreEqual(2, paths.Count);
            Assert.AreEqual(6, paths[0].Length);
            Assert.AreEqual(6, paths[1].Length);
        }