Exemplo n.º 1
0
        public static void ClassInitialize(TestContext context)
        {
            // todo centralize initialization of HttpClient so it's not repeated in web project startup
            _httpClient = new HttpClient()
            {
                BaseAddress = new Uri("http://api.weather.gov")
            };
            _httpClient.DefaultRequestHeaders.Clear();
            _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/geo+json"));
            // Have to fake it out so it sees the request as coming from a browser (Chrome latest)
            _httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36");

            _nwsClient = new NationalWeatherServiceClient(new NullLogger <NationalWeatherServiceClient>(), _httpClient);
        }
Exemplo n.º 2
0
 public HomeController(ILogger <HomeController> logger, INationalWeatherServiceClient nwsClient)
 {
     _logger    = logger;
     _nwsClient = nwsClient;
 }