public void FutureWeather() { WeatherInput input = new WeatherInput(); input.query = "Bangalore"; input.num_of_days = "7"; IGetWetherInfo weather = new WeatherRequestWWO(input); WeatherData data = weather.GetInformation(); bool success = false; if (DataStore.Instance().m_start != null && DataStore.Instance().m_end != null) { Node temp = DataStore.Instance().m_start; int count = 1; while (temp != null) { temp = temp.next; count++; } if (count >= 7) { success = true; } } NUnit.Framework.Assert.True(success); }
public async Task<Root> GetWeatherData(WeatherInput weatherInput) { var result = new Root(); result = await _weather.GetWeatherdata(weatherInput); return result; }
public async Task <Root> GetWeatherdata(WeatherInput objInput) { string apiId = Environment.GetEnvironmentVariable("ApiId"); string apiURL = $"https://api.openweathermap.org/data/2.5/weather?q={objInput.data.CityName}&appid={apiId}"; var result = await httpClient.GetFromJsonAsync <Root>(apiURL); return(result); }
public async Task<Root> Get(WeatherInput weatherInput) { var result = new Root(); //string apiKey = config.GetValue<string>("GlobalKeyValue:ApiKey"); //if (weatherInput.APIKey == apiKey) //{ result = await _weather.GetWeatherdata(weatherInput); //} return result; }
public void AddLeft() { WeatherInput input = new WeatherInput(); input.query = "Bangalore"; input.num_of_days = "7"; IGetWetherInfo weather = new WeatherRequestWWO(input); WeatherData data = weather.GetInformation(); Node current = DataStore.Instance().m_start; WeatherInput past = null; past = new WeatherInput(); past.query = input.query; DateTime startdate = DateTime.Now; startdate = startdate.AddDays(-5); string date_s = startdate.ToString("yyyy-MM-dd"); past.date = date_s; DateTime enddate = DateTime.Now; enddate = enddate.AddDays(-1); string enddate_s = enddate.ToString("yyyy-MM-dd"); past.enddate = enddate_s; IGetWetherInfo weather2 = new WeatherRequestWWO(input, past, RefreshType.AddLeft); WeatherData data2 = weather2.GetInformation(); bool success = false; if (DataStore.Instance().m_start != null && DataStore.Instance().m_start.IsValid) { Node temp = DataStore.Instance().m_start; int count = 1; bool added5 = false; while (temp != null) { temp = temp.next; if (count == 5 && temp == current) { added5 = true; } count++; } if (count == 13 && added5) { success = true; } } NUnit.Framework.Assert.True(success); }
private void button1_Click(object sender, EventArgs e) { if (comboBox1.Text.Length == 0) { return; } m_currentloc = comboBox1.Text; today = DateTime.Now; DisableButtons(); input.query = m_currentloc; input.num_of_days = numericUpDown2.Value.ToString(); WeatherInput past = null; int days = (int)numericUpDown1.Value; if (days > 0) { past = new WeatherInput(); past.query = m_currentloc; DateTime startdate = DateTime.Now; startdate = startdate.AddDays(-1 * days); string date_s = startdate.ToString("yyyy-MM-dd"); past.date = date_s; DateTime enddate = DateTime.Now; enddate = enddate.AddDays(-1); string enddate_s = enddate.ToString("yyyy-MM-dd"); past.enddate = enddate_s; } //create a command and push to queue Command cmd = new Command(); cmd.SetInput(input, past); cmd.SetCallback(updateui); CommandQueue.Instance().add(cmd); SetButtonNames(); }
public void FalseInput_Negative() { WeatherInput input = new WeatherInput(); input.query = "..."; input.num_of_days = "-1"; IGetWetherInfo weather = new WeatherRequestZOWA(input); WeatherData data = weather.GetInformation(); if (DataStore.Instance().m_start != null) { NUnit.Framework.Assert.True(true); } else { NUnit.Framework.Assert.True(false); } }
public void TodaysWeather() { WeatherInput input = new WeatherInput(); input.query = "Bangalore"; input.num_of_days = "1"; IGetWetherInfo weather = new WeatherRequestWWO(input); WeatherData data = weather.GetInformation(); if (DataStore.Instance().m_start != null) { NUnit.Framework.Assert.True(true); } else { NUnit.Framework.Assert.True(false); } }
private void button2_Click(object sender, EventArgs e) { m_currentloc = comboBox1.Text; today = today.AddDays(-1); DisableButtons(); if (DataStore.Instance().m_start == DataStore.Instance().m_left) { //fetch new data input.query = m_currentloc; input.num_of_days = "1"; WeatherInput past = null; past = new WeatherInput(); past.query = m_currentloc; DateTime startdate = DataStore.Instance().m_start.datetime; startdate = startdate.AddDays(-5); string date_s = startdate.ToString("yyyy-MM-dd"); past.date = date_s; DateTime enddate = DataStore.Instance().m_start.datetime; enddate = enddate.AddDays(-1); string enddate_s = enddate.ToString("yyyy-MM-dd"); past.enddate = enddate_s; Command cmd = new Command(); cmd.SetInput(input, past, RefreshType.AddLeft); cmd.SetCallback(updateui); CommandQueue.Instance().add(cmd); } else { DataStore.Instance().moveleft(); //Uncomment following line if you want to change todays weather when you click left button //DataStore.Instance().m_today = DataStore.Instance().m_today.prev; updateui(null); } SetButtonNames(); }
public void PastWeather() { WeatherInput input = new WeatherInput(); input.query = "Bangalore"; input.num_of_days = "7"; WeatherInput past = null; past = new WeatherInput(); past.query = input.query; DateTime startdate = DateTime.Now; startdate = startdate.AddDays(-5); string date_s = startdate.ToString("yyyy-MM-dd"); past.date = date_s; DateTime enddate = DateTime.Now; enddate = enddate.AddDays(-1); string enddate_s = enddate.ToString("yyyy-MM-dd"); past.enddate = enddate_s; IGetWetherInfo weather = new WeatherRequestWWO(input, past); WeatherData data = weather.GetInformation(); bool success = false; if (DataStore.Instance().m_start != null && DataStore.Instance().m_start.IsValid) { string firstdate = DataStore.Instance().m_start.datetime.ToString("yyyy-MM-dd"); if (firstdate == date_s) { success = true; } } NUnit.Framework.Assert.True(success); }