Exemple #1
0
        public void TestHandlingHTMLErrorResponse()
        {
            string errorRepsonse = "<html><body>Error: <br> The Error Message</body></html>";
            var    stream        = new MemoryStream(UTF8Encoding.UTF8.GetBytes(errorRepsonse));
            var    responseData  = new FakeResponseData {
                StatusCode = HttpStatusCode.BadGateway
            };

            XmlUnmarshallerContext context = new XmlUnmarshallerContext(stream, false, responseData);

            var             unmarshaller = new S3ErrorResponseUnmarshaller();
            S3ErrorResponse response     = unmarshaller.Unmarshall(context);

            Assert.IsNotNull(response);
        }
Exemple #2
0
        public void TestJsonResponseUnmarshaller_UnmarshallResponse()
        {
            var fakeResponseData = new FakeResponseData();

            fakeResponseData.StatusCode = HttpStatusCode.OK;
            var unmarshaller        = new BadJsonResponseUnmarshaller();
            var unmarshallerContext = new JsonUnmarshallerContext(new MemoryStream(), true, fakeResponseData);

            try
            {
                unmarshaller.UnmarshallResponse(unmarshallerContext);
                Assert.Fail();
            }
            catch (AmazonUnmarshallingException aue)
            {
                Assert.IsTrue(aue.Message.Contains("HTTP Status Code: 200 OK"));
                Assert.AreEqual(HttpStatusCode.OK, aue.StatusCode);
                Assert.IsNotNull(aue.InnerException);
                Assert.AreEqual("Error in Unmarshall", aue.InnerException.Message);
            }
        }