public void Open_Open_error() { var address = @"net.pipe://127.0.0.1/" + this.GetType().Name + MethodBase.GetCurrentMethod().Name; var serv = new Service(null); using (var host = new ServiceHost(serv, new Uri[] { new Uri(address) })) { var b = new NetNamedPipeBinding(); host.AddServiceEndpoint(typeof(IService), b, address); host.Open(); host.Open(); } }
public void LongNamePipe() { var address = @"net.pipe://127.0.0.1/1/test.test/testtestLongNameLongNameLongNameLongNameLongNameLongNameLongNameLongNameLongNamefd0286a60b9b4db18659-b715e5db5b3bd0286a6-0b9b-4db1-8659-b715e5db5b3b"; var serv = new Service(null); var b = new NetNamedPipeBinding(); using (var host = new ServiceHost(serv, new Uri[] { new Uri(address), })) { host.AddServiceEndpoint(typeof(IService), b, address); host.Open(); using (var f = new ChannelFactory<IService>(b)) { var c = f.CreateChannel(new EndpointAddress(address)); var result = c.DoWithParamsAndResult(":)", Guid.NewGuid()); Assert.AreEqual(2, result.d1); } } }
public void Open_2Endpoints_callsBoth() { var baseAddress = @"net.pipe://127.0.0.1/" + this.GetType().Name + MethodBase.GetCurrentMethod().Name; var serv = new Service(null); using (var host = new ServiceHost(serv, new Uri[] { new Uri(baseAddress) })) { var binding = new NetNamedPipeBinding(); host.AddServiceEndpoint(typeof(IService), binding, baseAddress + "/1"); host.AddServiceEndpoint(typeof(IService), binding, baseAddress + "/2"); host.Open(); using (var channelFatory = new ChannelFactory<IService>(binding)) { var c1 = channelFatory.CreateChannel(new EndpointAddress(baseAddress + "/1")); var c2 = channelFatory.CreateChannel(new EndpointAddress(baseAddress + "/2")); c1.DoWithParamsAndResult("", Guid.Empty); c2.DoWithParamsAndResult("", Guid.Empty); } } }
public void ServerAncClientEndpointBehavior() { var hook = new InvokesCounterBehaviour(); var address = @"net.pipe://127.0.0.1/test" + this.GetType().Name + "_" + MethodBase.GetCurrentMethod().Name; var serv = new Service(null); var host = new ServiceHost(serv, new Uri[] { new Uri(address), }); var b = new NetNamedPipeBinding(); var serverEndpoint = host.AddServiceEndpoint(typeof(IService), b, address); serverEndpoint.Behaviors.Add(hook); Assert.AreEqual(0, hook.Counter); host.Open(); Assert.AreEqual(3, hook.Counter); var f = new ChannelFactory<IService>(b); f.Endpoint.Behaviors.Add(hook); Assert.AreEqual(3, hook.Counter); var c = f.CreateChannel(new EndpointAddress(address)); Assert.AreEqual(6, hook.Counter); var result = c.DoWithParamsAndResult("", Guid.NewGuid()); host.Abort(); }
public void PipeICommuicationObject() { var address = @"net.pipe://127.0.0.1/test" + MethodBase.GetCurrentMethod().Name; var serv = new Service(null); var host = new ServiceHost(serv, new Uri(address)); var b = new NetNamedPipeBinding(); host.AddServiceEndpoint(typeof(IService), b, address); host.Open(); var f = new ChannelFactory<IService>(b); var c = f.CreateChannel(new EndpointAddress(address)); c.DoWithParamsAndResult(null, Guid.Empty); var obj = c as ICommunicationObject; var state = obj.State; Assert.AreEqual(CommunicationState.Opened, state); host.Close(); }
public void PipeChannel_openClose_fail() { var address = @"net.pipe://127.0.0.1/test" + MethodBase.GetCurrentMethod().Name; var b = new NetNamedPipeBinding(); var serv = new Service(null); var host = new ServiceHost(serv, new Uri(address)); host.AddServiceEndpoint(typeof(IService), b, address); host.Open(); var f = new ChannelFactory<IService>(b); var c = f.CreateChannel(new EndpointAddress(address)); c.DoWithParamsAndResult(null, Guid.Empty); host.Close(); Exception comminicationEx = null; try { c.DoWithParamsAndResult(null, Guid.Empty); } catch (Exception ex) { comminicationEx = ex; } var obj = c as ICommunicationObject; var state = obj.State; Assert.AreEqual(CommunicationState.Faulted, state); Assert.That(comminicationEx, new ExceptionTypeConstraint(typeof(CommunicationException))); }