Exemplo n.º 1
0
        public async Task AllGood_ValueNotNull()
        {
            int timesTried = 0;

            SetUpWithSettings(new WeatherClientSettings("testApi"), () =>

            {
                timesTried++;
                var response     = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
                response.Content = new StringContent(MockHttpClient.GetLondonCurrentWeather(),
                                                     Encoding.UTF8, "application/json");
                return(Task.FromResult(response));
            });

            var weather = await client.GetByName("London");

            Assert.IsNotNull(weather);
            Assert.AreEqual("London", weather.Name);
            Assert.AreEqual(1, timesTried);
        }
Exemplo n.º 2
0
        public void SetUpWithSettings(WeatherClientSettings settings, Func <Task <HttpResponseMessage> > mockResponseMessage)
        {
            var httpclient = MockHttpClient.GetMockClient(mockResponseMessage);

            client = new CurrentWeatherClient(httpclient, settings);
        }