public void Abort_Calls_The_Inner_Listener()
        {
            MockChannelListener innerListener = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(new HttpBinding(), innerListener);

            listener.Abort();

            Assert.IsTrue(innerListener.OnAbortCalled, "HttpMessageEncodingChannelListener.Abort should have called Abort on the inner listener.");
        }
Exemplo n.º 2
0
        public void LocalAddress_Calls_LocalAdress_On_The_Inner_Channel()
        {
            MockChannelListener             channelManager = new MockChannelListener();
            MockReplyChannel                innerChannel   = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel        = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);

            innerChannel.SetLocalAddress(new EndpointAddress("http://somehost.org"));
            Assert.AreSame(innerChannel.LocalAddress, channel.LocalAddress, "HttpMessageEncodingReplyChannel.LocalAddress should call LocalAddress on the inner channel.");
        }
Exemplo n.º 3
0
        public void Abort_Calls_The_Inner_Listener()
        {
            MockChannelListener innerListener           = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

            listener.Abort();

            Assert.IsTrue(innerListener.OnAbortCalled, "HttpMessageEncodingChannelListener.Abort should have called Abort on the inner listener.");
        }
        public void AcceptChannel_Returns_Null_If_Inner_Listener_Returns_Null()
        {
            MockChannelListener innerListener = new MockChannelListener(true /* return null channel */);
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(new HttpBinding(), innerListener);
            listener.Open();

            IReplyChannel replyChannel = listener.AcceptChannel();

            Assert.IsNull(replyChannel, "HttpMessageEncodingChannelListener.AcceptChannel should have returned null since the inner listener returned null.");
        }
        public void Abort_Calls_Abort_On_The_Inner_Channel()
        {
            MockChannelListener channelManager = new MockChannelListener();
            MockReplyChannel innerChannel = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);
            channel.Open();

            channel.Abort();
            Assert.IsTrue(innerChannel.OnAbortCalled, "HttpMessageEncodingReplyChannel.Abort should call Abort on the inner channel.");
        }
Exemplo n.º 6
0
        public void EndOpen_Calls_EndOpen_On_The_Inner_Channel()
        {
            MockChannelListener             channelManager = new MockChannelListener();
            MockReplyChannel                innerChannel   = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel        = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);

            IAsyncResult result = channel.BeginOpen(null, null);

            channel.EndOpen(result);
            Assert.IsTrue(innerChannel.OnEndOpenCalled, "HttpMessageEncodingReplyChannel.EndOpen should call EndOpen on the inner channel.");
        }
        public void BeginOpen_Calls_BeginOpen_On_The_Inner_Channel()
        {
            MockChannelListener channelManager = new MockChannelListener();
            MockReplyChannel innerChannel = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);

            TimeSpan timeout = new TimeSpan(0, 1, 0);
            IAsyncResult result = channel.BeginOpen(timeout, null, null);
            Assert.IsTrue(innerChannel.OnBeginOpenCalled, "HttpMessageEncodingReplyChannel.BeginOpen should call BeginOpen on the inner channel.");
            Assert.AreEqual(timeout, innerChannel.TimeoutParameter, "HttpMessageEncodingReplyChannel.BeginOpen should have passed the timeout parameter to the inner channel.");
        }
Exemplo n.º 8
0
        public void AcceptChannel_Returns_Null_If_Inner_Listener_Returns_Null()
        {
            MockChannelListener innerListener           = new MockChannelListener(true /* return null channel */);
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

            listener.Open();

            IReplyChannel replyChannel = listener.AcceptChannel();

            Assert.IsNull(replyChannel, "HttpMessageEncodingChannelListener.AcceptChannel should have returned null since the inner listener returned null.");
        }
