public void Should_not_fail_if_xml_is_a_malformed_api_error() { const string validXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><response status=\"error\" version=\"1.2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://api.7digital.com/1.2/static/7digitalAPI.xsd\" ><error><errorme></errorme></error></response>"; var xmlErrorHandler = new XmlErrorHandler(); XElement responseAsXml = xmlErrorHandler.GetResponseAsXml(validXml); Assert.Throws<ApiXmlException>(() => xmlErrorHandler.AssertError(responseAsXml)); }
public void Should_not_fail_if_xml_is_not_an_api_error() { const string validXml = "<xml>Hello world</xml>"; var xmlErrorHandler = new XmlErrorHandler(); XElement responseAsXml = xmlErrorHandler.GetResponseAsXml(validXml); Assert.DoesNotThrow(() => xmlErrorHandler.AssertError(responseAsXml)); }
public void Should_assert_error_with_valid_api_xml() { const string validXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><response status=\"error\" version=\"1.2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://api.7digital.com/1.2/static/7digitalAPI.xsd\" ><error code=\"1001\"><errorMessage>Requires parameter q is missing</errorMessage></error></response>"; var xmlErrorHandler = new XmlErrorHandler(); XElement responseAsXml = xmlErrorHandler.GetResponseAsXml(validXml); Assert.Throws<ApiXmlException>(() => xmlErrorHandler.AssertError(responseAsXml)); }