Exemplo n.º 1
0
        public void TryReceiveRequest_Returns_Null_If_Inner_Channel_Returns_False()
        {
            MockChannelListener             channelManager = new MockChannelListener();
            MockReplyChannel                innerChannel   = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel        = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);

            channel.Open();

            TimeSpan timeout = new TimeSpan(0, 1, 0);

            innerChannel.RequestContextToReturn       = new MockRequestContext();
            innerChannel.TryReceiveRequestReturnsTrue = false;
            RequestContext context;
            bool           didRecievedRequest = channel.TryReceiveRequest(timeout, out context);

            Assert.IsNull(context, "HttpMessageEncodingReplyChannel.TryReceiveRequest should have returned null since the inner channel returned false.");
            Assert.IsFalse(didRecievedRequest, "HttpMessageEncodingReplyChannel.EndWaitForRequest should have returned the value returned from the inner channel.");
        }
Exemplo n.º 2
0
        public void TryReceiveRequest_Calls_TryReceiveRequest_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);

            innerChannel.RequestContextToReturn       = new MockRequestContext();
            innerChannel.TryReceiveRequestReturnsTrue = true;
            RequestContext context;
            bool           didRecievedRequest = channel.TryReceiveRequest(timeout, out context);

            Assert.IsTrue(innerChannel.TryReceiveRequestCalled, "HttpMessageEncodingReplyChannel.TryReceiveRequest should call TryReceiveRequest on the inner channel.");
            Assert.AreEqual(timeout, innerChannel.TimeoutParameter, "HttpMessageEncodingReplyChannel.TryReceiveRequest should have passed the timeout parameter to the inner channel.");
            Assert.IsInstanceOfType(context, typeof(HttpMessageEncodingRequestContext), "HttpMessageEncodingReplyChannel.ReceiveRequest should have returned an HttpMessageEncodingRequestContext instance.");
            Assert.IsTrue(didRecievedRequest, "HttpMessageEncodingReplyChannel.EndWaitForRequest should have returned the value returned from the inner channel.");
        }
        public void TryReceiveRequest_Returns_Null_If_Inner_Channel_Returns_Null()
        {
            MockChannelListener channelManager = new MockChannelListener();
            MockReplyChannel innerChannel = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);
            channel.Open();

            TimeSpan timeout = new TimeSpan(0, 1, 0);
            innerChannel.RequestContextToReturn = null;
            innerChannel.TryReceiveRequestReturnsTrue = true;
            RequestContext context;
            bool didRecievedRequest = channel.TryReceiveRequest(timeout, out context);
            Assert.IsNull(context, "HttpMessageEncodingReplyChannel.TryReceiveRequest should have returned null since the inner channel returned null.");
            Assert.IsTrue(didRecievedRequest, "HttpMessageEncodingReplyChannel.EndWaitForRequest should have returned the value returned from the inner channel.");
        }
        public void TryReceiveRequest_Calls_TryReceiveRequest_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);
            innerChannel.RequestContextToReturn = new MockRequestContext();
            innerChannel.TryReceiveRequestReturnsTrue = true;
            RequestContext context;
            bool didRecievedRequest = channel.TryReceiveRequest(timeout, out context);
            Assert.IsTrue(innerChannel.TryReceiveRequestCalled, "HttpMessageEncodingReplyChannel.TryReceiveRequest should call TryReceiveRequest on the inner channel.");
            Assert.AreEqual(timeout, innerChannel.TimeoutParameter, "HttpMessageEncodingReplyChannel.TryReceiveRequest should have passed the timeout parameter to the inner channel.");
            Assert.IsInstanceOfType(context, typeof(HttpMessageEncodingRequestContext), "HttpMessageEncodingReplyChannel.ReceiveRequest should have returned an HttpMessageEncodingRequestContext instance.");
            Assert.IsTrue(didRecievedRequest, "HttpMessageEncodingReplyChannel.EndWaitForRequest should have returned the value returned from the inner channel.");
        }