示例#1
0
        public async void UnicodeLanguageIsSupported()
        {
            var client = new ForecastApi(this.apiKey);
            var result = await client.GetWeatherDataAsync(AlcatrazLatitude, AlcatrazLongitude, Unit.Auto, Language.Chinese);

            Assert.That(result, Is.Not.Null);
        }
    protected async virtual Task <int> TimerElapsedTask()
    {
        var forecast = await _api.GetWeatherDataAsync(40.7505045d, -73.9934387d);

        int tempC = (int)(5.0 / 9.0 * (forecast.Currently.Temperature - 32));

        return(tempC);
    }
示例#3
0
        public async void NonUSDataCanBeRetrieved()
        {
            var client = new ForecastApi(this.apiKey);

            var result = await client.GetWeatherDataAsync(MumbaiLatitude, MumbaiLongitude);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Currently, Is.Not.Null);
        }
示例#4
0
        public async void ValidKeyRetrievesData()
        {
            var client = new ForecastApi(this.apiKey);

            var result = await client.GetWeatherDataAsync(AlcatrazLatitude, AlcatrazLongitude);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Currently, Is.Not.Null);
        }
示例#5
0
        public async void UnitsCanBeSpecified()
        {
            var client = new ForecastApi(this.apiKey);

            var result = await client.GetWeatherDataAsync(AlcatrazLatitude, AlcatrazLongitude, Unit.CA);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Flags.Units, Is.EqualTo(Unit.CA.ToValue()));
        }
示例#6
0
        /// <summary>
        /// Checks that requests can be made with Unit.UK.
        /// </summary>
        public async void UnitUKWorksCorrectly()
        {
            var client = new ForecastApi(this.apiKey);

            var result = await client.GetWeatherDataAsync(MumbaiLatitude, MumbaiLongitude, Unit.UK);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Currently, Is.Not.Null);
        }
示例#7
0
        public async void WorksWithPeriodDecimalSeperator()
        {
            var client = new ForecastApi(this.apiKey);

            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
            var result = await client.GetWeatherDataAsync(AlcatrazLatitude, AlcatrazLongitude);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Currently, Is.Not.Null);
        }
示例#8
0
        public async void ExclusionWorksCorrectly()
        {
            var client        = new ForecastApi(this.apiKey);
            var exclusionList = new List <Exclude> {
                Exclude.Minutely
            };

            var result = await client.GetWeatherDataAsync(AlcatrazLatitude, AlcatrazLongitude, Unit.US, exclusionList);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Currently, Is.Not.Null);
            Assert.That(result.Minutely, Is.Null);
        }
示例#9
0
        private static async Task GetForcast(dynamic x, double latitude, double longitude)
        {
            //if (ForecastRetrieved < DateTime.Now.AddMinutes(5))
            //{
            //	return;
            //}

            ForecastApi api = new ForecastApi(x.apikey);

            forecast = await api.GetWeatherDataAsync(latitude, longitude);

            ForecastRetrieved = DateTime.Now;
        }
示例#10
0
 public async Task <IList <DayForecast> > GetForecast(double latitude, double longitude, DateTimeOffset?forecastDate = null)
 {
     try
     {
         var      client = new ForecastApi(FORECAST_API_KEY);
         Forecast result;
         if (forecastDate != null)
         {
             result = await client.GetTimeMachineWeatherAsync(latitude, longitude, (DateTimeOffset)forecastDate);
         }
         else
         {
             result = await client.GetWeatherDataAsync(latitude, longitude);
         }
         var days = WeatherFactory.CreateDayForecasts(result);
         return(days);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
         return(null);
     }
 }
示例#11
0
        public void EmptyKeyThrowsException()
        {
            var client = new ForecastApi(string.Empty);

            Assert.That(async() => await client.GetWeatherDataAsync(AlcatrazLatitude, AlcatrazLongitude), Throws.InvalidOperationException);
        }