Example #1
0
        public void WeatherProviderWrongCoordinatesTest()
        {
            var weatherProvider = WeatherProviderFactory.GetWeatherProvider();

            // Use wrong coordinates
            weatherProvider.GetCurrentWeather("559.89", "330.26");
        }
Example #2
0
        public void WeatherProviderCheckStatusTest()
        {
            var weatherProvider = WeatherProviderFactory.GetWeatherProvider();
            // Use coordinates of Saint-Petersburg
            var weatherInfo = weatherProvider.GetCurrentWeather("59.89", "30.26");

            Assert.IsFalse(string.IsNullOrEmpty(weatherInfo.Status), "Weather info contains empty status");
        }
Example #3
0
        public ActionResult GetCurrentWeather(string latitude, string longitude)
        {
            try
            {
                var weatherProvider = WeatherProviderFactory.GetWeatherProvider();
                var weatherInfo     = weatherProvider.GetCurrentWeather(latitude, longitude);

                return(PartialView("_WeatherView", new WeatherModel(weatherInfo)));
            }
            catch (Exception ex)
            {
                _logger.Error("Error to get current weather action", ex);
                throw new WebException("Failed to get current weather", ex);
            }
        }