Пример #1
0
        public void BuildChannelFactory_Throws()
        {
            HttpMessageHandlerBindingElement bindingElement = new HttpMessageHandlerBindingElement();

            ExceptionAssert.Throws <NotSupportedException>(
                SR.HttpMessageHandlerChannelFactoryNotSupported(typeof(HttpMessageHandlerBindingElement).Name, typeof(IChannelFactory <IReplyChannel>).Name),
                () =>
            {
                bindingElement.BuildChannelFactory <IReplyChannel>(MockBindingContext.Create());
            });
        }
Пример #2
0
        public void BuildChannelFactory_Throws()
        {
            HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();

            ExceptionAssert.Throws <NotSupportedException>(
                SR.ChannelFactoryNotSupportedByHttpMessageEncodingBindingElement(typeof(HttpMessageEncodingBindingElement).Name),
                () =>
            {
                encoding.BuildChannelFactory <IReplyChannel>(MockBindingContext.Create());
            });
        }
        public void BuildChannelFactory_Throws()
        {
            HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();

            ExceptionAssert.Throws(
                typeof(NotSupportedException),
                "HttpMessageEncodingBindingElement.BuildChannelFactory should have thrown.",
                () =>
            {
                encoding.BuildChannelFactory <IReplyChannel>(MockBindingContext.Create());
            });
        }
Пример #4
0
        public void CanBuildChannelListener_Only_Returns_True_For_IReplyChannel()
        {
            HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();

            Assert.IsTrue(encoding.CanBuildChannelListener <IReplyChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelListener should have returned 'true'.");
            Assert.IsFalse(encoding.CanBuildChannelListener <IReplySessionChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
            Assert.IsFalse(encoding.CanBuildChannelListener <IRequestChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
            Assert.IsFalse(encoding.CanBuildChannelListener <IRequestSessionChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
            Assert.IsFalse(encoding.CanBuildChannelListener <IOutputChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
            Assert.IsFalse(encoding.CanBuildChannelListener <IOutputSessionChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
            Assert.IsFalse(encoding.CanBuildChannelListener <IInputChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
            Assert.IsFalse(encoding.CanBuildChannelListener <IInputSessionChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
            Assert.IsFalse(encoding.CanBuildChannelListener <IDuplexChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
            Assert.IsFalse(encoding.CanBuildChannelListener <IDuplexSessionChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
        }
Пример #5
0
        public void CanBuildChannelFactory_Always_Returns_False()
        {
            HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();

            Assert.IsFalse(encoding.CanBuildChannelFactory <IReplyChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(encoding.CanBuildChannelFactory <IReplySessionChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(encoding.CanBuildChannelFactory <IRequestChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(encoding.CanBuildChannelFactory <IRequestSessionChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(encoding.CanBuildChannelFactory <IOutputChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(encoding.CanBuildChannelFactory <IOutputSessionChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(encoding.CanBuildChannelFactory <IInputChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(encoding.CanBuildChannelFactory <IInputSessionChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(encoding.CanBuildChannelFactory <IDuplexChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(encoding.CanBuildChannelFactory <IDuplexSessionChannel>(MockBindingContext.Create()), "HttpMessageEncodingBindingElement.CanBuildChannelFactory should always return 'false'.");
        }
Пример #6
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());
            });
        }
Пример #7
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.");
        }
Пример #8
0
        public void BuildChannelListener_Throws_For_Non_IReplyChannel()
        {
            HttpMessageHandlerBindingElement bindingElement = new HttpMessageHandlerBindingElement();

            ExceptionAssert.Throws <NotSupportedException>(
                SR.HttpMessageHandlerChannelInvalidChannelShape(typeof(IReplySessionChannel).Name, typeof(HttpMessageHandlerBindingElement).Name, typeof(IReplyChannel).Name),
                () =>
            {
                bindingElement.BuildChannelListener <IReplySessionChannel>(MockBindingContext.Create());
            });

            ExceptionAssert.Throws <NotSupportedException>(
                SR.HttpMessageHandlerChannelInvalidChannelShape(typeof(IRequestChannel).Name, typeof(HttpMessageHandlerBindingElement).Name, typeof(IReplyChannel).Name),
                () =>
            {
                bindingElement.BuildChannelListener <IRequestChannel>(MockBindingContext.Create());
            });

            ExceptionAssert.Throws <NotSupportedException>(
                SR.HttpMessageHandlerChannelInvalidChannelShape(typeof(IRequestSessionChannel).Name, typeof(HttpMessageHandlerBindingElement).Name, typeof(IReplyChannel).Name),
                () =>
            {
                bindingElement.BuildChannelListener <IRequestSessionChannel>(MockBindingContext.Create());
            });

            ExceptionAssert.Throws <NotSupportedException>(
                SR.HttpMessageHandlerChannelInvalidChannelShape(typeof(IOutputChannel).Name, typeof(HttpMessageHandlerBindingElement).Name, typeof(IReplyChannel).Name),
                () =>
            {
                bindingElement.BuildChannelListener <IOutputChannel>(MockBindingContext.Create());
            });

            ExceptionAssert.Throws <NotSupportedException>(
                SR.HttpMessageHandlerChannelInvalidChannelShape(typeof(IOutputSessionChannel).Name, typeof(HttpMessageHandlerBindingElement).Name, typeof(IReplyChannel).Name),
                () =>
            {
                bindingElement.BuildChannelListener <IOutputSessionChannel>(MockBindingContext.Create());
            });

            ExceptionAssert.Throws <NotSupportedException>(
                SR.HttpMessageHandlerChannelInvalidChannelShape(typeof(IInputChannel).Name, typeof(HttpMessageHandlerBindingElement).Name, typeof(IReplyChannel).Name),
                () =>
            {
                bindingElement.BuildChannelListener <IInputChannel>(MockBindingContext.Create());
            });

            ExceptionAssert.Throws <NotSupportedException>(
                SR.HttpMessageHandlerChannelInvalidChannelShape(typeof(IInputSessionChannel).Name, typeof(HttpMessageHandlerBindingElement).Name, typeof(IReplyChannel).Name),
                () =>
            {
                bindingElement.BuildChannelListener <IInputSessionChannel>(MockBindingContext.Create());
            });

            ExceptionAssert.Throws <NotSupportedException>(
                SR.HttpMessageHandlerChannelInvalidChannelShape(typeof(IDuplexChannel).Name, typeof(HttpMessageHandlerBindingElement).Name, typeof(IReplyChannel).Name),
                () =>
            {
                bindingElement.BuildChannelListener <IDuplexChannel>(MockBindingContext.Create());
            });

            ExceptionAssert.Throws <NotSupportedException>(
                SR.HttpMessageHandlerChannelInvalidChannelShape(typeof(IDuplexSessionChannel).Name, typeof(HttpMessageHandlerBindingElement).Name, typeof(IReplyChannel).Name),
                () =>
            {
                bindingElement.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());
            });
        }