Exemplo n.º 9
0
        public void Abort_Calls_Abort_On_The_Inner_Channel()
        {
            MockChannelListener             channelManager = new MockChannelListener();
            MockReplyChannel                innerChannel   = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel        = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);

            channel.Open();

            channel.Abort();
            Assert.IsTrue(innerChannel.OnAbortCalled, "HttpMessageEncodingReplyChannel.Abort should call Abort on the inner channel.");
        }
        public void AcceptChannel_Returns_HttpMessageEncodingReplyChannel()
        {
            MockChannelListener innerListener = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(new HttpBinding(), innerListener);
            listener.Open();

            IReplyChannel replyChannel = listener.AcceptChannel();

            Assert.IsNotNull(replyChannel, "HttpMessageEncodingChannelListener.AcceptChannel should not have returned null.");
            Assert.IsInstanceOfType(replyChannel, typeof(HttpMessageEncodingReplyChannel), "HttpMessageEncodingChannelListener.AcceptChannel should have returned an HttpMessageEncodingReplyChannel.");
        }
Exemplo n.º 11
0
        public void BeginOpen_Calls_BeginOpen_On_The_Inner_Channel()
        {
            MockChannelListener             channelManager = new MockChannelListener();
            MockReplyChannel                innerChannel   = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel        = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);

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

            Assert.IsTrue(innerChannel.OnBeginOpenCalled, "HttpMessageEncodingReplyChannel.BeginOpen should call BeginOpen on the inner channel.");
            Assert.AreEqual(timeout, innerChannel.TimeoutParameter, "HttpMessageEncodingReplyChannel.BeginOpen should have passed the timeout parameter to the inner channel.");
        }
        public void AcceptChannel_Calls_The_Inner_Listener_With_Timeout()
        {
            MockChannelListener innerListener = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(new HttpBinding(), innerListener);
            listener.Open();

            TimeSpan timeout = new TimeSpan(0,2,0);
            IReplyChannel replyChannel = listener.AcceptChannel(timeout);

            Assert.IsTrue(innerListener.OnAcceptChannelCalled, "HttpMessageEncodingChannelListener.AcceptChannel should have called AcceptChannel on the inner listener.");
            Assert.AreEqual(innerListener.TimeoutParameter, timeout, "HttpMessageEncodingChannelListener.AcceptChannel should have passed along the same timeout instance to the inner listener.");
        }
Exemplo n.º 13
0
        public void BeginOpen_Calls_The_Inner_Listener()
        {
            MockChannelListener innerListener           = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

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

            listener.BeginOpen(timeout, null, null);

            Assert.IsTrue(innerListener.OnBeginOpenCalled, "HttpMessageEncodingChannelListener.BeginOpen should have called BeginOpen on the inner listener.");
            Assert.AreEqual(timeout, innerListener.TimeoutParameter, "HttpMessageEncodingChannelListener.BeginOpen should have passed the timeout parameter along to the inner listener.");
        }
Exemplo n.º 14
0
        public void Uri_Returns_Inner_Listener_Uri()
        {
            MockChannelListener innerListener = new MockChannelListener();
            Uri innerUri = new Uri("http://innerListenerUri.org/");

            innerListener.SetUri(innerUri);
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);
            Uri uri = listener.Uri;

            Assert.IsNotNull(uri, "HttpMessageEncodingChannelListener.Uri should not have returned null.");
            Assert.AreSame(innerUri, uri, "HttpMessageEncodingChannelListener.Uri should have returned the same Uri instance as the inner listener.");
        }
Exemplo n.º 15
0
        public void AcceptChannel_Returns_HttpMessageEncodingReplyChannel()
        {
            MockChannelListener innerListener           = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

            listener.Open();

            IReplyChannel replyChannel = listener.AcceptChannel();

            Assert.IsNotNull(replyChannel, "HttpMessageEncodingChannelListener.AcceptChannel should not have returned null.");
            Assert.IsInstanceOfType(replyChannel, typeof(HttpMessageEncodingReplyChannel), "HttpMessageEncodingChannelListener.AcceptChannel should have returned an HttpMessageEncodingReplyChannel.");
        }
Exemplo n.º 16
0
        public void Open_Calls_The_Inner_Listener_With_Timeout()
        {
            MockChannelListener innerListener           = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

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

            listener.Open(timeout);

            Assert.IsTrue(innerListener.OnOpenCalled, "HttpMessageEncodingChannelListener.Open should have called Open on the inner listener.");
            Assert.AreEqual(innerListener.TimeoutParameter, timeout, "HttpMessageEncodingChannelListener.Open should have passed along the same timeout instance to the inner listener.");
        }
