public void should_get_shortest_route_from_B_to_B() { var trainService = new ShortestRouteService(GraphInput); var result = trainService.GetShortestRoute("B", "B"); Assert.AreEqual("The lenght of the shortest route (in terms of distance to travel) from B to B.", result.Pregunta); Assert.AreEqual("9", result.Salida); }
private static void RunOptionsAndReturnExitCode(Options opts) { var graphInput = System.IO.File.ReadAllText(opts.InputFiles).ToUpper().Replace(" ", string.Empty); RouteResponse response = new RouteResponse(); switch (opts.Question.First()) { case "d": var route = ((string[])opts.Question)[1].ToUpper().Replace(" ", string.Empty).Split(',').ToList(); response = new DistanceRouteService(graphInput).GetRouteDistance(route); break; case "tmax": var trips = ((string[])opts.Question)[1].ToUpper().Replace(" ", string.Empty).Split(',').ToList(); var maxStops = Convert.ToInt16(((string[])opts.Question)[2].ToUpper().Replace(" ", string.Empty)); response = new NumberOfTripsService(graphInput).GetMaxNumberOfTrips(trips[0], trips[1], maxStops); break; case "texact": trips = ((string[])opts.Question)[1].ToUpper().Replace(" ", string.Empty).Split(',').ToList(); var exactStops = Convert.ToInt16(((string[])opts.Question)[2].ToUpper().Replace(" ", string.Empty)); response = new NumberOfTripsService(graphInput).GetExactlyNumberOfTrips(trips[0], trips[1], exactStops); break; case "l": route = ((string[])opts.Question)[1].ToUpper().Replace(" ", string.Empty).Split(',').ToList(); response = new ShortestRouteService(graphInput).GetShortestRoute(route[0], route[1]); break; case "r": route = ((string[])opts.Question)[1].ToUpper().Replace(" ", string.Empty).Split(',').ToList(); maxStops = Convert.ToInt16(((string[])opts.Question)[2].ToUpper().Replace(" ", string.Empty)); response = new NumberOfDiffRoutesService(graphInput).GetNumberDiffRoutes(route[0], route[1], maxStops); break; } Console.WriteLine(string.Format("Pregunta: {0}; Salida: {1}", response.Pregunta, response.Salida)); }