f9ad75cd3ac4a05f55b984212b19982d795a576a
[mono.git] / mcs / class / System.Runtime.Remoting / Test / RemotingServicesTest.cs
1 //\r
2 // System.Runtime.Remoting.RemotingServices NUnit V2.0 test class\r
3 //\r
4 // Author Jean-Marc ANDRE (jean-marc.andre@polymtl.ca)\r
5 //\r
6 // ToDo: I didn't write test functions for the method not yep\r
7 // implemented by Mono\r
8 \r
9 using System;\r
10 using System.Collections;\r
11 using NUnit.Framework;\r
12 using System.Reflection;\r
13 using System.Runtime.Remoting;\r
14 using System.Threading;\r
15 using System.Runtime.Remoting.Activation;\r
16 using System.Runtime.Remoting.Messaging;\r
17 using System.Runtime.Remoting.Proxies;\r
18 using System.Runtime.Remoting.Channels;\r
19 using System.Runtime.Remoting.Channels.Tcp;\r
20 \r
21 namespace MonoTests.System.Runtime.Remoting.RemotingServicesInternal\r
22 {\r
23         // We need our own proxy to intercept messages to remote object\r
24         // and forward them using RemotingServices.ExecuteMessage\r
25         public class MyProxy : RealProxy\r
26         {\r
27                 MarshalByRefObject target;\r
28                 IMessageSink _sink;\r
29                 MethodBase _mthBase;\r
30                 bool methodOverloaded = false;\r
31 \r
32                 public MethodBase MthBase {\r
33                         get { return _mthBase; }\r
34                 }\r
35 \r
36                 public bool IsMethodOverloaded {\r
37                         get { return methodOverloaded; }\r
38                 }\r
39 \r
40                 public MyProxy (Type serverType, MarshalByRefObject target)\r
41                         : base (serverType)\r
42                 {\r
43                         this.target = target;\r
44 \r
45                         IChannel [] registeredChannels = ChannelServices.RegisteredChannels;\r
46                         string ObjectURI;\r
47 \r
48                         // A new IMessageSink chain has to be created\r
49                         // since the RemotingServices.GetEnvoyChainForProxy() is not yet\r
50                         // implemented.\r
51                         foreach (IChannel channel in registeredChannels) {\r
52                                 IChannelSender channelSender = channel as IChannelSender;\r
53                                 if (channelSender != null) {\r
54                                         _sink = (IMessageSink) channelSender.CreateMessageSink (RemotingServices.GetObjectUri (target), null, out ObjectURI);\r
55                                 }\r
56                         }\r
57 \r
58                 }\r
59 \r
60                 // Messages will be intercepted here and redirected\r
61                 // to another object.\r
62                 public override IMessage Invoke (IMessage msg)\r
63                 {\r
64                         try {\r
65                                 if (msg is IConstructionCallMessage) {\r
66                                         IActivator remActivator = (IActivator) RemotingServices.Connect (typeof (IActivator), "tcp://localhost:1234/RemoteActivationService.rem");\r
67                                         IConstructionReturnMessage crm = remActivator.Activate ((IConstructionCallMessage) msg);\r
68                                         return crm;\r
69                                 } else {\r
70                                         methodOverloaded = RemotingServices.IsMethodOverloaded ((IMethodMessage) msg);\r
71 \r
72                                         _mthBase = RemotingServices.GetMethodBaseFromMethodMessage ((IMethodMessage) msg);\r
73                                         MethodCallMessageWrapper mcm = new MethodCallMessageWrapper ((IMethodCallMessage) msg);\r
74                                         mcm.Uri = RemotingServices.GetObjectUri ((MarshalByRefObject) target);\r
75                                         MarshalByRefObject objRem = (MarshalByRefObject) Activator.CreateInstance (GetProxiedType ());\r
76                                         RemotingServices.ExecuteMessage ((MarshalByRefObject) objRem, (IMethodCallMessage) msg);\r
77                                         IMessage rtnMsg = null;\r
78 \r
79                                         try {\r
80                                                 rtnMsg = _sink.SyncProcessMessage (msg);\r
81                                         } catch (Exception e) {\r
82                                                 Console.WriteLine (e.Message);\r
83                                         }\r
84 \r
85                                         Console.WriteLine ("RR:" + rtnMsg);\r
86                                         return rtnMsg;\r
87                                 }\r
88                         } catch (Exception ex) {\r
89                                 Console.WriteLine (ex);\r
90                                 return null;\r
91                         }\r
92                 }\r
93         } // end MyProxy\r
94 \r
95         // This class is used to create "CAO"\r
96         public class MarshalObjectFactory : MarshalByRefObject\r
97         {\r
98                 public MarshalObject GetNewMarshalObject ()\r
99                 {\r
100                         return new MarshalObject ();\r
101                 }\r
102         }\r
103 \r
104         // A class used by the tests\r
105         public class MarshalObject : ContextBoundObject\r
106         {\r
107                 public MarshalObject ()\r
108                 {\r
109 \r
110                 }\r
111 \r
112                 public MarshalObject (int id, string uri)\r
113                 {\r
114                         this.id = id;\r
115                         this.uri = uri;\r
116                 }\r
117 \r
118                 public int Id {\r
119                         get { return id; }\r
120                         set { id = value; }\r
121                 }\r
122 \r
123                 public string Uri {\r
124                         get { return uri; }\r
125                 }\r
126 \r
127                 public void Method1 ()\r
128                 {\r
129                         _called++;\r
130                         methodOneWay = RemotingServices.IsOneWay (MethodBase.GetCurrentMethod ());\r
131                 }\r
132 \r
133                 public void Method2 ()\r
134                 {\r
135                         methodOneWay = RemotingServices.IsOneWay (MethodBase.GetCurrentMethod ());\r
136                 }\r
137 \r
138                 public void Method2 (int i)\r
139                 {\r
140                         methodOneWay = RemotingServices.IsOneWay (MethodBase.GetCurrentMethod ());\r
141                 }\r
142 \r
143                 [OneWay ()]\r
144                 public void Method3 ()\r
145                 {\r
146                         methodOneWay = RemotingServices.IsOneWay (MethodBase.GetCurrentMethod ());\r
147                 }\r
148 \r
149                 public static int Called {\r
150                         get { return _called; }\r
151                 }\r
152 \r
153                 public static bool IsMethodOneWay {\r
154                         get { return methodOneWay; }\r
155                 }\r
156 \r
157                 private static int _called;\r
158                 private int id = 0;\r
159                 private string uri;\r
160                 private static bool methodOneWay = false;\r
161         }\r
162 \r
163         // Another class used by the tests\r
164         public class DerivedMarshalObject : MarshalObject\r
165         {\r
166                 public DerivedMarshalObject () { }\r
167 \r
168                 public DerivedMarshalObject (int id, string uri) : base (id, uri) { }\r
169         }\r
170 \r
171         interface A\r
172         {\r
173         }\r
174 \r
175         interface B : A\r
176         {\r
177         }\r
178 \r
179         public class CC : MarshalByRefObject\r
180         {\r
181         }\r
182 \r
183         public class DD : MarshalByRefObject\r
184         {\r
185         }\r
186 \r
187 \r
188 } // namespace MonoTests.System.Runtime.Remoting.RemotingServicesInternal\r
189 \r
190 namespace MonoTests.Remoting\r
191 {\r
192         using MonoTests.System.Runtime.Remoting.RemotingServicesInternal;\r
193 \r
194         // The main test class\r
195         [TestFixture]\r
196         public class RemotingServicesTest : Assertion\r
197         {\r
198                 private static int MarshalObjectId = 0;\r
199 \r
200                 public RemotingServicesTest ()\r
201                 {\r
202                         MarshalObjectId = 0;\r
203                 }\r
204 \r
205                 // Helper function that create a new\r
206                 // MarshalObject with an unique ID\r
207                 private static MarshalObject NewMarshalObject ()\r
208                 {\r
209                         string uri = "MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject" + MarshalObjectId.ToString ();\r
210                         MarshalObject objMarshal = new MarshalObject (MarshalObjectId, uri);\r
211 \r
212                         MarshalObjectId++;\r
213 \r
214                         return objMarshal;\r
215                 }\r
216 \r
217                 // Another helper function\r
218                 private DerivedMarshalObject NewDerivedMarshalObject ()\r
219                 {\r
220                         string uri = "MonoTests.System.Runtime.Remoting.RemotingServicesTest.DerivedMarshalObject" + MarshalObjectId.ToString ();\r
221                         DerivedMarshalObject objMarshal = new DerivedMarshalObject (MarshalObjectId, uri);\r
222 \r
223                         MarshalObjectId++;\r
224 \r
225                         return objMarshal;\r
226                 }\r
227 \r
228                 // The two folling method test RemotingServices.Marshal()\r
229                 [Test]\r
230                 public void Marshal1 ()\r
231                 {\r
232 \r
233                         MarshalObject objMarshal = NewMarshalObject ();\r
234                         ObjRef objRef = RemotingServices.Marshal (objMarshal);\r
235 \r
236                         Assert ("#A01", objRef.URI != null);\r
237 \r
238                         MarshalObject objRem = (MarshalObject) RemotingServices.Unmarshal (objRef);\r
239                         AssertEquals ("#A02", objMarshal.Id, objRem.Id);\r
240 \r
241                         objRem.Id = 2;\r
242                         AssertEquals ("#A03", objMarshal.Id, objRem.Id);\r
243 \r
244                         // TODO: uncomment when RemotingServices.Disconnect is implemented\r
245                         //RemotingServices.Disconnect(objMarshal);\r
246 \r
247                         objMarshal = NewMarshalObject ();\r
248 \r
249                         objRef = RemotingServices.Marshal (objMarshal, objMarshal.Uri);\r
250 \r
251                         Assert ("#A04", objRef.URI.EndsWith (objMarshal.Uri));\r
252                         // TODO: uncomment when RemotingServices.Disconnect is implemented\r
253                         //RemotingServices.Disconnect(objMarshal);\r
254                 }\r
255 \r
256                 [Test]\r
257                 public void Marshal2 ()\r
258                 {\r
259                         DerivedMarshalObject derivedObjMarshal = NewDerivedMarshalObject ();\r
260 \r
261                         ObjRef objRef = RemotingServices.Marshal (derivedObjMarshal, derivedObjMarshal.Uri, typeof (MarshalObject));\r
262 \r
263                         // Check that the type of the marshaled object is MarshalObject\r
264                         Assert ("#A05", objRef.TypeInfo.TypeName.StartsWith ((typeof (MarshalObject)).ToString ()));\r
265 \r
266                         // TODO: uncomment when RemotingServices.Disconnect is implemented\r
267                         //RemotingServices.Disconnect(derivedObjMarshal);\r
268                 }\r
269 \r
270                 // Tests RemotingServices.GetObjectUri()\r
271                 [Test]\r
272                 public void GetObjectUri ()\r
273                 {\r
274                         MarshalObject objMarshal = NewMarshalObject ();\r
275 \r
276                         Assert ("#A06", RemotingServices.GetObjectUri (objMarshal) == null);\r
277 \r
278                         RemotingServices.Marshal (objMarshal);\r
279 \r
280                         Assert ("#A07", RemotingServices.GetObjectUri (objMarshal) != null);\r
281                         // TODO: uncomment when RemotingServices.Disconnect is implemented\r
282                         //RemotingServices.Disconnect(objMarshal);\r
283                 }\r
284 \r
285                 // Tests RemotingServices.Connect\r
286                 [Test]\r
287                 public void Connect ()\r
288                 {\r
289                         MarshalObject objMarshal = NewMarshalObject ();\r
290 \r
291                         IDictionary props = new Hashtable ();\r
292                         props ["name"] = objMarshal.Uri;\r
293                         props ["port"] = 1236;\r
294                         TcpChannel chn = new TcpChannel (props, null, null);\r
295                         ChannelServices.RegisterChannel (chn);\r
296 \r
297                         try {\r
298                                 RemotingServices.Marshal (objMarshal, objMarshal.Uri);\r
299                                 MarshalObject objRem = (MarshalObject) RemotingServices.Connect (typeof (MarshalObject), "tcp://localhost:1236/" + objMarshal.Uri);\r
300                                 Assert ("#A08", RemotingServices.IsTransparentProxy (objRem));\r
301                         } finally {\r
302                                 ChannelServices.UnregisterChannel (chn);\r
303                                 RemotingServices.Disconnect (objMarshal);\r
304                         }\r
305                 }\r
306 \r
307                 // Tests RemotingServices.Marshal()\r
308                 [Test]\r
309                 public void MarshalThrowException ()\r
310                 {\r
311                         MarshalObject objMarshal = NewMarshalObject ();\r
312 \r
313                         IDictionary props = new Hashtable ();\r
314                         props ["name"] = objMarshal.Uri;\r
315                         props ["port"] = 1237;\r
316                         TcpChannel chn = new TcpChannel (props, null, null);\r
317                         ChannelServices.RegisterChannel (chn);\r
318 \r
319                         try {\r
320                                 RemotingServices.Marshal (objMarshal, objMarshal.Uri);\r
321                                 MarshalObject objRem = (MarshalObject) RemotingServices.Connect (typeof (MarshalObject), "tcp://localhost:1237/" + objMarshal.Uri);\r
322                                 // This line should throw a RemotingException\r
323                                 // It is forbidden to export an object which is not\r
324                                 // a real object\r
325                                 try {\r
326                                         RemotingServices.Marshal (objRem, objMarshal.Uri);\r
327                                         Fail ("#1");\r
328                                 } catch (RemotingException e) {\r
329                                 }\r
330                         } finally {\r
331                                 ChannelServices.UnregisterChannel (chn);\r
332 \r
333                                 // TODO: uncomment when RemotingServices.Disconnect is implemented\r
334                                 //RemotingServices.Disconnect(objMarshal);\r
335                         }\r
336                 }\r
337 \r
338                 // Tests RemotingServices.ExecuteMessage()\r
339                 // also tests GetMethodBaseFromMessage()\r
340                 // IsMethodOverloaded()\r
341                 [Test]\r
342                 public void ExecuteMessage ()\r
343                 {\r
344                         TcpChannel chn = new TcpChannel (1235);\r
345                         ChannelServices.RegisterChannel (chn);\r
346                         try {\r
347                                 MarshalObject objMarshal = NewMarshalObject ();\r
348                                 RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), objMarshal.Uri, WellKnownObjectMode.SingleCall);\r
349 \r
350                                 // use a proxy to catch the Message\r
351                                 MyProxy proxy = new MyProxy (typeof (MarshalObject), (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1235/" + objMarshal.Uri));\r
352 \r
353                                 MarshalObject objRem = (MarshalObject) proxy.GetTransparentProxy ();\r
354 \r
355                                 objRem.Method1 ();\r
356 \r
357                                 // Tests RemotingServices.GetMethodBaseFromMethodMessage()\r
358                                 AssertEquals ("#A09", "Method1", proxy.MthBase.Name);\r
359                                 Assert ("#A09.1", !proxy.IsMethodOverloaded);\r
360 \r
361                                 objRem.Method2 ();\r
362                                 Assert ("#A09.2", proxy.IsMethodOverloaded);\r
363 \r
364                                 // Tests RemotingServices.ExecuteMessage();\r
365                                 // If ExecuteMessage does it job well, Method1 should be called 2 times\r
366                                 AssertEquals ("#A10", 2, MarshalObject.Called);\r
367                         } finally {\r
368                                 ChannelServices.UnregisterChannel (chn);\r
369                         }\r
370                 }\r
371 \r
372                 // Tests the IsOneWay method\r
373                 [Test]\r
374                 public void IsOneWay ()\r
375                 {\r
376                         TcpChannel chn = new TcpChannel (1238);\r
377                         ChannelServices.RegisterChannel (chn);\r
378                         try {\r
379                                 RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "MarshalObject.rem", WellKnownObjectMode.Singleton);\r
380 \r
381                                 MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1238/MarshalObject.rem");\r
382 \r
383                                 Assert ("#A10.1", RemotingServices.IsTransparentProxy (objRem));\r
384 \r
385                                 objRem.Method1 ();\r
386                                 Thread.Sleep (20);\r
387                                 Assert ("#A10.2", !MarshalObject.IsMethodOneWay);\r
388                                 objRem.Method3 ();\r
389                                 Thread.Sleep (20);\r
390                                 Assert ("#A10.3", MarshalObject.IsMethodOneWay);\r
391                         } finally {\r
392                                 ChannelServices.UnregisterChannel (chn);\r
393                         }\r
394                 }\r
395 \r
396                 [Test]\r
397                 public void GetObjRefForProxy ()\r
398                 {\r
399                         TcpChannel chn = new TcpChannel (1239);\r
400                         ChannelServices.RegisterChannel (chn);\r
401                         try {\r
402                                 // Register le factory as a SAO\r
403                                 RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObjectFactory), "MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap", WellKnownObjectMode.Singleton);\r
404 \r
405                                 MarshalObjectFactory objFactory = (MarshalObjectFactory) Activator.GetObject (typeof (MarshalObjectFactory), "tcp://localhost:1239/MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap");\r
406 \r
407                                 // Get a new "CAO"\r
408                                 MarshalObject objRem = objFactory.GetNewMarshalObject ();\r
409 \r
410                                 ObjRef objRefRem = RemotingServices.GetObjRefForProxy ((MarshalByRefObject) objRem);\r
411 \r
412                                 Assert ("#A11", objRefRem != null);\r
413                         } finally {\r
414                                 ChannelServices.UnregisterChannel (chn);\r
415                         }\r
416                 }\r
417 \r
418                 // Tests GetRealProxy\r
419                 [Test]\r
420                 public void GetRealProxy ()\r
421                 {\r
422                         TcpChannel chn = new TcpChannel (1241);\r
423                         ChannelServices.RegisterChannel (chn);\r
424                         try {\r
425                                 RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap", WellKnownObjectMode.Singleton);\r
426 \r
427                                 MyProxy proxy = new MyProxy (typeof (MarshalObject), (MarshalByRefObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1241/MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap"));\r
428                                 MarshalObject objRem = (MarshalObject) proxy.GetTransparentProxy ();\r
429 \r
430                                 RealProxy rp = RemotingServices.GetRealProxy (objRem);\r
431 \r
432                                 Assert ("#A12", rp != null);\r
433                                 AssertEquals ("#A13", "MonoTests.System.Runtime.Remoting.RemotingServicesInternal.MyProxy", rp.GetType ().ToString ());\r
434                         } finally {\r
435                                 ChannelServices.UnregisterChannel (chn);\r
436                         }\r
437                 }\r
438 \r
439                 // Tests SetObjectUriForMarshal()\r
440                 [Test]\r
441                 public void SetObjectUriForMarshal ()\r
442                 {\r
443                         TcpChannel chn = new TcpChannel (1242);\r
444                         ChannelServices.RegisterChannel (chn);\r
445                         try {\r
446                                 MarshalObject objRem = NewMarshalObject ();\r
447                                 RemotingServices.SetObjectUriForMarshal (objRem, objRem.Uri);\r
448                                 RemotingServices.Marshal (objRem);\r
449 \r
450                                 objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1242/" + objRem.Uri);\r
451                                 Assert ("#A14", objRem != null);\r
452                         } finally {\r
453                                 ChannelServices.UnregisterChannel (chn);\r
454                         }\r
455 \r
456                 }\r
457 \r
458                 // Tests GetServeurTypeForUri()\r
459                 [Test]\r
460                 public void GetServeurTypeForUri ()\r
461                 {\r
462                         TcpChannel chn = new TcpChannel (1243);\r
463                         Type type = typeof (MarshalObject);\r
464                         ChannelServices.RegisterChannel (chn);\r
465                         try {\r
466                                 MarshalObject objRem = NewMarshalObject ();\r
467                                 RemotingServices.SetObjectUriForMarshal (objRem, objRem.Uri);\r
468                                 RemotingServices.Marshal (objRem);\r
469 \r
470                                 Type typeRem = RemotingServices.GetServerTypeForUri (RemotingServices.GetObjectUri (objRem));\r
471                                 AssertEquals ("#A15", type, typeRem);\r
472                         } finally {\r
473                                 ChannelServices.UnregisterChannel (chn);\r
474                         }\r
475                 }\r
476 \r
477                 // Tests IsObjectOutOfDomain\r
478                 // Tests IsObjectOutOfContext\r
479                 [Test]\r
480                 [Category ("NotWorking")]\r
481                 public void IsObjectOutOf ()\r
482                 {\r
483                         TcpChannel chn = new TcpChannel (1245);\r
484                         ChannelServices.RegisterChannel (chn);\r
485                         try {\r
486                                 RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "MarshalObject2.rem", WellKnownObjectMode.Singleton);\r
487 \r
488                                 MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1245/MarshalObject2.rem");\r
489 \r
490                                 Assert ("#A16", RemotingServices.IsObjectOutOfAppDomain (objRem));\r
491                                 Assert ("#A17", RemotingServices.IsObjectOutOfContext (objRem));\r
492 \r
493                                 MarshalObject objMarshal = new MarshalObject ();\r
494                                 Assert ("#A18", !RemotingServices.IsObjectOutOfAppDomain (objMarshal));\r
495                                 Assert ("#A19", !RemotingServices.IsObjectOutOfContext (objMarshal));\r
496                         } finally {\r
497                                 ChannelServices.UnregisterChannel (chn);\r
498                         }\r
499                 }\r
500 \r
501                 [Test]\r
502                 public void ApplicationNameTest ()\r
503                 {\r
504                         RemotingConfiguration.ApplicationName = "app";\r
505                         TcpChannel chn = new TcpChannel (1246);\r
506                         ChannelServices.RegisterChannel (chn);\r
507                         try {\r
508                                 RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "obj3.rem", WellKnownObjectMode.Singleton);\r
509 \r
510                                 MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1246/app/obj3.rem");\r
511                                 MarshalObject objRem2 = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1246/obj3.rem");\r
512 \r
513                                 Assert ("#AN1", RemotingServices.IsTransparentProxy (objRem));\r
514                                 Assert ("#AN2", RemotingServices.IsTransparentProxy (objRem2));\r
515 \r
516                                 AssertNotNull ("#AN3", RemotingServices.GetServerTypeForUri ("obj3.rem"));\r
517                                 AssertNotNull ("#AN4", RemotingServices.GetServerTypeForUri ("/app/obj3.rem"));\r
518                                 AssertNull ("#AN5", RemotingServices.GetServerTypeForUri ("//app/obj3.rem"));\r
519                                 AssertNull ("#AN6", RemotingServices.GetServerTypeForUri ("app/obj3.rem"));\r
520                                 AssertNull ("#AN7", RemotingServices.GetServerTypeForUri ("/whatever/obj3.rem"));\r
521                                 AssertNotNull ("#AN8", RemotingServices.GetServerTypeForUri ("/obj3.rem"));\r
522                                 AssertNull ("#AN9", RemotingServices.GetServerTypeForUri ("//obj3.rem"));\r
523                         } finally {\r
524                                 ChannelServices.UnregisterChannel (chn);\r
525                         }\r
526                 }\r
527 \r
528                 [Test]\r
529                 public void GetObjectWithChannelDataTest ()\r
530                 {\r
531                         TcpChannel chn = new TcpChannel (1247);\r
532                         ChannelServices.RegisterChannel (chn);\r
533                         try {\r
534                                 RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "getobjectwithchanneldata.rem", WellKnownObjectMode.Singleton);\r
535 \r
536                                 string channelData = "test";\r
537                                 AssertNotNull ("#01", Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1247/getobjectwithchanneldata.rem", channelData));\r
538                         } finally {\r
539                                 ChannelServices.UnregisterChannel (chn);\r
540                         }\r
541                 }\r
542 \r
543                 [Test]\r
544                 [Ignore ("We cannot test RemotingConfiguration.Configure() because it keeps channels registered. If we really need to test it, do it as a standalone case")]\r
545                 public void ConnectProxyCast ()\r
546                 {\r
547                         object o;\r
548                         RemotingConfiguration.Configure (null);\r
549 \r
550                         o = RemotingServices.Connect (typeof (MarshalByRefObject), "tcp://localhost:3434/ff1.rem");\r
551                         Assert ("#m1", o is DD);\r
552                         Assert ("#m2", o is A);\r
553                         Assert ("#m3", o is B);\r
554                         Assert ("#m4", !(o is CC));\r
555 \r
556                         o = RemotingServices.Connect (typeof (A), "tcp://localhost:3434/ff3.rem");\r
557                         Assert ("#a1", o is DD);\r
558                         Assert ("#a2", o is A);\r
559                         Assert ("#a3", o is B);\r
560                         Assert ("#a4", !(o is CC));\r
561 \r
562                         o = RemotingServices.Connect (typeof (DD), "tcp://localhost:3434/ff4.rem");\r
563                         Assert ("#d1", o is DD);\r
564                         Assert ("#d2", o is A);\r
565                         Assert ("#d3", o is B);\r
566                         Assert ("#d4", !(o is CC));\r
567 \r
568                         o = RemotingServices.Connect (typeof (CC), "tcp://localhost:3434/ff5.rem");\r
569                         Assert ("#c1", !(o is DD));\r
570                         Assert ("#c2", o is A);\r
571                         Assert ("#c3", o is B);\r
572                         Assert ("#c4", o is CC);\r
573                 }\r
574                 // Don't add any tests that must create channels\r
575                 // after ConnectProxyCast (), because this test calls\r
576                 // RemotingConfiguration.Configure ().\r
577         } // end class RemotingServicesTest\r
578 } // end of namespace MonoTests.Remoting\r