public void CalculateStops()
        {
            string responseJson = "[{\"name\":\"Executor\",\"model\":\"Executor-class star dreadnought\",\"manufacturer\":\"Kuat Drive Yards, Fondor Shipyards\",\"cost_in_credits\":\"1143350000\",\"length\":\"19000\",\"max_atmosphering_speed\":\"n/a\",\"crew\":\"279144\",\"passengers\":\"38000\",\"cargo_capacity\":\"250000000\",\"consumables\":\"6 years\",\"hyperdrive_rating\":\"2.0\",\"MGLT\":\"40\",\"starship_class\":\"Star dreadnought\",\"pilots\":[],\"films\":[\"https://swapi.co/api/films/2/\",\"https://swapi.co/api/films/3/\"],\"created\":\"2014-12-15T12:31:42.547000Z\",\"edited\":\"2017-04-19T10:56:06.685592Z\",\"url\":\"https://swapi.co/api/starships/15/\"}]";
            var    ships        = JsonSerializer.Deserialize <Startship[]>(responseJson, SerializerOptions);
            var    results      = TripCalculator.CalculateTripStops(ships, 100000);

            Assert.NotNull(results);
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of <see cref="FakeWebRequest"/>
        /// with the response to return.
        /// </summary>
        public async void Run()
        {
            //Instantiate the Api Wrapper for the desired Entity
            var helper = new WebHelper <Startship>(_logger);

            //Request all the Starships
            var ships = await helper.GetAll();

            //Print UI Welcome
            PrintWelcome();

            //ask User to input the distance
            var distance = PrintInputDistance();

            //do the math
            var stops = TripCalculator.CalculateTripStops(ships.ToArray(), distance);

            //Print the data in a formated table
            PrintStopsTable(stops);

            //print thank you and good bye
            PrintThankYouGoodBye();
        }