public void HttpMessagePluginBindingElement_Constructor1()
        {
            var be = new HttpMessageHandlerBindingElement();

            Assert.IsNotNull(be);
            Assert.IsTrue(typeof(BindingElement).IsAssignableFrom(be.GetType()));
        }
Exemplo n.º 2
0
        public void BuildChannelListener_Returns_ChannelListener_For_IReplyChannel()
        {
            HttpMessageHandlerBindingElement bindingElement = new HttpMessageHandlerBindingElement();
            IChannelListener <IReplyChannel> listener       = bindingElement.BuildChannelListener <IReplyChannel>(MockBindingContext.Create());

            Assert.IsNotNull(listener, "HttpMessageHandlerBindingElement.BuildChannelListener should have returned an instance.");
            Assert.IsInstanceOfType(listener, typeof(HttpMessageHandlerChannelListener), "HttpMessageHandlerBindingElement.BuildChannelListener should have returned an HttpMessageHandlerChannelListener.");
        }
Exemplo n.º 3
0
        public void Clone_Creates_New_HttpMessageHandlerBindingElement()
        {
            HttpMessageHandlerBindingElement bindingElement      = new HttpMessageHandlerBindingElement();
            HttpMessageHandlerBindingElement bindingElementClone = bindingElement.Clone() as HttpMessageHandlerBindingElement;

            Assert.IsNotNull(bindingElementClone, "Clone should have created a new HttpMessageHandlerBindingElement instance.");
            Assert.AreNotSame(bindingElement, bindingElementClone, "The cloned instance should be different from the original HttpMessageHandlerBindingElement instance.");
        }
        public override bool CanBuildChannelListener <TChannel>(BindingContext context)
        {
            if (context == null)
            {
                throw Fx.Exception.ArgumentNull("context");
            }

            return(HttpMessageHandlerBindingElement.IsChannelShapeSupported <TChannel>() && context.CanBuildInnerChannelListener <TChannel>());
        }
Exemplo n.º 5
0
        public void HttpMessageHandlerFactory_Is_Get_Set()
        {
            HttpMessageHandlerBindingElement bindingElement = new HttpMessageHandlerBindingElement();

            HttpMessageHandlerFactory factory = new HttpMessageHandlerFactory();

            bindingElement.MessageHandlerFactory = factory;
            Assert.AreSame(factory, bindingElement.MessageHandlerFactory, "The HttpMessageHandlerFactory should refer to the factory that was set.");
        }
        public void HttpMessagePluginBindingElement_Constructor2()
        {
            var be1 = new HttpMessageHandlerBindingElement();

            Assert.IsNotNull(be1);
            var be2 = be1.Clone();

            Assert.IsNotNull(be2);
            Assert.AreNotSame(be1, be2);
        }
Exemplo n.º 7
0
        public void HttpMessageHandlerFactory_Can_Be_Set_To_Null()
        {
            HttpMessageHandlerBindingElement bindingElement = new HttpMessageHandlerBindingElement();

            HttpMessageHandlerFactory factory = new HttpMessageHandlerFactory();

            bindingElement.MessageHandlerFactory = factory;
            bindingElement.MessageHandlerFactory = null;
            Assert.IsNull(bindingElement.MessageHandlerFactory, "The HttpMessageHandlerFactory should be null as it was set to null.");
        }
Exemplo n.º 8
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());
            });
        }
        public void HttpMessagePluginBindingElement_Property1()
        {
            var be = new HttpMessageHandlerBindingElement();

            be.MessageHandlerFactory = null;
            Assert.IsNull(be.MessageHandlerFactory);

            var factory = new HttpMessageHandlerFactory();

            be.MessageHandlerFactory = factory;
            Assert.ReferenceEquals(factory, be.MessageHandlerFactory);
        }
