Exemple #1
0
        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);
        }
Exemple #2
0
 public WeatherForecastController(ILogger <WeatherForecastController> logger,
                                  IWeatherAggregateService weatherAggregateService,
                                  IMetaWeatherService metaWeatherservice)
 {
     _logger = logger;
     _weatherAggregateService = weatherAggregateService;
     _metaWeatherService      = metaWeatherservice;
 }
Exemple #3
0
        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;
 }
Exemple #5
0
 public WeatherAggregateService(IMetaWeatherService metaWeatherService)
 {
     _metaWeatherService = metaWeatherService;
 }
Exemple #6
0
 public ApiProxy(IMetaWeatherService metaWeatherService)
 {
     _metaWeatherService = metaWeatherService;
 }
Exemple #7
0
 public SearchLocationUseCase(IMetaWeatherService weatherService, IMapper mapper)
 {
     this.weatherService = weatherService;
     this.mapper         = mapper;
 }