public void Should_not_parse_json_identified_as_xml() { var response = new Response(HttpStatusCode.OK, XmlContentType(), JsonResponseText); var deserializer = new ResponseDeserializer(); Assert.Throws <NonXmlContentException>(() => deserializer.ResponseAs <Status>(response)); }
public void Should_not_parse_xml_identified_as_json() { var response = new Response(HttpStatusCode.OK, JsonContentType(), XmlResponseText); var deserializer = new ResponseDeserializer(); Assert.Throws <JsonParseFailedException>(() => deserializer.ResponseAs <Status>(response)); }
public void Should_not_parse_wrong_xml() { var response = new Response(HttpStatusCode.OK, XmlContentType(), XmlWrongDtoResponseText); var deserializer = new ResponseDeserializer(); Assert.Throws <UnexpectedXmlContentException>(() => deserializer.ResponseAs <Status>(response)); }
public void Should_parse_json() { var response = new Response(HttpStatusCode.OK, JsonContentType(), JsonResponseText); var deserializer = new ResponseDeserializer(); var status = deserializer.ResponseAs <Status>(response); Assert.That(status, Is.Not.Null); }
public async Task <TR> ResponseAs <TR>() { var request = _requestBuilder.BuildRequest(_requestData); try { var response = await _httpClient.Send(request); var responseDeserializer = new ResponseDeserializer(); return(responseDeserializer.ResponseAs <TR>(response)); } catch (WebException webException) { throw new ApiWebException(webException.Message, webException, request); } }