Exemplo n.º 17
0
        public void EndOpen_Calls_The_Inner_Listener()
        {
            MockChannelListener innerListener           = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

            TimeSpan     timeout = new TimeSpan(0, 2, 0);
            IAsyncResult result  = listener.BeginOpen(timeout, null, null);

            listener.EndOpen(result);

            Assert.IsTrue(innerListener.OnEndOpenCalled, "HttpMessageEncodingChannelListener.EndOpen should have called EndOpen on the inner listener.");
        }
Exemplo n.º 18
0
        public void ReceiveRequest_Returns_Null_If_Inner_Channel_Returns_Null()
        {
            MockChannelListener             channelManager = new MockChannelListener();
            MockReplyChannel                innerChannel   = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel        = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);

            channel.Open();

            innerChannel.RequestContextToReturn = null;
            RequestContext context = channel.ReceiveRequest();

            Assert.IsNull(context, "HttpMessageEncodingReplyChannel.ReceiveRequest should have returned null since the inner channel returned null.");
        }
        public void AcceptChannel_Calls_The_Inner_Listener_With_Timeout()
        {
            MockChannelListener innerListener           = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(new HttpBinding(), innerListener);

            listener.Open();

            TimeSpan      timeout      = new TimeSpan(0, 2, 0);
            IReplyChannel replyChannel = listener.AcceptChannel(timeout);

            Assert.IsTrue(innerListener.OnAcceptChannelCalled, "HttpMessageEncodingChannelListener.AcceptChannel should have called AcceptChannel on the inner listener.");
            Assert.AreEqual(innerListener.TimeoutParameter, timeout, "HttpMessageEncodingChannelListener.AcceptChannel should have passed along the same timeout instance to the inner listener.");
        }
        public void BeginClose_Calls_The_Inner_Listener()
        {
            MockChannelListener innerListener           = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(new HttpBinding(), innerListener);

            listener.Open();

            TimeSpan     timeout     = new TimeSpan(0, 2, 0);
            IAsyncResult asyncResult = listener.BeginClose(timeout, null, null);

            Assert.IsTrue(innerListener.OnBeginCloseCalled, "HttpMessageEncodingChannelListener.BeginClose should have called BeginClose on the inner listener.");
            Assert.AreEqual(timeout, innerListener.TimeoutParameter, "HttpMessageEncodingChannelListener.BeginClose should have passed the timeout parameter along to the inner listener.");
        }
        public void BeginReceiveRequest_Calls_BeginReceiveRequest_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.BeginReceiveRequest(timeout, null, null);
            Assert.IsTrue(innerChannel.BeginReceiveRequestCalled, "HttpMessageEncodingReplyChannel.BeginReceiveRequest should call BeginReceiveRequest on the inner channel.");
            Assert.AreEqual(timeout, innerChannel.TimeoutParameter, "HttpMessageEncodingReplyChannel.BeginReceiveRequest should have passed the timeout parameter to the inner channel.");
            Assert.AreSame(innerChannel.AsyncResultReturned, result, "HttpMessageEncodingReplyChannel.BeginReceiveRequest should have returned the async result from the inner channel.");
        }
Exemplo n.º 22
0
        public void WaitForChannel_Calls_The_Inner_Listener_With_Timeout()
        {
            MockChannelListener innerListener           = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

            listener.Open();

            TimeSpan timeout    = new TimeSpan(0, 2, 0);
            bool     waitResult = listener.WaitForChannel(timeout);

            Assert.IsTrue(waitResult, "HttpMessageEncodingChannelListener.WaitForChannel should have returned the value from calling WaitForChannel on the inner listener.");
            Assert.IsTrue(innerListener.OnWaitForChannelCalled, "HttpMessageEncodingChannelListener.WaitForChannel should have called WaitForChannel on the inner listener.");
            Assert.AreEqual(innerListener.TimeoutParameter, timeout, "HttpMessageEncodingChannelListener.WaitForChannel should have passed along the same timeout instance to the inner listener.");
        }
