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); }
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); }
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); }
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); }
public void EmptyKeyThrowsException() { var client = new ForecastApi(string.Empty); Assert.That(async () => await client.GetWeatherDataAsync(AlcatrazLatitude, AlcatrazLongitude), Throws.InvalidOperationException); }
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())); }
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); }
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); }
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); }
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())); }
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; }