public void BeginTryReceiveRequest_Calls_BeginTryReceiveRequest_On_The_Inner_Channel()
        {
            MockChannelListener channelManager = new MockChannelListener();
            MockReplyChannel innerChannel = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);
            channel.Open();

            TimeSpan timeout = new TimeSpan(0, 1, 0);
            IAsyncResult result = channel.BeginTryReceiveRequest(timeout, null, null);
            Assert.IsTrue(innerChannel.BeginTryReceiveRequestCalled, "HttpMessageEncodingReplyChannel.BeginTryReceiveRequest should call BeginTryReceiveRequest on the inner channel.");
            Assert.AreEqual(timeout, innerChannel.TimeoutParameter, "HttpMessageEncodingReplyChannel.BeginTryReceiveRequest should have passed the timeout parameter to the inner channel.");
            Assert.AreSame(innerChannel.AsyncResultReturned, result, "HttpMessageEncodingReplyChannel.BeginTryReceiveRequest should have returned the async result from the inner channel.");
        }
コード例 #2
0
        public void BeginTryReceiveRequest_Calls_BeginTryReceiveRequest_On_The_Inner_Channel()
        {
            MockChannelListener             channelManager = new MockChannelListener();
            MockReplyChannel                innerChannel   = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel        = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);

            channel.Open();

            TimeSpan     timeout = new TimeSpan(0, 1, 0);
            IAsyncResult result  = channel.BeginTryReceiveRequest(timeout, null, null);

            Assert.IsTrue(innerChannel.BeginTryReceiveRequestCalled, "HttpMessageEncodingReplyChannel.BeginTryReceiveRequest should call BeginTryReceiveRequest on the inner channel.");
            Assert.AreEqual(timeout, innerChannel.TimeoutParameter, "HttpMessageEncodingReplyChannel.BeginTryReceiveRequest should have passed the timeout parameter to the inner channel.");
            Assert.AreSame(innerChannel.AsyncResultReturned, result, "HttpMessageEncodingReplyChannel.BeginTryReceiveRequest should have returned the async result from the inner channel.");
        }
コード例 #3
0
        public void EndTryReceiveRequest_Returns_Null_If_The_Inner_Channel_Returns_False()
        {
            MockChannelListener             channelManager = new MockChannelListener();
            MockReplyChannel                innerChannel   = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel        = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);

            channel.Open();

            innerChannel.RequestContextToReturn       = new MockRequestContext();
            innerChannel.TryReceiveRequestReturnsTrue = false;
            IAsyncResult   result = channel.BeginTryReceiveRequest(new TimeSpan(0, 1, 0), null, null);
            RequestContext context;
            bool           didRecievedRequest = channel.EndTryReceiveRequest(result, out context);

            Assert.IsNull(context, "HttpMessageEncodingReplyChannel.EndTryReceiveRequest should have returned null since the inner channel returned false.");
        }
コード例 #4
0
        public void EndTryReceiveRequest_Calls_EndTryReceiveRequest_On_The_Inner_Channel()
        {
            MockChannelListener             channelManager = new MockChannelListener();
            MockReplyChannel                innerChannel   = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel        = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);

            channel.Open();

            innerChannel.RequestContextToReturn       = new MockRequestContext();
            innerChannel.TryReceiveRequestReturnsTrue = true;
            IAsyncResult   result = channel.BeginTryReceiveRequest(new TimeSpan(0, 1, 0), null, null);
            RequestContext context;
            bool           didRecievedRequest = channel.EndTryReceiveRequest(result, out context);

            Assert.IsTrue(innerChannel.EndTryReceiveRequestCalled, "HttpMessageEncodingReplyChannel.EndTryReceiveRequest should call EndTryReceiveRequest on the inner channel.");
            Assert.IsTrue(didRecievedRequest, "HttpMessageEncodingReplyChannel.EndTryReceiveRequest should have returned the value returned from the inner channel.");
            Assert.IsInstanceOfType(context, typeof(HttpMessageEncodingRequestContext), "HttpMessageEncodingReplyChannel.EndTryReceiveRequest should have returned an HttpMessageEncodingRequestContext instance.");
        }
コード例 #5
0
        public void EndTryReceiveRequest_Returns_Null_If_The_Inner_Channel_Returns_Null()
        {
            MockChannelListener channelManager = new MockChannelListener();
            MockReplyChannel innerChannel = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);
            channel.Open();

            innerChannel.RequestContextToReturn = null;
            innerChannel.TryReceiveRequestReturnsTrue = true;
            IAsyncResult result = channel.BeginTryReceiveRequest(new TimeSpan(0, 1, 0), null, null);
            RequestContext context;
            bool didRecievedRequest = channel.EndTryReceiveRequest(result, out context);
            Assert.IsNull(context, "HttpMessageEncodingReplyChannel.EndTryReceiveRequest should have returned null since the inner channel returned null.");
        }
コード例 #6
0
        public void EndTryReceiveRequest_Calls_EndTryReceiveRequest_On_The_Inner_Channel()
        {
            MockChannelListener channelManager = new MockChannelListener();
            MockReplyChannel innerChannel = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);
            channel.Open();

            innerChannel.RequestContextToReturn = new MockRequestContext();
            innerChannel.TryReceiveRequestReturnsTrue = true;
            IAsyncResult result = channel.BeginTryReceiveRequest(new TimeSpan(0, 1, 0), null, null);
            RequestContext context;
            bool didRecievedRequest = channel.EndTryReceiveRequest(result, out context);
            Assert.IsTrue(innerChannel.EndTryReceiveRequestCalled, "HttpMessageEncodingReplyChannel.EndTryReceiveRequest should call EndTryReceiveRequest on the inner channel.");
            Assert.IsTrue(didRecievedRequest, "HttpMessageEncodingReplyChannel.EndTryReceiveRequest should have returned the value returned from the inner channel.");
            Assert.IsInstanceOfType(context, typeof(HttpMessageEncodingRequestContext), "HttpMessageEncodingReplyChannel.EndTryReceiveRequest should have returned an HttpMessageEncodingRequestContext instance.");
        }