コード例 #1
0
        public void GetDistanceOfShortestRouteBtoB()
        {
            var railRoadManager = new RailRoadManager();

            var routeData = new TestData();

            var command = new RouteCalculateCommand
            {
                StartPoint = routeData.GetPointByName("B"),

                EndPoint = routeData.GetPointByName("B"),

                ForceLoopingCount = 0,

                Route = routeData.GetTestRailRoad()
            };

            var allRoads = railRoadManager.GetRoutes(command);

            var shortesRoute = railRoadManager.GetShortestRoute(allRoads);

            var distance = railRoadManager.GetRouteDistance(shortesRoute);

            Assert.AreEqual(21, distance);
        }
コード例 #2
0
        public void TestDistanceRouteAebcd()
        {
            var railRoadManager = new RailRoadManager();

            var routeData = new TestData();

            var routeAbc = new Route(new List <PathNode> {
                routeData.GetPathNodeByPoints("AE"), routeData.GetPathNodeByPoints("EB"), routeData.GetPathNodeByPoints("BC")
            });

            var distance = railRoadManager.GetRouteDistance(routeAbc);

            Assert.AreEqual(14, distance);
        }