Exemplo n.º 23
0
        public void EndReceiveRequest_Calls_EndReceiveRequest_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();
            IAsyncResult   result  = channel.BeginReceiveRequest(null, null);
            RequestContext context = channel.EndReceiveRequest(result);

            Assert.IsTrue(innerChannel.EndReceiveRequestCalled, "HttpMessageEncodingReplyChannel.EndReceiveRequest should call EndReceiveRequest on the inner channel.");
            Assert.IsInstanceOfType(context, typeof(HttpMessageEncodingRequestContext), "HttpMessageEncodingReplyChannel.EndReceiveRequest should have returned an HttpMessageEncodingRequestContext instance.");
        }
Exemplo n.º 24
0
        public void WaitForRequest_Calls_WaitForRequest_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);
            bool     didRecievedRequest = channel.WaitForRequest(timeout);

            Assert.IsTrue(innerChannel.WaitForRequestCalled, "HttpMessageEncodingReplyChannel.WaitForRequest should call WaitForRequest on the inner channel.");
            Assert.AreEqual(timeout, innerChannel.TimeoutParameter, "HttpMessageEncodingReplyChannel.WaitForRequest should have passed the timeout parameter to the inner channel.");
            Assert.IsFalse(didRecievedRequest, "HttpMessageEncodingReplyChannel.EndWaitForRequest should have returned the value returned from the inner channel.");
        }
Exemplo n.º 25
0
        public void BeginWaitForRequest_Calls_BeginWaitForRequest_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.BeginWaitForRequest(timeout, null, null);

            Assert.IsTrue(innerChannel.BeginWaitForRequestCalled, "HttpMessageEncodingReplyChannel.BeginWaitForRequest should call BeginWaitForRequest on the inner channel.");
            Assert.AreEqual(timeout, innerChannel.TimeoutParameter, "HttpMessageEncodingReplyChannel.BeginWaitForRequest should have passed the timeout parameter to the inner channel.");
            Assert.AreSame(innerChannel.AsyncResultReturned, result, "HttpMessageEncodingReplyChannel.BeginWaitForRequest should have returned the async result from the inner channel.");
        }
Exemplo n.º 26
0
        public void EndAcceptChannel_Returns_Null_If_The_Inner_Listener_Returns_Null()
        {
            MockChannelListener innerListener           = new MockChannelListener(true /* return null channel */);
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

            listener.Open();

            object        state    = new object();
            AsyncCallback callback = MockAsyncCallback.Create();
            TimeSpan      timeout  = new TimeSpan(0, 2, 0);
            IAsyncResult  result   = listener.BeginAcceptChannel(timeout, callback, state);
            IReplyChannel channel  = listener.EndAcceptChannel(result);

            Assert.IsNull(channel, "HttpMessageEncodingChannelListener.EndAcceptChannel should have returned null since the inner listener returned null.");
        }
Exemplo n.º 27
0
        public void EndWaitForRequest_Calls_EndWaitForRequest_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();
            IAsyncResult result             = channel.BeginWaitForRequest(new TimeSpan(0, 1, 0), null, null);
            bool         didRecievedRequest = channel.EndWaitForRequest(result);

            Assert.IsTrue(innerChannel.EndWaitForRequestCalled, "HttpMessageEncodingReplyChannel.EndWaitForRequest should call EndWaitForRequest on the inner channel.");
            Assert.IsFalse(didRecievedRequest, "HttpMessageEncodingReplyChannel.EndWaitForRequest should have returned the value returned from the inner channel.");
        }
