Ejemplo n.º 1
0
        public void GetForecastTest()
        {
            IWeatherDataService service = WeatherDataServiceFactory.GetWeatherDataService(
                WeatherDataServiceFactory.WeatherDataKind.OPEN_WEATHER_MAP);

            Location location = new Location("Hod Hasharon", "IL");

            List <WeatherData> forecast = null;

            try
            {
                forecast = service.GetForecast(location);
            }
            catch (WeatherDataServiceException)
            {
                Assert.Fail();
            }

            Assert.IsTrue(forecast.Count > 10);
        }
        static void Main(string[] args)
        {
            IWeatherDataService service = WeatherDataServiceFactory.GetWeatherDataService(
                WeatherDataServiceFactory.WeatherDataKind.OPEN_WEATHER_MAP);

            try
            {
                WeatherData weatherData = service.GetWeatherData(new Location("Hod Hasharon", "IL"));

                Console.WriteLine(weatherData);

                List <WeatherData> forecast = service.GetForecast(new Location("Hod Hasharon", "IL"));

                foreach (var t in forecast)
                {
                    Console.WriteLine(t);
                }
            }
            catch (WeatherDataServiceException e)
            {
                Console.WriteLine(e.Message + "\n" + e.StackTrace);
            }
        }