Ejemplo n.º 1
0
        public void MessageSecurityAndBindings2()
        {
            var n = new NetTcpBinding()
            {
                TransferMode = TransferMode.Streamed
            };

            n.Security.Mode = SecurityMode.Message;

            Assert.AreEqual(SecurityAlgorithmSuite.Default, n.Security.Message.AlgorithmSuite, "#sec1");
            Assert.AreEqual(MessageCredentialType.Windows /*huh*/, n.Security.Message.ClientCredentialType, "#sec2");

            var bc = n.CreateBindingElements();

            Assert.AreEqual(4, bc.Count, "#bc1");
            Assert.AreEqual(typeof(TransactionFlowBindingElement), bc [0].GetType(), "#bc2");
            Assert.AreEqual(typeof(SymmetricSecurityBindingElement), bc [1].GetType(), "#bc3");
            Assert.AreEqual(typeof(BinaryMessageEncodingBindingElement), bc [2].GetType(), "#bc4");
            Assert.AreEqual(typeof(TcpTransportBindingElement), bc [3].GetType(), "#bc5");

            Assert.IsFalse(n.CanBuildChannelFactory <IRequestChannel> (), "#cbf1");
            Assert.IsFalse(n.CanBuildChannelFactory <IOutputChannel> (), "#cbf2");
            Assert.IsFalse(n.CanBuildChannelFactory <IDuplexChannel> (), "#cbf3");
            Assert.IsFalse(n.CanBuildChannelFactory <IDuplexSessionChannel> (), "#cbf4");
            Assert.IsTrue(n.CanBuildChannelFactory <IRequestSessionChannel> (), "#cbf5");
        }
Ejemplo n.º 2
0
        public void MessageSecurityAndBindings4()
        {
            var n = new NetTcpBinding();

            n.Security.Mode = SecurityMode.Message;
            n.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;

            var bc = n.CreateBindingElements();

            Assert.AreEqual(4, bc.Count, "#bc1");
            Assert.AreEqual(typeof(TransactionFlowBindingElement), bc [0].GetType(), "#bc2");
            Assert.AreEqual(typeof(SymmetricSecurityBindingElement), bc [1].GetType(), "#bc3");
            Assert.AreEqual(typeof(BinaryMessageEncodingBindingElement), bc [2].GetType(), "#bc4");
            Assert.AreEqual(typeof(TcpTransportBindingElement), bc [3].GetType(), "#bc5");

            Assert.IsFalse(n.CanBuildChannelFactory <IRequestChannel> (), "#cbf1");
            Assert.IsFalse(n.CanBuildChannelFactory <IOutputChannel> (), "#cbf2");
            Assert.IsFalse(n.CanBuildChannelFactory <IDuplexChannel> (), "#cbf3");
            Assert.IsTrue(n.CanBuildChannelFactory <IDuplexSessionChannel> (), "#cbf4");
        }
Ejemplo n.º 3
0
        public void DefaultValues()
        {
            var n = new NetTcpBinding();

            Assert.AreEqual(HostNameComparisonMode.StrongWildcard, n.HostNameComparisonMode, "#1");
            Assert.AreEqual(10, n.ListenBacklog, "#2");
            Assert.AreEqual(false, n.PortSharingEnabled, "#3");

            var tr = n.CreateBindingElements().Find <TcpTransportBindingElement> ();

            Assert.IsNotNull(tr, "#tr1");
            Assert.AreEqual(false, tr.TeredoEnabled, "#tr2");
            Assert.AreEqual("net.tcp", tr.Scheme, "#tr3");

            Assert.IsFalse(n.TransactionFlow, "#4");
            var tx = n.CreateBindingElements().Find <TransactionFlowBindingElement> ();

            Assert.IsNotNull(tx, "#tx1");

            Assert.AreEqual(SecurityMode.Transport, n.Security.Mode, "#sec1");
            Assert.AreEqual(ProtectionLevel.EncryptAndSign, n.Security.Transport.ProtectionLevel, "#sec2");
            Assert.AreEqual(TcpClientCredentialType.Windows /*huh*/, n.Security.Transport.ClientCredentialType, "#sec3");

            var bc = n.CreateBindingElements();

            Assert.AreEqual(4, bc.Count, "#bc1");
            Assert.AreEqual(typeof(TransactionFlowBindingElement), bc [0].GetType(), "#bc2");
            Assert.AreEqual(typeof(BinaryMessageEncodingBindingElement), bc [1].GetType(), "#bc3");
            Assert.AreEqual(typeof(WindowsStreamSecurityBindingElement), bc [2].GetType(), "#bc4");
            Assert.AreEqual(typeof(TcpTransportBindingElement), bc [3].GetType(), "#bc5");

            Assert.IsFalse(n.CanBuildChannelFactory <IRequestChannel> (), "#cbf1");
            Assert.IsFalse(n.CanBuildChannelFactory <IOutputChannel> (), "#cbf2");
            Assert.IsFalse(n.CanBuildChannelFactory <IDuplexChannel> (), "#cbf3");
            Assert.IsTrue(n.CanBuildChannelFactory <IDuplexSessionChannel> (), "#cbf4");
        }