示例#1
0
        public void CreateMessageEncoderFactory_Returns_An_HttpMessageEncoderFactory()
        {
            HttpMessageEncodingBindingElement encoding       = new HttpMessageEncodingBindingElement();
            MessageEncoderFactory             encoderFactory = encoding.CreateMessageEncoderFactory();

            Assert.IsNotNull(encoderFactory, "HttpMessageEncodingBindingElement.CreateMessageEncoderFactory should not have returned null.");
            Assert.IsInstanceOfType(encoderFactory, typeof(HttpMessageEncoderFactory), "HttpMessageEncodingBindingElement.CreateMessageEncoderFactory should have returned an instance of a HttpMessageEncoderFactory.");
        }
示例#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 Clone_Returns_New_HttpMessageEncodingBindingElement_Instance()
        {
            HttpMessageEncodingBindingElement encoding       = new HttpMessageEncodingBindingElement();
            HttpMessageEncodingBindingElement encodingCloned = encoding.Clone() as HttpMessageEncodingBindingElement;

            Assert.IsNotNull(encodingCloned, "Clone should have returned a new instance of HttpMessageEncodingBindingElement");
            Assert.AreNotSame(encoding, encodingCloned, "Clone should have returned a new instance of HttpMessageEncodingBindingElement");
        }
示例#4
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.");
        }
示例#5
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.");
        }
示例#6
0
        public void BuildChannelFactory_Throws()
        {
            HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();

            ExceptionAssert.Throws <NotSupportedException>(
                SR.ChannelFactoryNotSupportedByHttpMessageEncodingBindingElement(typeof(HttpMessageEncodingBindingElement).Name),
                () =>
            {
                encoding.BuildChannelFactory <IReplyChannel>(MockBindingContext.Create());
            });
        }
示例#7
0
        public void Setting_MessageVersion_To_Other_Than_None_Throws()
        {
            HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();

            ExceptionAssert.Throws <NotSupportedException>(
                SR.OnlyMessageVersionNoneSupportedOnHttpMessageEncodingBindingElement(typeof(HttpMessageEncodingBindingElement)),
                () =>
            {
                encoding.MessageVersion = MessageVersion.Soap11;
            });
        }
示例#8
0
        public void Setting_MessageVersion_To_Null_Throws()
        {
            HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();

            ExceptionAssert.ThrowsArgumentNull(
                "value",
                () =>
            {
                encoding.MessageVersion = null;
            });
        }
示例#9
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.");
        }
示例#10
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'.");
        }
示例#11
0
        public void MessageVersion_Is_Always_None()
        {
            HttpMessageEncodingBindingElement encoding = new HttpMessageEncodingBindingElement();

            Assert.AreEqual(MessageVersion.None, encoding.MessageVersion, "HttpMessageEncodingBindingElement.MessageVersion should have been MessageVersion.None.");
        }
示例#12
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());
            });
        }