Exemplo n.º 28
0
        public void EndAcceptChannel_Returns_HttpMessageEncodingChannel()
        {
            MockChannelListener innerListener           = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

            listener.Open();

            object        state    = new object();
            AsyncCallback callback = MockAsyncCallback.Create();
            TimeSpan      timeout  = new TimeSpan(0, 2, 0);
            IAsyncResult  result   = listener.BeginAcceptChannel(timeout, callback, state);
            IReplyChannel channel  = listener.EndAcceptChannel(result);

            Assert.IsNotNull(channel, "HttpMessageEncodingChannelListener.EndAcceptChannel should not have returned null since the inner listener did not return null.");
            Assert.IsInstanceOfType(channel, typeof(HttpMessageEncodingReplyChannel), "HttpMessageEncodingChannelListener.EndAcceptChannel should have returned an HttpMessageEncodingReplyChannel.");
        }
Exemplo n.º 29
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.");
        }
Exemplo n.º 30
0
        public void EndClose_Calls_The_Inner_Listener()
        {
            MockChannelListener innerListener           = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

            listener.Open();

            object        state    = new object();
            AsyncCallback callback = MockAsyncCallback.Create();
            TimeSpan      timeout  = new TimeSpan(0, 2, 0);
            IAsyncResult  result   = listener.BeginClose(timeout, callback, state);

            listener.EndClose(result);

            Assert.IsTrue(innerListener.OnEndCloseCalled, "HttpMessageEncodingChannelListener.EndClose should have called EndClose on the inner listener.");
        }
        public void BeginAcceptChannel_Calls_The_Inner_Listener()
        {
            MockChannelListener innerListener = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);
            listener.Open();

            object state = new object();
            AsyncCallback callback = MockAsyncCallback.Create();
            TimeSpan timeout = new TimeSpan(0,2,0);
            IAsyncResult asyncResult = listener.BeginAcceptChannel(timeout, callback, state);

            Assert.IsTrue(innerListener.OnBeginAcceptChannelCalled, "HttpMessageEncodingChannelListener.BeginAcceptChannel should have called BeginAcceptChannel on the inner listener.");
            Assert.AreSame(callback, innerListener.CallbackParameter, "HttpMessageEncodingChannelListener.BeginAcceptChannel should have passed the callback parameter along to the inner listener.");
            Assert.AreEqual(timeout, innerListener.TimeoutParameter, "HttpMessageEncodingChannelListener.BeginAcceptChannel should have passed the timeout parameter along to the inner listener.");
            Assert.AreSame(state, innerListener.StateParameter, "HttpMessageEncodingChannelListener.BeginAcceptChannel should have passed the state parameter along to the inner listener.");
            Assert.AreSame(asyncResult, innerListener.AsyncResultReturned, "HttpMessageEncodingChannelListener.BeginAcceptChannel should returned the same asyncResult as the inner listener.");
        }
Exemplo n.º 32
0
        public void ReceiveRequest_Calls_ReceiveRequest_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();
            RequestContext context = channel.ReceiveRequest(timeout);

            Assert.IsTrue(innerChannel.ReceiveRequestCalled, "HttpMessageEncodingReplyChannel.ReceiveRequest should call ReceiveRequest on the inner channel.");
            Assert.AreEqual(timeout, innerChannel.TimeoutParameter, "HttpMessageEncodingReplyChannel.ReceiveRequest should have passed the timeout parameter to the inner channel.");
            Assert.IsInstanceOfType(context, typeof(HttpMessageEncodingRequestContext), "HttpMessageEncodingReplyChannel.ReceiveRequest should have returned an HttpMessageEncodingRequestContext instance.");
        }
Exemplo n.º 33
0
        public void EndWaitForChannel_Calls_The_Inner_Listener()
        {
            MockChannelListener innerListener           = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

            listener.Open();

            object        state      = new object();
            AsyncCallback callback   = MockAsyncCallback.Create();
            TimeSpan      timeout    = new TimeSpan(0, 2, 0);
            IAsyncResult  result     = listener.BeginWaitForChannel(timeout, callback, state);
            bool          waitResult = listener.EndWaitForChannel(result);

            Assert.IsTrue(waitResult, "HttpMessageEncodingChannelListener.EndWaitForChannel should have returned the value from calling EndWaitForChannel on the inner listener.");
            Assert.IsTrue(innerListener.OnEndWaitForChannelCalled, "HttpMessageEncodingChannelListener.EndWaitForChannel should have called EndWaitForChannel on the inner listener.");
            Assert.AreSame(result, innerListener.ResultParameter, "HttpMessageEncodingChannelListener.EndWaitForChannel should have passed the result parameter along to the inner listener.");
        }
