public Result <FiveDaysForecastResult> ObterPrevisao(int idAPI) { try { //consulta a previsao na api ClientConfig.ApiUrl = "http://api.openweathermap.org/data/2.5"; ClientConfig.ApiKey = "a75f4b55aed47dd3b7b65f58a242855f"; var result = FiveDaysForecast.GetByCityId(idAPI); return(result); } catch (Exception) { return(new Result <FiveDaysForecastResult>()); } }
public void GetFiveDaysForecastByCityIdTest() { ClientConfig.ApiUrl = "http://api.openweathermap.org/data/2.5"; ClientConfig.ApiKey = "a75f4b55aed47dd3b7b65f58a242855f"; var result = FiveDaysForecast.GetByCityId(-100); Assert.IsFalse(result.Success); Assert.IsNull(result.Items); result = FiveDaysForecast.GetByCityId(3469968); Assert.IsTrue(result.Success); Assert.IsNotNull(result.Items); Assert.IsTrue(result.Items.Count > 0); Assert.IsNotNull(result.Items[0]); }
public void GetFiveDaysForecastByCityIdTest() { //Does not exist var result = FiveDaysForecast.GetByCityId(-2964574); Assert.IsFalse(result.Success); Assert.IsNull(result.Items); //Exist result = FiveDaysForecast.GetByCityId(2964574); Assert.IsTrue(result.Success); Assert.IsNotNull(result.Items); Assert.IsTrue(result.Items.Count > 0); Assert.IsNotNull(result.Items[0]); result = FiveDaysForecast.GetByCityId(2964574, "de", "metric"); Assert.IsTrue(result.Success); Assert.IsNotNull(result.Items); Assert.IsTrue(result.Items.Count > 0); Assert.IsNotNull(result.Items[0]); }
private static async Task <List <List <FiveDaysForecastResult> > > GetFiveDaysForecastByCityCode(Module module) { return(await FiveDaysForecast.GetByCityId(Convert.ToInt32(module.CityCode), module.Language, "metric")); }