public async Task ForecastCountShouldBeFour() { HttpMessageHandler handlerMock = MockHttpMessageHandler.CreateMock( new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent( FromEmbedResources.ReadText("ResponseMock.ForecastResponse.json")) }); var httpClient = new HttpClient(handlerMock); IWeatherService weatherService = new WeatherService(httpClient, ""); WeatherViewModel weatherViewModelMock = MockWeatherViewModel.CreateMock(weatherService).Object; await weatherViewModelMock.GetForecastAsync(); weatherViewModelMock.Forecast.Should().HaveCount(5); }
public async Task CurrentWeatherShouldNotBeNull() { HttpMessageHandler handlerMock = MockHttpMessageHandler.CreateMock( new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent( FromEmbedResources.ReadText("ResponseMock.CurrentWeatherResponse.json")) }); var httpClient = new HttpClient(handlerMock); IWeatherService weatherService = new WeatherService(httpClient, ""); WeatherViewModel weatherViewModelMock = MockWeatherViewModel.CreateMock(weatherService).Object; await weatherViewModelMock.GetWeatherAsync(); weatherViewModelMock.CurrentWeather.Should().NotBeNull(); }
public async void FetchCurrentWeatherFromCoordinates() { HttpMessageHandler handlerMock = MockHttpMessageHandler.CreateMock( new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent( FromEmbedResources.ReadText("ResponseMock.CurrentWeatherResponse.json")) }); var httpClient = new HttpClient(handlerMock); var coordinates = new Coordinates { Lat = 51.51f, Lon = -0.13f }; IWeatherService weatherService = new WeatherService(httpClient, ""); WeatherData result = await weatherService.GetCurrentWeatherAsync(coordinates); result.Should().NotBeNull(); }
public async void FetchForecastFromCoordinates_ReturnFiveDaysForecast() { HttpMessageHandler handlerMock = MockHttpMessageHandler.CreateMock( new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent( FromEmbedResources.ReadText("ResponseMock.ForecastResponse.json")) }); var httpClient = new HttpClient(handlerMock); var coordinates = new Coordinates { Lat = 51.51f, Lon = -0.13f }; IWeatherService weatherService = new WeatherService(httpClient, ""); Forecast result = await weatherService.GetWeatherForecastAsync(coordinates); result.Should().NotBeNull(); result.List.Should().NotBeEmpty(); }