Exemplo n.º 1
0
        public void StatusCode_TestWithResponse()
        {
            var response = new HttpResponseMessage(errorCode);

            var exception = new TestClientException(errorMessage, response);

            Assert.AreEqual(errorCode, exception.StatusCode);
        }
Exemplo n.º 2
0
        public void InnerException_TestWithRequestAndInnerException()
        {
            var innerException = new Exception("Inner exception message");

            var exception = new TestClientException(errorMessage, new HttpRequestMessage(), errorCode, innerException);

            Assert.AreSame(innerException, exception.InnerException);
        }
Exemplo n.º 3
0
        public void ResponseContent_TestWithResponse()
        {
            var content  = new StringContent("MockContent");
            var response = new HttpResponseMessage()
            {
                Content = content,
            };

            var exception = new TestClientException(errorMessage, response);

            Assert.IsNotNull(exception.ResponseContent);
            Assert.IsInstanceOfType(exception.ResponseContent, typeof(StringContent));
        }
Exemplo n.º 4
0
        public void Message_TestWithRequest()
        {
            var requestMock = new Mock <HttpRequestMessage>();

            requestMock
            .Setup(r => r.ToString())
            .Returns("MockRequestToString");

            var exception = new TestClientException(errorMessage, requestMock.Object, errorCode);

            exception.AssertMessageKeyAndValue("Message", errorMessage);
            exception.AssertMessageKeyAndValue("Request", "MockRequestToString");
            exception.AssertMessageKeyAndValue("StatusCode", errorCode.ToString());
            exception.AssertMissingMessageKey("Response");
            exception.AssertMissingMessageKey("ResponseContent");
        }
Exemplo n.º 5
0
        public void StatusCode_TestWithRequest()
        {
            var exception = new TestClientException(errorMessage, new HttpRequestMessage(), errorCode);

            Assert.AreEqual(errorCode, exception.StatusCode);
        }
Exemplo n.º 6
0
        public void ResponseContent_TestWithRequest()
        {
            var exception = new TestClientException(errorMessage, new HttpRequestMessage(), errorCode);

            Assert.IsNull(exception.ResponseContent);
        }