コード例 #1
0
        public void BeforeSendReply_Null_HttpResponseMessage_Throws()
        {
            IDispatchMessageInspector inspector = new MockHttpMessageInspector();
            Message wcfMessage = Message.CreateMessage(MessageVersion.None, "unused");

            ExceptionAssert.ThrowsInvalidOperation(
                "WCF message without inner Http message should throw",
                () =>
            {
                inspector.BeforeSendReply(ref wcfMessage, correlationState: null);
            });
        }
コード例 #2
0
        public void BeforeSendReply_Null_Message_Throws()
        {
            IDispatchMessageInspector inspector = new MockHttpMessageInspector();
            Message wcfMessage = null;

            ExceptionAssert.ThrowsArgumentNull(
                "Null message argument should throw",
                "reply",
                () =>
            {
                inspector.BeforeSendReply(ref wcfMessage, correlationState: null);
            });
        }
コード例 #3
0
        public void BeforeSendReply_Receives_Custom_CorrelationState()
        {
            HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
            Message             wcfMessage          = httpResponseMessage.ToMessage();
            object correlationState = "Hello";

            IDispatchMessageInspector inspector = new MockHttpMessageInspector()
            {
                OnBeforeSendReply = (actualMessage, state) =>
                {
                    Assert.AreSame(correlationState, state, "BeforeSendReply did not receive the state we provided.");
                }
            };

            inspector.BeforeSendReply(ref wcfMessage, correlationState);
            Assert.IsTrue(((MockHttpMessageInspector)inspector).WasBeforeSendReplyCalled, "BeforeSentReply in derived class was not called");
        }
コード例 #4
0
        public void BeforeSendReply_Receives_HttpResponseMessage()
        {
            HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
            Message             wcfMessage          = httpResponseMessage.ToMessage();

            IDispatchMessageInspector inspector = new MockHttpMessageInspector()
            {
                OnBeforeSendReply = (actualMessage, state) =>
                {
                    Assert.AreSame(httpResponseMessage, actualMessage, "BeforeSendReply did not receive the message we provided.");
                }
            };

            inspector.BeforeSendReply(ref wcfMessage, correlationState: null);
            Assert.AreSame(httpResponseMessage, wcfMessage.ToHttpResponseMessage(), "Expected embedded HttpResponseMessage to remain unmodified");
            Assert.IsTrue(((MockHttpMessageInspector)inspector).WasBeforeSendReplyCalled, "BeforeSentReply in derived class was not called");
        }