public void should_get_distance_of_the_route_A_E_D() { var service = new DistanceRouteService(GraphInput); var result = service.GetRouteDistance(new List <string>() { "A", "E", "D" }); Assert.AreEqual("The distance of the route A-E-D", result.Pregunta); Assert.AreEqual("NO SUCH ROUTE", result.Salida); }
public void should_get_distance_of_the_route_A_B_C() { var service = new DistanceRouteService(GraphInput); var result = service.GetRouteDistance(new List <string>() { "A", "B", "C" }); Assert.AreEqual("The distance of the route A-B-C", 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)); }