private void CreateIataGeoFakeClient() { var handler = new Mock <HttpMessageHandler>(); FakeHttpClient = handler.CreateClient(); handler.SetupAnyRequest() .ReturnsResponse(HttpStatusCode.NotFound); handler.SetupRequest("http://iatageo.com/getLatLng/AYT") .Returns(async(HttpRequestMessage request, CancellationToken _) => new HttpResponseMessage() { Content = new StringContent(JsonSerializer.Serialize(new AirportResponse { Latitude = "36.898701", Longitude = "30.800501", Code = "AYT", Name = "Antalya International Airport" })) }); handler.SetupRequest("http://iatageo.com/getLatLng/IST") .Returns(async(HttpRequestMessage request, CancellationToken _) => new HttpResponseMessage() { Content = new StringContent(JsonSerializer.Serialize(new AirportResponse { Latitude = "40.9768981934", Longitude = "28.8145999908", Code = "IST", Name = "Atatürk International Airport" })) }); FakeIataGeoClient = new IataGeoClient(Options.Create(new IataGeoOptions() { BaseUrl = "http://iatageo.com" }), FakeHttpClient); }
public AirportDistanceService(IIataGeoClient iataGeoClient) { _iataGeoClient = iataGeoClient; }