예제 #1
0
        public void StatusCode_TestWithResponse()
        {
            var response = new HttpResponseMessage(errorCode);

            var exception = new TestClientException(errorMessage, response);

            Assert.AreEqual(errorCode, exception.StatusCode);
        }
예제 #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);
        }
예제 #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));
        }
예제 #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");
        }
예제 #5
0
        public void StatusCode_TestWithRequest()
        {
            var exception = new TestClientException(errorMessage, new HttpRequestMessage(), errorCode);

            Assert.AreEqual(errorCode, exception.StatusCode);
        }
예제 #6
0
        public void ResponseContent_TestWithRequest()
        {
            var exception = new TestClientException(errorMessage, new HttpRequestMessage(), errorCode);

            Assert.IsNull(exception.ResponseContent);
        }