/// <summary> /// Get weather forecast for a given geographical point /// </summary> /// <param name="A">Point for the forecast</param> /// <returns>A WeatherAnswer object containing all data</returns> public async Task <WeatherAnswer> GetForecast(Tuple <double, double> A) { //Code for a get request string getdata = string.Format( "http://api.openweathermap.org/data/2.5/forecast?lon={0}&lat={1}&units=metric&appid=1d9fd0f441a4df3321623d653ec72144", A.Item1, A.Item2); //Get result of the request string getresult = await GetAsync(getdata); //Convert JSON string to an object tree WeatherAnswer weatherAnswer = JsonConvert.DeserializeObject <WeatherAnswer>(getresult); return(weatherAnswer); }
public void WeatherAnswerTest() { var packet = new WeatherAnswer { CurrentWeather = WeatherAnswer.Weather.Foggy }; var bytes = packet.GetBytes(); using (var ms = new MemoryStream(bytes)) { using (var bs = new BinaryReaderExt(ms)) { var weather = bs.ReadInt32(); Assert.AreEqual((int)packet.CurrentWeather, weather); } } }