2 // MonoTests.Remoting.GenericTest.cs
5 // Robert Jordan <robertj@gmx.net>
11 using System.Runtime.Remoting;
12 using System.Runtime.Remoting.Channels;
13 using System.Runtime.Remoting.Channels.Tcp;
14 using System.Runtime.Remoting.Channels.Http;
15 using System.Runtime.Remoting.Channels.Ipc;
16 using System.Threading;
17 using NUnit.Framework;
19 namespace MonoTests.Remoting
21 class Server <T> : MarshalByRefObject
29 public V Test2 <V> (V v)
41 public class GenericTest
45 public static void Test (string url)
48 Server <int> server = new Server <int> ();
49 RemotingServices.Marshal (server, "test");
52 Server <int> client = (Server <int>) RemotingServices.Connect (
53 typeof (Server <int>), url);
57 Assert.AreEqual ("hello", client.Test2 <string> ("hello"), "#01");
58 Assert.AreEqual (42, client.Test3 (42), "#02");
61 RemotingServices.Disconnect (server);
67 public void TestTcp ()
69 TcpChannel c = new TcpChannel (18181);
70 Helper.Test ("tcp://127.0.0.1:18181/test");
71 c.StopListening (null);
75 public void TestIpc ()
77 string portName = "ipc" + Guid.NewGuid ().ToString ("N");
78 IpcChannel c = new IpcChannel (portName);
79 // FIXME: the named pipe of the Win32 IpcServerChannel
80 // seems to require a sleep because the pipe is not
81 // ready immediately after creation.
83 Helper.Test ("ipc://" + portName + "/test");
84 c.StopListening (null);
88 [Ignore ("The SOAP formatter doesn't support generics.")]
89 // FIXME: change the SOAP formatter to throw on generic types
90 public void TestHttp ()
92 HttpChannel c = new HttpChannel (19191);
93 Helper.Test ("http://127.0.0.1:19191/test");
94 c.StopListening (null);