Exemplo n.º 10
0
        public void CanBuildChannelFactory_Always_Returns_False()
        {
            HttpMessageHandlerBindingElement bindingElement = new HttpMessageHandlerBindingElement();

            Assert.IsFalse(bindingElement.CanBuildChannelFactory <IReplyChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(bindingElement.CanBuildChannelFactory <IReplySessionChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(bindingElement.CanBuildChannelFactory <IRequestChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(bindingElement.CanBuildChannelFactory <IRequestSessionChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(bindingElement.CanBuildChannelFactory <IOutputChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(bindingElement.CanBuildChannelFactory <IOutputSessionChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(bindingElement.CanBuildChannelFactory <IInputChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(bindingElement.CanBuildChannelFactory <IInputSessionChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(bindingElement.CanBuildChannelFactory <IDuplexChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelFactory should always return 'false'.");
            Assert.IsFalse(bindingElement.CanBuildChannelFactory <IDuplexSessionChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelFactory should always return 'false'.");
        }
Exemplo n.º 11
0
        public void CanBuildChannelListener_Only_Returns_True_For_IReplyChannel()
        {
            HttpMessageHandlerBindingElement bindingElement = new HttpMessageHandlerBindingElement();

            Assert.IsTrue(bindingElement.CanBuildChannelListener <IReplyChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelListener should have returned 'true'.");
            Assert.IsFalse(bindingElement.CanBuildChannelListener <IReplySessionChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
            Assert.IsFalse(bindingElement.CanBuildChannelListener <IRequestChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
            Assert.IsFalse(bindingElement.CanBuildChannelListener <IRequestSessionChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
            Assert.IsFalse(bindingElement.CanBuildChannelListener <IOutputChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
            Assert.IsFalse(bindingElement.CanBuildChannelListener <IOutputSessionChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
            Assert.IsFalse(bindingElement.CanBuildChannelListener <IInputChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
            Assert.IsFalse(bindingElement.CanBuildChannelListener <IInputSessionChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
            Assert.IsFalse(bindingElement.CanBuildChannelListener <IDuplexChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
            Assert.IsFalse(bindingElement.CanBuildChannelListener <IDuplexSessionChannel>(MockBindingContext.Create()), "HttpMessageHandlerBindingElement.CanBuildChannelListener should always return 'false' for non IReplyChannel shapes.");
        }
Exemplo n.º 12
0
        public void HttpMessageHandlerBindingElement_Has_Parameterless_Constructor()
        {
            HttpMessageHandlerBindingElement bindingElement = new HttpMessageHandlerBindingElement();

            Assert.IsTrue(typeof(BindingElement).IsAssignableFrom(bindingElement.GetType()), "HttpMessageHandlerBindingElement should be a BindingElement");
        }
 public void HttpMessagePluginBindingElement_Method7()
 {
     var be      = new HttpMessageHandlerBindingElement();
     var bc      = new BindingContext(new CustomBinding(be), new BindingParameterCollection());
     var channel = be.BuildChannelListener <IInputChannel>(bc);
 }
        public void HttpMessagePluginBindingElement_Method4()
        {
            var be = new HttpMessageHandlerBindingElement();

            Assert.IsTrue(be.CanBuildChannelListener <IReplyChannel>(null));
        }
        public void HttpMessagePluginBindingElement_Method3()
        {
            var be = new HttpMessageHandlerBindingElement();

            be.BuildChannelFactory <IReplyChannel>(null);
        }
Exemplo n.º 16
0
        public void HttpMessageHandlerFactory_Is_Null_By_Default()
        {
            HttpMessageHandlerBindingElement bindingElement = new HttpMessageHandlerBindingElement();

            Assert.IsNull(bindingElement.MessageHandlerFactory, "The HttpMessageHandlerFactory should be null by default.");
        }
Exemplo n.º 17
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 HttpMessagePluginBindingElement_Method2()
        {
            var be = new HttpMessageHandlerBindingElement();

            Assert.IsFalse(be.CanBuildChannelFactory <IRequestChannel>(null));
        }
 private HttpMessageHandlerBindingElement(HttpMessageHandlerBindingElement elementToBeCloned)
 {
     this.MessageHandlerFactory = elementToBeCloned.MessageHandlerFactory;
 }