public void Background() { _mockHttpMessageHandler = new MockHttpMessageHandler(); var locationBuilder = new TestLocationResponseBuilder(); var weatherBuilder = new TestWeatherResponseBuilder(); _mockHttpMessageHandler.When(STR_Search) .WithQueryString("query", "Belfast") .Respond(() => locationBuilder.Default().WithBelfast().BuildHttpResponse()); _mockHttpMessageHandler.When(STR_Search) .WithQueryString("query", "Birmingham") .Respond(() => locationBuilder.Default().WithBirmingham().BuildHttpResponse()); _mockHttpMessageHandler.When(STR_44544) .Respond(() => weatherBuilder.Default().WithBelfast().BuildHttpResponse()); _mockHttpMessageHandler.When(STR_12723) .Respond(() => weatherBuilder.Default().WithBirmingham().BuildHttpResponse()); _mockHttpMessageHandler.Fallback .Respond( req => new HttpResponseMessage(HttpStatusCode.NotFound) { ReasonPhrase = $"No matching mock handler found for \"{req.Method.ToString().ToUpperInvariant()} {req.RequestUri.AbsoluteUri}\"" }); var settings = new RefitSettings { HttpMessageHandlerFactory = () => _mockHttpMessageHandler }; _metaWeatherService = RestService.For <IMetaWeatherService>("https://www.metaweather.com", settings); }
public WeatherForecastController(ILogger <WeatherForecastController> logger, IWeatherAggregateService weatherAggregateService, IMetaWeatherService metaWeatherservice) { _logger = logger; _weatherAggregateService = weatherAggregateService; _metaWeatherService = metaWeatherservice; }
public void Background() { _mockHttpMessageHandler = new MockHttpMessageHandler(); var builder = new TestLocationResponseBuilder(); _mockHttpMessageHandler.When("https://www.metaweather.com/api/location/search") .WithQueryString("query", "Belfast") .Respond(() => builder.Default().WithBelfast().BuildHttpResponse()); _mockHttpMessageHandler.When("https://www.metaweather.com/api/location/search") .WithQueryString("query", "Birmingham") .Respond(() => builder.Default().WithBirmingham().BuildHttpResponse()); var settings = new RefitSettings { HttpMessageHandlerFactory = () => _mockHttpMessageHandler }; _metaWeatherService = RestService.For <IMetaWeatherService>("https://www.metaweather.com", settings); }
public GetWeatherByLocationIdUseCase(IMetaWeatherService weatherService, IMapper mapper) { this.weatherService = weatherService; this.mapper = mapper; }
public WeatherAggregateService(IMetaWeatherService metaWeatherService) { _metaWeatherService = metaWeatherService; }
public ApiProxy(IMetaWeatherService metaWeatherService) { _metaWeatherService = metaWeatherService; }
public SearchLocationUseCase(IMetaWeatherService weatherService, IMapper mapper) { this.weatherService = weatherService; this.mapper = mapper; }