public CommonResponse SendRequestCheckResponse(Request request, CommonResponse expectedResponse, RequestType requestType = RequestType.Get) { Response response = WeatherEndpoint.SendGetRequest(request).Execute().GetResponse(0); CommonResponse actualResponse = JsonConvert.DeserializeObject <CommonResponse>(response.ResponseBody); Comparator.CompareObjects(actualResponse, expectedResponse); return(actualResponse); }
public void GetWeatherViaInvalidUrl() { ByCityCountryRequest request = new ByCityCountryRequest("London"); CommonResponse expectedResponse = new CommonResponse(null, 401).SetMessage("Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."); Response response = WeatherEndpoint.SendGetRequest(request, "https://api.openweathermap.org/data/2.5weatherAPPID=9acb0f4df01ac2645b18fabf8ac4bdc6").Execute().GetResponse(0); CommonResponse actualResponse = JsonConvert.DeserializeObject <CommonResponse>(response.ResponseBody); Comparator.CompareObjects(actualResponse, expectedResponse); }
public void GetWeatherViaNonExistingEndpoint() { ByCityCountryRequest request = new ByCityCountryRequest("London"); CommonResponse expectedResponse = new CommonResponse(null, 404).SetMessage("Internal error"); Response response = NonExistingEndpoint.SendGetRequest(request).Execute().GetResponse(0); CommonResponse actualResponse = JsonConvert.DeserializeObject <CommonResponse>(response.ResponseBody); Comparator.CompareObjects(actualResponse, expectedResponse); }