public void ServerAncClientExceptionsEndpointBehavior()
        {
            var hook = new ExceptionsEndpointBehaviour();
            var address = @"net.pipe://127.0.0.1/test" + this.GetType().Name + "_" + MethodBase.GetCurrentMethod().Name;
            var serv = new ExceptionService();
            using (var host = new ServiceHost(serv, new Uri[] { new Uri(address), }))
            {
                var b = new NetNamedPipeBinding();
                var serverEndpoint = host.AddServiceEndpoint(typeof(IExceptionService), b, address);
                serverEndpoint.Behaviors.Add(hook);

                host.Open();

                var f = new ChannelFactory<IExceptionService>(b);
                f.Endpoint.Behaviors.Add(hook);

                var c = f.CreateChannel(new EndpointAddress(address));

                try
                {
                    c.DoException("message");
                }
                catch (InvalidOperationException ex)
                {
                    StringAssert.AreEqualIgnoringCase("message", ex.Message);
                }
                host.Abort();
            }
        }
Example #2
0
        public void ServerAndClientExceptions()
        {
            var address = @"net.pipe://127.0.0.1/test" + this.GetType().Name + "_" + MethodBase.GetCurrentMethod().Name;
            var serv = new ExceptionService();
            using (var host = new NDceRpc.ServiceModel.ServiceHost(serv, new Uri[] {new Uri(address),}))
            {
                var b = new NDceRpc.ServiceModel.NetNamedPipeBinding();
                host.AddServiceEndpoint(typeof(IExceptionService), b, address);
                host.Open();
                var f = new NDceRpc.ServiceModel.ChannelFactory<IExceptionService>(b);
                var c = f.CreateChannel(new NDceRpc.ServiceModel.EndpointAddress(address));

                try
                {
                    c.DoException("message");
                }
                catch (Exception ex)
                {
                    Assert.IsInstanceOf<NDceRpc.ServiceModel.FaultException>(ex);
                }
                host.Abort();
            }
        }
        public void ServerAndClientExceptions()
        {
            var address = @"net.pipe://127.0.0.1/test" + this.GetType().Name + "_" + MethodBase.GetCurrentMethod().Name;
            var serv    = new ExceptionService();

            using (var host = new NDceRpc.ServiceModel.ServiceHost(serv, new Uri[] { new Uri(address), }))
            {
                var b = new NDceRpc.ServiceModel.NetNamedPipeBinding();
                host.AddServiceEndpoint(typeof(IExceptionService), b, address);
                host.Open();
                var f = new NDceRpc.ServiceModel.ChannelFactory <IExceptionService>(b);
                var c = f.CreateChannel(new NDceRpc.ServiceModel.EndpointAddress(address));

                try
                {
                    c.DoException("message");
                }
                catch (Exception ex)
                {
                    Assert.IsInstanceOf <NDceRpc.ServiceModel.FaultException>(ex);
                }
                host.Abort();
            }
        }