예제 #1
0
        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);
        }
예제 #2
0
        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();
        }
예제 #3
0
        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();
        }
예제 #4
0
        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();
        }