Exemple #1
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);
        }
 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);
 }
Exemple #3
0
        public async void UnitSIWorksCorrectly()
        {
            var client = new ForecastApi(this.apiKey);

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

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Currently, Is.Not.Null);
        }
Exemple #4
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);
        }
Exemple #5
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);
        }
Exemple #6
0
 public void EmptyKeyThrowsException()
 {
     var client = new ForecastApi(string.Empty);
     Assert.That(async () => await client.GetWeatherDataAsync(AlcatrazLatitude, AlcatrazLongitude), Throws.InvalidOperationException);
 }
Exemple #7
0
        public async void TimeMachineUnitsCanBeSpecified()
        {
            var client = new ForecastApi(this.apiKey);
            var date = DateTime.Now.Subtract(new TimeSpan(2, 0, 0, 0));

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

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Flags.Units, Is.EqualTo(Unit.CA.ToValue()));
        }
Exemple #8
0
        public async void TimeMachineWorksWithPeriodDecimalSeperator()
        {
            var client = new ForecastApi(this.apiKey);
            var date = DateTime.Now.Subtract(new TimeSpan(2, 0, 0, 0));

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

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Currently, Is.Not.Null);
        }
Exemple #9
0
        public async void TimeMachineExclusionWorksCorrectly()
        {
            var client = new ForecastApi(this.apiKey);
            var date = DateTime.Now.Subtract(new TimeSpan(2, 0, 0, 0));
            var exclusionList = new List<Exclude> { Exclude.Hourly };

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

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Currently, Is.Not.Null);
            Assert.That(result.Hourly, Is.Null);
        }
Exemple #10
0
        public async void CanRetrieveForThePast()
        {
            var client = new ForecastApi(this.apiKey);
            var date = DateTime.Now.Subtract(new TimeSpan(2, 0, 0, 0));

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

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Currently, Is.Not.Null);
        }
Exemple #11
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()));
        }
Exemple #12
0
        public async void MultipleExclusionWorksCorrectly()
        {
            var client = new ForecastApi(this.apiKey);
            var exclusionList = new List<Exclude> { Exclude.Minutely, Exclude.Hourly, Exclude.Daily };

            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);
            Assert.That(result.Hourly, Is.Null);
            Assert.That(result.Daily, Is.Null);
        }
        public async void SetWeather()
        {
            DebugBox.Text += "Setting Weather...\n";
            var client = new ForecastApi(AccountInformation.getForecastAPI());
            if (client == null)
            {
                DebugBox.Text += "ERROR: NULL client returned in SetWeather()";
                return;
            }
            var result = await client.GetWeatherDataAsync(AccountInformation.getLatitude(), AccountInformation.getLongitude());

            if (result == null || result.Currently == null)
            {
                this.WeatherBox.Text = "ERROR: NULL returned";
                return;
            }
            string toWrite = "";
            toWrite += "Current Temperature: " + result.Currently.Temperature + " °F\n";
            toWrite += "Feels Like: " + result.Currently.ApparentTemperature + " °F\n";
            toWrite += "Probability for Percipitation: " + result.Currently.PrecipitationProbability + " %\n";
            toWrite += "Current Wind Speed: " + result.Currently.WindSpeed + " mph\n";
            //toWrite += "Current Wind Bearing: " + result.Currently.WindBearing + " \n"; // Erased for space
            toWrite += "Current Visibility: " + result.Currently.Visibility + " miles\n";
            toWrite += "\n" + result.Hourly.Summary + "\n";


            if (!WeatherBox.Text.Equals(toWrite))
                WeatherBox.Text = toWrite;

            setWeatherIcon(result.Currently.Icon);

            if (result.Alerts != null)
            {
                WeatherIcon.Source = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/weatherAlert.jpg"));
                WeatherAlertBox.IsEnabled = true;
            }
            else if (WeatherAlertBox.IsEnabled)
                WeatherAlertBox.IsEnabled = false;
        }