Пример #1
0
        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.");
        }
Пример #2
0
        public void BuildChannelListener_Adds_HttpMessageEncodingBindingElement_To_Binding_Parameters_Collection()
        {
            HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();
            MockBindingContext context = MockBindingContext.CreateWithMockTransport();

            encoding.BuildChannelListener <IReplyChannel>(context);
            Assert.IsNotNull(context.BindingParameters.Find <HttpMessageEncodingBindingElement>(), "The HttpMessageEncodingBindingElement should have been added to the collection of binding parameters.");
        }
Пример #3
0
        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.");
        }
Пример #4
0
        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());
            });
        }