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 [Ignore ("https://bugzilla.xamarin.com/show_bug.cgi?id=36634")]
32 public void Bug609381 ()
34 string portName = "ipc" + Guid.NewGuid ().ToString ("N");
35 string objUri = "ipcserver609381.rem";
36 string url = String.Format ("ipc://{0}/{1}", portName, objUri);
38 IpcChannel serverChannel = new IpcChannel (portName);
39 ChannelServices.RegisterChannel (serverChannel);
41 RemotingServices.Marshal (new Server (), objUri);
43 Server client = (Server) RemotingServices.Connect (typeof (Server), url);
45 int count = 10 * 1024 * 1024;
46 byte[] sendBuf = new byte[count];
47 sendBuf [sendBuf.Length - 1] = 41;
49 byte[] recvBuf = client.Send (sendBuf);
51 Assert.IsNotNull (recvBuf);
52 Assert.AreNotSame (sendBuf, recvBuf);
53 Assert.AreEqual (count, recvBuf.Length);
54 Assert.AreEqual (42, recvBuf [recvBuf.Length - 1]);
59 ChannelServices.UnregisterChannel (serverChannel);
62 class Server : MarshalByRefObject
64 public byte[] Send (byte[] payload)
66 payload [payload.Length - 1]++;
72 public void TestCtor2 ()
74 string channelName = Guid.NewGuid ().ToString ("N");
75 string portName = "ipc" + Guid.NewGuid ().ToString ("N");
76 string url = String.Format ("ipc://{0}/server.rem", portName);
78 IpcServerChannel chan = new IpcServerChannel (channelName, portName);
79 string[] uris = chan.GetUrlsForUri ("server.rem");
80 Assert.IsNotNull (uris);
81 Assert.Greater (uris.Length, 0);
84 foreach (string s in uris) {
90 Assert.IsTrue (found);
94 public void TestCtor3 ()
96 string portName = "ipc" + Guid.NewGuid ().ToString ("N");
97 string url = String.Format ("ipc://{0}/server.rem", portName);
99 Hashtable props = new Hashtable ();
100 props ["portName"] = portName;
101 IpcChannel chan = new IpcChannel (props, null, null);
102 string[] uris = chan.GetUrlsForUri ("server.rem");
103 Assert.IsNotNull (uris);
104 Assert.Greater (uris.Length, 0);
107 foreach (string s in uris) {
113 Assert.IsTrue (found);