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(); } }
public void ServerAncClientExceptions() { 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(); host.AddServiceEndpoint(typeof(IExceptionService), b, address); host.Open(); var f = new ChannelFactory<IExceptionService>(b); var c = f.CreateChannel(new EndpointAddress(address)); try { c.DoException("message"); } catch (Exception ex) { Assert.IsInstanceOf<FaultException>(ex); } host.Abort(); } }
public void ServerAncClientExceptions() { 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(); host.AddServiceEndpoint(typeof(IExceptionService), b, address); host.Open(); var f = new ChannelFactory <IExceptionService>(b); var c = f.CreateChannel(new EndpointAddress(address)); try { c.DoException("message"); } catch (Exception ex) { Assert.IsInstanceOf <FaultException>(ex); } host.Abort(); } }