コード例 #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();
        }