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); }
/// <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); }
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 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 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 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 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 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 ForecastApiAsyncTimer(double interval, ForecastApi forecastApi) { if (forecastApi == null) { throw new ArgumentNullException("forecastApi"); } _api = forecastApi; _timer = new Timer(interval); _timer.Elapsed += _timer_Elapsed; }
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 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); }
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; }
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 ForecastApiAsyncTimer(Timer timer, ForecastApi forecastApi) { if (timer == null) { throw new ArgumentNullException("timer"); } if (forecastApi == null) { throw new ArgumentNullException("forecastApi"); } _api = forecastApi; _timer = timer; _timer.Elapsed += _timer_Elapsed; }
public static List <ForecastHourly> GetHourlyWeatherOverPeriod(SimpleTime start, SimpleTime end, double lat, double lng) { LocalDateTime begin = new LocalDateTime(start.Year, start.Month, start.Day, 0, 0); LocalDateTime stop = new LocalDateTime(end.Year, end.Month, end.Day, 0, 0); Period period = Period.Between(begin, stop, PeriodUnits.Days); List <ForecastHourly> hourlyData = new List <ForecastHourly>(); for (int i = 0; i <= period.Days; i++) { LocalDateTime localtime = begin.PlusDays(i); string timezone = "America/Toronto"; DateTimeZone tz = DateTimeZoneProviders.Tzdb[timezone]; ZonedDateTime zt = tz.AtLeniently(localtime); var tz_offset = zt.ToDateTimeOffset(); Task.Run(async() => { var client = new ForecastApi(API_KEY); Forecast result = await client.GetTimeMachineWeatherAsync(lat, lng, tz_offset); var hourly = result.Hourly.Hours; for (int h = 0; h < hourly.Count(); h++) { ForecastHourly store_hourly = new ForecastHourly(); store_hourly.ApparentTemperature = hourly[h].ApparentTemperature; store_hourly.CloudCover = hourly[h].CloudCover; store_hourly.DewPoint = hourly[h].DewPoint; store_hourly.Humidity = hourly[h].Humidity; store_hourly.Icon = hourly[h].Icon; store_hourly.Ozone = hourly[h].Ozone; store_hourly.PrecipitationIntensity = hourly[h].PrecipitationIntensity; store_hourly.PrecipitationProbability = hourly[h].PrecipitationProbability; store_hourly.Pressure = hourly[h].Pressure; store_hourly.Summary = hourly[h].Summary; store_hourly.Temperature = hourly[h].Temperature; store_hourly.Time = hourly[h].Time; //Instant instant = Instant.FromDateTimeUtc(hourly[h].Time.UtcDateTime); //don't need this, already defined above store_hourly.LocalTime = zt.LocalDateTime; store_hourly.Visibility = hourly[h].Visibility; store_hourly.WindBearing = hourly[h].WindBearing; store_hourly.WindSpeed = hourly[h].WindSpeed; hourlyData.Add(store_hourly); } }).Wait(); } return(hourlyData); }
public static Func <Coordinates, IEnumerable <ICurrentConditions> > GetCurrentConditions(Action <Exception> notifyOnError, string openWeatherMapKey, string wunderGroundKey) { var httpClient = new HttpClient(); string HttpGet(Uri uri) => httpClient.GetStringAsync(uri).Result; var forecastApi = new ForecastApi( notifyOnError, Aggregate.Average, ForecastSource.OpenWeatherMap.Factory.GetCurrentConditions(openWeatherMapKey, HttpGet), ForecastSource.WunderGround.Factory.GetCurrentConditions(wunderGroundKey, HttpGet)); return(coordinates => forecastApi.GetCurrentConditions(coordinates)); }
static void Main(string[] args) { var data = WeatherStation.GetWeatherStation(); var data2 = WeatherStation.GetWeatherStation(); var forecastApi = new ForecastApi(new PercentageDisplay()); var forecastPlatform = new ForecastPlatform(new HeatIndexDisplay()); var forecastApi2 = new ForecastApi(new NormalDisplay()); data.Register(forecastApi); data.Register(forecastPlatform); data.Register(forecastApi2); data.SetMeasurements(1.2f, 1.5f, 10f); data.SetMeasurements(25f, 12f, 19f); //SingletonTest data2.SetMeasurements(213f, 21f, 61f); }
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); } }
public GetIntersightForecastInstance() { ApiInstance = new ForecastApi(Config); MethodName = "GetForecastInstanceListWithHttpInfo"; }
public WeatherForecast() { Client = new ForecastApi("800ff5cacaa097384f4cadb734d9cb6e"); }
public void EmptyKeyThrowsException() { var client = new ForecastApi(string.Empty); Assert.That(async() => await client.GetWeatherDataAsync(AlcatrazLatitude, AlcatrazLongitude), Throws.InvalidOperationException); }
public SetIntersightForecastInstance() { ApiInstance = new ForecastApi(Config); ModelObject = new ForecastInstance(); MethodName = "UpdateForecastInstanceWithHttpInfo"; }