2 // MonoTests.Remoting.IpcChannelTests.cs
5 // Robert Jordan (robertj@gmx.net)
10 using System.Collections;
11 using System.Runtime.Remoting;
12 using System.Runtime.Remoting.Channels;
13 using System.Runtime.Remoting.Channels.Ipc;
14 using NUnit.Framework;
16 namespace MonoTests.Remoting
19 public class IpcChannelTest
22 public void Bug81653 ()
24 IpcClientChannel c = new IpcClientChannel ();
25 ChannelDataStore cd = new ChannelDataStore (new string[] { "foo" });
27 c.CreateMessageSink (null, cd, out objectUri);
31 public void Bug609381 ()
33 string portName = "ipc" + Guid.NewGuid ().ToString ("N");
34 string objUri = "ipcserver609381.rem";
35 string url = String.Format ("ipc://{0}/{1}", portName, objUri);
37 IpcChannel serverChannel = new IpcChannel (portName);
38 ChannelServices.RegisterChannel (serverChannel);
40 RemotingServices.Marshal (new Server (), objUri);
42 Server client = (Server) RemotingServices.Connect (typeof (Server), url);
44 int count = 10 * 1024 * 1024;
45 byte[] sendBuf = new byte[count];
46 sendBuf [sendBuf.Length - 1] = 41;
48 byte[] recvBuf = client.Send (sendBuf);
50 Assert.IsNotNull (recvBuf);
51 Assert.AreNotSame (sendBuf, recvBuf);
52 Assert.AreEqual (count, recvBuf.Length);
53 Assert.AreEqual (42, recvBuf [recvBuf.Length - 1]);
58 ChannelServices.UnregisterChannel (serverChannel);
61 class Server : MarshalByRefObject
63 public byte[] Send (byte[] payload)
65 payload [payload.Length - 1]++;
71 public void TestCtor2 ()
73 string channelName = Guid.NewGuid ().ToString ("N");
74 string portName = "ipc" + Guid.NewGuid ().ToString ("N");
75 string url = String.Format ("ipc://{0}/server.rem", portName);
77 IpcServerChannel chan = new IpcServerChannel (channelName, portName);
78 string[] uris = chan.GetUrlsForUri ("server.rem");
79 Assert.IsNotNull (uris);
80 AssertHelper.Greater (uris.Length, 0);
83 foreach (string s in uris) {
89 Assert.IsTrue (found);
93 public void TestCtor3 ()
95 string portName = "ipc" + Guid.NewGuid ().ToString ("N");
96 string url = String.Format ("ipc://{0}/server.rem", portName);
98 Hashtable props = new Hashtable ();
99 props ["portName"] = portName;
100 IpcChannel chan = new IpcChannel (props, null, null);
101 string[] uris = chan.GetUrlsForUri ("server.rem");
102 Assert.IsNotNull (uris);
103 AssertHelper.Greater (uris.Length, 0);
106 foreach (string s in uris) {
112 Assert.IsTrue (found);