Exemplo n.º 34
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.");
        }
Exemplo n.º 35
0
        public void BeginAcceptChannel_Calls_The_Inner_Listener()
        {
            MockChannelListener innerListener           = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

            listener.Open();

            object        state       = new object();
            AsyncCallback callback    = MockAsyncCallback.Create();
            TimeSpan      timeout     = new TimeSpan(0, 2, 0);
            IAsyncResult  asyncResult = listener.BeginAcceptChannel(timeout, callback, state);

            Assert.IsTrue(innerListener.OnBeginAcceptChannelCalled, "HttpMessageEncodingChannelListener.BeginAcceptChannel should have called BeginAcceptChannel on the inner listener.");
            Assert.AreSame(callback, innerListener.CallbackParameter, "HttpMessageEncodingChannelListener.BeginAcceptChannel should have passed the callback parameter along to the inner listener.");
            Assert.AreEqual(timeout, innerListener.TimeoutParameter, "HttpMessageEncodingChannelListener.BeginAcceptChannel should have passed the timeout parameter along to the inner listener.");
            Assert.AreSame(state, innerListener.StateParameter, "HttpMessageEncodingChannelListener.BeginAcceptChannel should have passed the state parameter along to the inner listener.");
            Assert.AreSame(asyncResult, innerListener.AsyncResultReturned, "HttpMessageEncodingChannelListener.BeginAcceptChannel should returned the same asyncResult as the inner listener.");
        }
Exemplo n.º 36
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.");
        }
        public void EndClose_Calls_The_Inner_Listener()
        {
            MockChannelListener innerListener = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(new HttpBinding(), innerListener);
            listener.Open();

            object state = new object();
            AsyncCallback callback = MockAsyncCallback.Create();
            TimeSpan timeout = new TimeSpan(0, 2, 0);
            IAsyncResult result = listener.BeginClose(timeout, callback, state);
            listener.EndClose(result);

            Assert.IsTrue(innerListener.OnEndCloseCalled, "HttpMessageEncodingChannelListener.EndClose should have called EndClose on the inner listener.");
        }
        public void EndOpen_Calls_The_Inner_Listener()
        {
            MockChannelListener innerListener = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(new HttpBinding(), innerListener);

            TimeSpan timeout = new TimeSpan(0, 2, 0);
            IAsyncResult result = listener.BeginOpen(timeout, null, null);
            listener.EndOpen(result);

            Assert.IsTrue(innerListener.OnEndOpenCalled, "HttpMessageEncodingChannelListener.EndOpen should have called EndOpen on the inner listener.");
        }
        public void EndWaitForChannel_Calls_The_Inner_Listener()
        {
            MockChannelListener innerListener = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(new HttpBinding(), innerListener);
            listener.Open();

            object state = new object();
            AsyncCallback callback = MockAsyncCallback.Create();
            TimeSpan timeout = new TimeSpan(0, 2, 0);
            IAsyncResult result = listener.BeginWaitForChannel(timeout, callback, state);
            bool waitResult = listener.EndWaitForChannel(result);

            Assert.IsTrue(waitResult, "HttpMessageEncodingChannelListener.EndWaitForChannel should have returned the value from calling EndWaitForChannel on the inner listener.");
            Assert.IsTrue(innerListener.OnEndWaitForChannelCalled, "HttpMessageEncodingChannelListener.EndWaitForChannel should have called EndWaitForChannel on the inner listener.");
            Assert.AreSame(result, innerListener.ResultParameter, "HttpMessageEncodingChannelListener.EndWaitForChannel should have passed the result parameter along to the inner listener.");
        }
        public void Uri_Returns_Inner_Listener_Uri()
        {
            MockChannelListener innerListener = new MockChannelListener();
            Uri innerUri = new Uri("http://innerListenerUri.org/");
            innerListener.SetUri(innerUri);
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(new HttpBinding(), innerListener);
            Uri uri = listener.Uri;

            Assert.IsNotNull(uri, "HttpMessageEncodingChannelListener.Uri should not have returned null.");
            Assert.AreSame(innerUri, uri, "HttpMessageEncodingChannelListener.Uri should have returned the same Uri instance as the inner listener.");
        }
        public void LocalAddress_Calls_LocalAdress_On_The_Inner_Channel()
        {
            MockChannelListener channelManager = new MockChannelListener();
            MockReplyChannel innerChannel = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);

            innerChannel.SetLocalAddress(new EndpointAddress("http://somehost.org"));
            Assert.AreSame(innerChannel.LocalAddress, channel.LocalAddress, "HttpMessageEncodingReplyChannel.LocalAddress should call LocalAddress on the inner channel.");
        }
        public void Open_Calls_The_Inner_Listener_With_Timeout()
        {
            MockChannelListener innerListener = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

            TimeSpan timeout = new TimeSpan(0, 2, 0);
            listener.Open(timeout);

            Assert.IsTrue(innerListener.OnOpenCalled, "HttpMessageEncodingChannelListener.Open should have called Open on the inner listener.");
            Assert.AreEqual(innerListener.TimeoutParameter, timeout, "HttpMessageEncodingChannelListener.Open should have passed along the same timeout instance to the inner listener.");
        }
        public void BeginOpen_Calls_The_Inner_Listener()
        {
            MockChannelListener innerListener = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(new HttpBinding(), innerListener);

            TimeSpan timeout = new TimeSpan(0, 2, 0);
            listener.BeginOpen(timeout, null, null);

            Assert.IsTrue(innerListener.OnBeginOpenCalled, "HttpMessageEncodingChannelListener.BeginOpen should have called BeginOpen on the inner listener.");
            Assert.AreEqual(timeout, innerListener.TimeoutParameter, "HttpMessageEncodingChannelListener.BeginOpen should have passed the timeout parameter along to the inner listener.");
        }
        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.");
        }
        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.");
        }
        public void WaitForRequest_Calls_WaitForRequest_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);
            bool didRecievedRequest = channel.WaitForRequest(timeout);
            Assert.IsTrue(innerChannel.WaitForRequestCalled, "HttpMessageEncodingReplyChannel.WaitForRequest should call WaitForRequest on the inner channel.");
            Assert.AreEqual(timeout, innerChannel.TimeoutParameter, "HttpMessageEncodingReplyChannel.WaitForRequest should have passed the timeout parameter to the inner channel.");
            Assert.IsFalse(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.");
        }
        public void ReceiveRequest_Returns_Null_If_Inner_Channel_Returns_Null()
        {
            MockChannelListener channelManager = new MockChannelListener();
            MockReplyChannel innerChannel = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);
            channel.Open();

            innerChannel.RequestContextToReturn = null;
            RequestContext context = channel.ReceiveRequest();
            Assert.IsNull(context, "HttpMessageEncodingReplyChannel.ReceiveRequest should have returned null since the inner channel returned null.");
        }
        public void EndAcceptChannel_Returns_Null_If_The_Inner_Listener_Returns_Null()
        {
            MockChannelListener innerListener = new MockChannelListener(true /* return null channel */);
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(new HttpBinding(), innerListener);
            listener.Open();

            object state = new object();
            AsyncCallback callback = MockAsyncCallback.Create();
            TimeSpan timeout = new TimeSpan(0, 2, 0);
            IAsyncResult result = listener.BeginAcceptChannel(timeout, callback, state);
            IReplyChannel channel = listener.EndAcceptChannel(result);

            Assert.IsNull(channel, "HttpMessageEncodingChannelListener.EndAcceptChannel should have returned null since the inner listener returned null.");
        }
        public void EndAcceptChannel_Returns_HttpMessageEncodingChannel()
        {
            MockChannelListener innerListener = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(new HttpBinding(), innerListener);
            listener.Open();

            object state = new object();
            AsyncCallback callback = MockAsyncCallback.Create();
            TimeSpan timeout = new TimeSpan(0, 2, 0);
            IAsyncResult result = listener.BeginAcceptChannel(timeout, callback, state);
            IReplyChannel channel = listener.EndAcceptChannel(result);

            Assert.IsNotNull(channel, "HttpMessageEncodingChannelListener.EndAcceptChannel should not have returned null since the inner listener did not return null.");
            Assert.IsInstanceOfType(channel, typeof(HttpMessageEncodingReplyChannel), "HttpMessageEncodingChannelListener.EndAcceptChannel should have returned an HttpMessageEncodingReplyChannel.");
        }
        public void EndReceiveRequest_Calls_EndReceiveRequest_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();
            IAsyncResult result = channel.BeginReceiveRequest(null, null);
            RequestContext context = channel.EndReceiveRequest(result);
            Assert.IsTrue(innerChannel.EndReceiveRequestCalled, "HttpMessageEncodingReplyChannel.EndReceiveRequest should call EndReceiveRequest on the inner channel.");
            Assert.IsInstanceOfType(context, typeof(HttpMessageEncodingRequestContext), "HttpMessageEncodingReplyChannel.EndReceiveRequest should have returned an HttpMessageEncodingRequestContext instance.");
        }
        public void BeginClose_Calls_The_Inner_Listener()
        {
            MockChannelListener innerListener = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);
            listener.Open();

            TimeSpan timeout = new TimeSpan(0, 2, 0);
            IAsyncResult asyncResult = listener.BeginClose(timeout, null, null);

            Assert.IsTrue(innerListener.OnBeginCloseCalled, "HttpMessageEncodingChannelListener.BeginClose should have called BeginClose on the inner listener.");
            Assert.AreEqual(timeout, innerListener.TimeoutParameter, "HttpMessageEncodingChannelListener.BeginClose should have passed the timeout parameter along to the inner listener.");
        }
        public void EndOpen_Calls_EndOpen_On_The_Inner_Channel()
        {
            MockChannelListener channelManager = new MockChannelListener();
            MockReplyChannel innerChannel = new MockReplyChannel(channelManager);
            HttpMessageEncodingReplyChannel channel = new HttpMessageEncodingReplyChannel(channelManager, innerChannel);

            IAsyncResult result = channel.BeginOpen(null, null);
            channel.EndOpen(result);
            Assert.IsTrue(innerChannel.OnEndOpenCalled, "HttpMessageEncodingReplyChannel.EndOpen should call EndOpen on the inner channel.");
        }
        public void WaitForChannel_Calls_The_Inner_Listener_With_Timeout()
        {
            MockChannelListener innerListener = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(new HttpBinding(), innerListener);
            listener.Open();

            TimeSpan timeout = new TimeSpan(0, 2, 0);
            bool waitResult = listener.WaitForChannel(timeout);

            Assert.IsTrue(waitResult, "HttpMessageEncodingChannelListener.WaitForChannel should have returned the value from calling WaitForChannel on the inner listener.");
            Assert.IsTrue(innerListener.OnWaitForChannelCalled, "HttpMessageEncodingChannelListener.WaitForChannel should have called WaitForChannel on the inner listener.");
            Assert.AreEqual(innerListener.TimeoutParameter, timeout, "HttpMessageEncodingChannelListener.WaitForChannel should have passed along the same timeout instance to the inner listener.");
        }
        public void EndWaitForRequest_Calls_EndWaitForRequest_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();
            IAsyncResult result = channel.BeginWaitForRequest(new TimeSpan(0, 1, 0), null, null);
            bool didRecievedRequest = channel.EndWaitForRequest(result);
            Assert.IsTrue(innerChannel.EndWaitForRequestCalled, "HttpMessageEncodingReplyChannel.EndWaitForRequest should call EndWaitForRequest on the inner channel.");
            Assert.IsFalse(didRecievedRequest, "HttpMessageEncodingReplyChannel.EndWaitForRequest should have returned the value returned from the inner channel.");
        }