Esempio n. 1
0
        public void should_get_max_number_of_trips_C_to_C()
        {
            var service = new NumberOfTripsService(GraphInput);

            var result = service.GetMaxNumberOfTrips("C", "C", 3);

            Assert.AreEqual("The number of trips starting at C and ending at C with maximum of 3 stops. In the sample data below, there are two such trips: C-D-C (2 stops). and C-E-B-C (3 stops)", result.Pregunta);
            Assert.AreEqual("2", result.Salida);
        }
Esempio n. 2
0
        public void should_get_exactly_number_of_trips_A_to_C()
        {
            var service = new NumberOfTripsService(GraphInput);

            var result = service.GetExactlyNumberOfTrips("A", "C", 4);

            Assert.AreEqual("The number of trips starting at A and ending at C with exactly 4 stops. In the sample data below, there are three such trips: A to C (via B,C,D); A to C (via D,C,D); and A to C (via D,E,B).", result.Pregunta);
            Assert.AreEqual("3", result.Salida);
        }
Esempio n. 3
0
        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));
        }