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