Exemplo n.º 1
0
        static void Main(string[] args)
        {
            DataProvider dataProvider = new DataProvider();
            var KaitaiaAstroData2 = dataProvider.GetDataAsync<WunAstronomy>(PwsGeographicLocation.Kaitaia_Northland_NZ, WunDataFeatures.astronomy);
            var KaitaiaAstroData = dataProvider.GetData<WunAstronomy>(PwsGeographicLocation.Kaitaia_Northland_NZ, WunDataFeatures.astronomy);

            //Console.WriteLine("Sunrise in Kaitaia is: {0}:{1}", KaitaiaAstroData.sun_phase.sunrise.hour, KaitaiaAstroData.sun_phase.sunrise.minute);
            Console.WriteLine("Sunrise in Kaitaia is: {0}:{1}", KaitaiaAstroData2.Result.sun_phase.sunrise.hour, KaitaiaAstroData2.Result.sun_phase.sunrise.minute);

            Console.ReadKey();
        }
Exemplo n.º 2
0
        public void GetDataAsyncTest()
        {
            // Arrange
            DataProvider dataProvider = new DataProvider();
            var forecast = dataProvider.GetDataAsync<WunForecast>(PwsGeographicLocation.Kaitaia_Northland_NZ, WunDataFeatures.forecast);
            string expectedResult = "http://www.wunderground.com/weather/api/d/terms.html";

            // Extra work for performance testing of Async vs Sync
            // IMPORTANT --- To really test this make sure to uncomment the Thread.Sleep(10000)
            // lines in the DownloadJsonString/DownloadJsonStringAsync to simulate a slow internet
            // connection and see how this effects performance.
            int incrementor = int.MinValue;
            for (int i = int.MinValue; i < int.MaxValue; i++)
            {
                incrementor++;
            }

            // Act
            string actualResult = forecast.Result.response.termsofService;

            // Assert
            Assert.AreEqual(expectedResult, actualResult);
        }