コード例 #1
0
        public void MapDarkSkyToWeather_returns_Weather()
        {
            DarkSkyResult result = _service.GetDarkSkyResult(MockHelpers.GetDarkSkyJson());

            WeatherViewModel weather = _service.MapDarkSkyToWeather(result);

            Assert.Equal("yyy", weather.FeelsLike);
        }
コード例 #2
0
        /// <inheritdoc />
        public async Task <WeatherViewModel> GetWeatherAsync()
        {
            DarkSkyResult       result   = null;
            HttpResponseMessage response = await client.GetAsync(_apiUri);

            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync();

                result = GetDarkSkyResult(content);
            }

            //
            return(MapDarkSkyToWeather(result));
        }
コード例 #3
0
        /// <inheritdoc />
        public WeatherViewModel MapDarkSkyToWeather(DarkSkyResult darkSky)
        {
            var currentTime = darkSky.Currently.Time.InTimeZone(darkSky.Timezone);

            var weather = new WeatherViewModel
            {
                ConditionsLabel = darkSky.Currently.Icon,
                ConditionsDesc  = darkSky.Currently.Summary,
                DayOrNight      = darkSky.Currently.Time.DayOrNight(darkSky.Daily.Data[0].SunsetTime),
                CurrentDate     = currentTime.ToString("ddd, MMM d"),
                CurrentTime     = currentTime.ToString("t"),
                FeelsLike       = "(" + Math.Round(darkSky.Currently.ApparentTemperature).ToString() + ")",
                Temperature     = Math.Round(darkSky.Currently.Temperature).ToString()
            };

            //
            return(weather);
        }
コード例 #4
0
        public void DarkSkyService_returns_DarkSkyResult()
        {
            DarkSkyResult result = _service.GetDarkSkyResult(MockHelpers.GetDarkSkyJson());

            Assert.Equal("America/Chicago", result.Timezone);
        }
コード例 #5
0
 /// <inheritdoc />
 public WeatherViewModel MapDarkSkyToWeather(DarkSkyResult darkSky)
 {
     throw new NotImplementedException("MockDarkSkyApiService.MapDarkSkyToWeather NOT IMPLEMENTED");
 }