示例#1
0
        public void SendRequestTest()
        {
            string uri = "net.tcp://localhost:8889";

            // Open frontend
            Uri             listenUri = new Uri(uri);
            NetTcpBinding   binding   = new NetTcpBinding(SecurityMode.None);
            MockBrokerQueue queue     = new MockBrokerQueue();

            queue.DirectReply = true;
            DuplexFrontEnd target = new DuplexFrontEnd(listenUri, binding, null, queue, null, null);

            target.Open();

            MockWCFClient client = new MockWCFClient(binding, new EndpointAddress(uri));

            try
            {
                client.Calc(4);
            }
            catch (FaultException fe)
            {
                Assert.AreEqual(fe.Code.SubCode.Name, "DummyReply");
            }

            target.Close();
        }
示例#2
0
        public void SendRequestTestWithSecurity()
        {
            string uri = "net.tcp://localhost:8889";

            // Open frontend
            Uri                     listenUri = new Uri(uri);
            NetTcpBinding           binding   = new NetTcpBinding(SecurityMode.Transport);
            MockBrokerQueue         queue     = new MockBrokerQueue();
            MockBrokerAuthorization auth      = new MockBrokerAuthorization();

            queue.DirectReply = true;
            DuplexFrontEnd target = new DuplexFrontEnd(listenUri, binding, auth, queue);

            target.Open();

            MockWCFClient client = new MockWCFClient(binding, new EndpointAddress(uri));

            auth.Allow = true;
            try
            {
                client.Calc(4);
            }
            catch (FaultException fe)
            {
                Assert.AreEqual(fe.Code.SubCode.Name, "DummyReply");
            }

            auth.Allow = false;
            try
            {
                client.Calc(4);
            }
            catch (FaultException fe)
            {
                Assert.AreEqual(fe.Code.SubCode.Name, "AuthenticationFailure");
            }

            target.Close();
        }