public void GetWeatherDataByCity() { IWeatherRepository _iWeatherRepository = null; int cityID = 1; _iWeatherRepository = new WeatherRepository(); tblTemperature expectedTempData = new tblTemperature(); expectedTempData.CityID = 1; expectedTempData.Location = "Paramatta"; expectedTempData.Preasure = 30; expectedTempData.RelativeHumidity = 50; expectedTempData.SkyCondition = "Good"; expectedTempData.Visibility = 1; expectedTempData.DewPoint = 1; List <Country> actualTempData = null; WeatherController wc = new WeatherController(_iWeatherRepository); wc.Request = new HttpRequestMessage() { Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } } }; HttpResponseMessage response = wc.GetWeatherDataByCity(cityID); response.TryGetContentValue <List <Country> >(out actualTempData); Assert.AreEqual(expectedTempData, actualTempData); }
public HttpResponseMessage GetWeatherDataByCity([FromUri] int cityID) { try { tblTemperature temperatureData = _iWeatherRepository.GetWeatherData(cityID); return(Request.CreateResponse(HttpStatusCode.OK, temperatureData)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }