public void BuildChannelListener_Returns_Null_If_Inner_BindingElement_Returns_Null()
 {
     HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();
     MockBindingContext context = MockBindingContext.CreateWithMockTransport();
     IChannelListener<IReplyChannel> listener = encoding.BuildChannelListener<IReplyChannel>(context);
     Assert.IsNull(listener, "HttpMessageEncodingBindingElement.BuildChannelListener should have null since the inner binding element returned null.");
 }
 public void BuildChannelListener_Adds_HttpMessageEncodingBindingElement_To_Binding_Parameters_Collection()
 {
     HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();
     MockBindingContext context = MockBindingContext.CreateWithMockTransport();
     encoding.BuildChannelListener<IReplyChannel>(context);
     Assert.IsTrue(context.MockTransportBindingElement.FoundHttpMessageEncodingBindingElement, "The HttpMessageEncodingBindingElement should have been added to the collection of binding parameters.");
 }
 public void BuildChannelListener_Returns_ChannelListener_For_IReplyChannel()
 {
     HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();
     IChannelListener<IReplyChannel> listener = encoding.BuildChannelListener<IReplyChannel>(MockBindingContext.Create());
     Assert.IsNotNull(listener, "HttpMessageEncodingBindingElement.BuildChannelListener should have returned an instance.");
     Assert.IsInstanceOfType(listener, typeof(HttpMessageEncodingChannelListener), "HttpMessageEncodingBindingElement.BuildChannelListener should have returned an HttpMessageEncodingChannelListener.");
 }
        public void BuildChannelListener_Adds_HttpMessageEncodingBindingElement_To_Binding_Parameters_Collection()
        {
            HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();
            MockBindingContext context = MockBindingContext.CreateWithMockTransport();

            encoding.BuildChannelListener <IReplyChannel>(context);
            Assert.IsTrue(context.MockTransportBindingElement.FoundHttpMessageEncodingBindingElement, "The HttpMessageEncodingBindingElement should have been added to the collection of binding parameters.");
        }
        public void BuildChannelListener_Returns_Null_If_Inner_BindingElement_Returns_Null()
        {
            HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();
            MockBindingContext context = MockBindingContext.CreateWithMockTransport();
            IChannelListener <IReplyChannel> listener = encoding.BuildChannelListener <IReplyChannel>(context);

            Assert.IsNull(listener, "HttpMessageEncodingBindingElement.BuildChannelListener should have null since the inner binding element returned null.");
        }
        public void BuildChannelListener_Returns_ChannelListener_For_IReplyChannel()
        {
            HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();
            IChannelListener <IReplyChannel>  listener = encoding.BuildChannelListener <IReplyChannel>(MockBindingContext.Create());

            Assert.IsNotNull(listener, "HttpMessageEncodingBindingElement.BuildChannelListener should have returned an instance.");
            Assert.IsInstanceOfType(listener, typeof(HttpMessageEncodingChannelListener), "HttpMessageEncodingBindingElement.BuildChannelListener should have returned an HttpMessageEncodingChannelListener.");
        }
        public void BuildChannelListener_Throws_For_Non_IReplyChannel()
        {
            HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IReplySessionChannel.",
                () =>
                {
                    encoding.BuildChannelListener<IReplySessionChannel>(MockBindingContext.Create());
                });

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IRequestChannel.",
                () =>
                {
                    encoding.BuildChannelListener<IRequestChannel>(MockBindingContext.Create());
                });

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IRequestSessionChannel.",
                () =>
                {
                    encoding.BuildChannelListener<IRequestSessionChannel>(MockBindingContext.Create());
                });

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IOutputChannel.",
                () =>
                {
                    encoding.BuildChannelListener<IOutputChannel>(MockBindingContext.Create());
                });

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IOutputSessionChannel.",
                () =>
                {
                    encoding.BuildChannelListener<IOutputSessionChannel>(MockBindingContext.Create());
                });

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IInputChannel.",
                () =>
                {
                    encoding.BuildChannelListener<IInputChannel>(MockBindingContext.Create());
                });

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IInputSessionChannel.",
                () =>
                {
                    encoding.BuildChannelListener<IInputSessionChannel>(MockBindingContext.Create());
                });

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IDuplexChannel.",
                () =>
                {
                    encoding.BuildChannelListener<IDuplexChannel>(MockBindingContext.Create());
                });

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IDuplexSessionChannel.",
                () =>
                {
                    encoding.BuildChannelListener<IDuplexSessionChannel>(MockBindingContext.Create());
                });
        }
        public void BuildChannelListener_Throws_For_Non_IReplyChannel()
        {
            HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IReplySessionChannel.",
                () =>
            {
                encoding.BuildChannelListener <IReplySessionChannel>(MockBindingContext.Create());
            });

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IRequestChannel.",
                () =>
            {
                encoding.BuildChannelListener <IRequestChannel>(MockBindingContext.Create());
            });

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IRequestSessionChannel.",
                () =>
            {
                encoding.BuildChannelListener <IRequestSessionChannel>(MockBindingContext.Create());
            });

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IOutputChannel.",
                () =>
            {
                encoding.BuildChannelListener <IOutputChannel>(MockBindingContext.Create());
            });

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IOutputSessionChannel.",
                () =>
            {
                encoding.BuildChannelListener <IOutputSessionChannel>(MockBindingContext.Create());
            });

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IInputChannel.",
                () =>
            {
                encoding.BuildChannelListener <IInputChannel>(MockBindingContext.Create());
            });

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IInputSessionChannel.",
                () =>
            {
                encoding.BuildChannelListener <IInputSessionChannel>(MockBindingContext.Create());
            });

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IDuplexChannel.",
                () =>
            {
                encoding.BuildChannelListener <IDuplexChannel>(MockBindingContext.Create());
            });

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelListener should have thrown for IDuplexSessionChannel.",
                () =>
            {
                encoding.BuildChannelListener <IDuplexSessionChannel>(MockBindingContext.Create());
            });
        }
        public void BuildChannelListener_Throws_For_Non_IReplyChannel()
        {
            HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();

            ExceptionAssert.Throws<NotSupportedException>(
                SR.ChannelShapeNotSupportedByHttpMessageEncodingBindingElement(typeof(IReplySessionChannel).Name),
                () =>
                {
                    encoding.BuildChannelListener<IReplySessionChannel>(MockBindingContext.Create());
                });

            ExceptionAssert.Throws<NotSupportedException>(
                SR.ChannelShapeNotSupportedByHttpMessageEncodingBindingElement(typeof(IRequestChannel).Name),
                () =>
                {
                    encoding.BuildChannelListener<IRequestChannel>(MockBindingContext.Create());
                });

            ExceptionAssert.Throws<NotSupportedException>(
                SR.ChannelShapeNotSupportedByHttpMessageEncodingBindingElement(typeof(IRequestSessionChannel).Name),
                () =>
                {
                    encoding.BuildChannelListener<IRequestSessionChannel>(MockBindingContext.Create());
                });

            ExceptionAssert.Throws<NotSupportedException>(
                SR.ChannelShapeNotSupportedByHttpMessageEncodingBindingElement(typeof(IOutputChannel).Name),
                () =>
                {
                    encoding.BuildChannelListener<IOutputChannel>(MockBindingContext.Create());
                });

            ExceptionAssert.Throws<NotSupportedException>(
                SR.ChannelShapeNotSupportedByHttpMessageEncodingBindingElement(typeof(IOutputSessionChannel).Name),
                () =>
                {
                    encoding.BuildChannelListener<IOutputSessionChannel>(MockBindingContext.Create());
                });

            ExceptionAssert.Throws<NotSupportedException>(
                SR.ChannelShapeNotSupportedByHttpMessageEncodingBindingElement(typeof(IInputChannel).Name),
                () =>
                {
                    encoding.BuildChannelListener<IInputChannel>(MockBindingContext.Create());
                });

            ExceptionAssert.Throws<NotSupportedException>(
                SR.ChannelShapeNotSupportedByHttpMessageEncodingBindingElement(typeof(IInputSessionChannel).Name),
                () =>
                {
                    encoding.BuildChannelListener<IInputSessionChannel>(MockBindingContext.Create());
                });

            ExceptionAssert.Throws<NotSupportedException>(
                SR.ChannelShapeNotSupportedByHttpMessageEncodingBindingElement(typeof(IDuplexChannel).Name),
                () =>
                {
                    encoding.BuildChannelListener<IDuplexChannel>(MockBindingContext.Create());
                });

            ExceptionAssert.Throws<NotSupportedException>(
                SR.ChannelShapeNotSupportedByHttpMessageEncodingBindingElement(typeof(IDuplexSessionChannel).Name),
                () =>
                {
                    encoding.BuildChannelListener<IDuplexSessionChannel>(MockBindingContext.Create());
                });
        }