Esempio n. 1
0
        static void Main(string[] args)
        {
            int distance = GetDistanceFromUserInput();

            Console.WriteLine("Fetching data, please wait...");

            var url = ConfigurationManager.AppSettings.Get("StarWarsApiUrl");

            using (var apiClient = new ApiClient(url))
            {
                //var apiClient = new ApiClient(url);
                var deserializer = new ApiResponseDeserializer();
                var mapper       = new StarShipMap();

                var service = new StarShipService(apiClient, deserializer, mapper);

                var result = Task.Run(() => service.GetNumberOfStopsForStarShips(distance)).Result;

                foreach (var item in result.OrderBy(x => x.ShipName))
                {
                    //Console.WriteLine("Ship name: {0} Number of stops: {1}", item.ShipName, item.NumberOfStopsRequired);
                    Console.WriteLine("{0}: {1}", item.ShipName, item.NumberOfStopsRequired);
                }

                Console.ReadKey();
            }
        }
Esempio n. 2
0
 public WhenRequestingNumberOfStopsForAllStarShips()
 {
     this.deserializer = new ApiResponseDeserializer();
     this.mapper       = new StarShipMap();
     this.service      = new StarShipService(this.ApiClient, deserializer, mapper);
 }
 public StarShipService(ApiClient apiClient, ApiResponseDeserializer apiResponseDeserializer, StarShipMap mapper)
 {
     this.apiClient            = apiClient;
     this.responseDeserializer = apiResponseDeserializer;
     this.mapper = mapper;
 }
 public void TestInit()
 {
     this.mapper = new StarShipMap();
 }