public void GetRealProxy () { TcpChannel chn = new TcpChannel (1241); ChannelServices.RegisterChannel (chn); try { RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap", WellKnownObjectMode.Singleton); MyProxy proxy = new MyProxy (typeof (MarshalObject), (MarshalByRefObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1241/MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap")); MarshalObject objRem = (MarshalObject) proxy.GetTransparentProxy (); RealProxy rp = RemotingServices.GetRealProxy (objRem); Assert ("#A12", rp != null); AssertEquals ("#A13", "MonoTests.System.Runtime.Remoting.RemotingServicesInternal.MyProxy", rp.GetType ().ToString ()); } finally { ChannelServices.UnregisterChannel (chn); } }
public void ExecuteMessage () { TcpChannel chn = new TcpChannel (1235); ChannelServices.RegisterChannel (chn); try { MarshalObject objMarshal = NewMarshalObject (); RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), objMarshal.Uri, WellKnownObjectMode.SingleCall); // use a proxy to catch the Message MyProxy proxy = new MyProxy (typeof (MarshalObject), (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1235/" + objMarshal.Uri)); MarshalObject objRem = (MarshalObject) proxy.GetTransparentProxy (); objRem.Method1 (); // Tests RemotingServices.GetMethodBaseFromMethodMessage() AssertEquals ("#A09", "Method1", proxy.MthBase.Name); Assert ("#A09.1", !proxy.IsMethodOverloaded); objRem.Method2 (); Assert ("#A09.2", proxy.IsMethodOverloaded); // Tests RemotingServices.ExecuteMessage(); // If ExecuteMessage does it job well, Method1 should be called 2 times AssertEquals ("#A10", 2, MarshalObject.Called); } finally { ChannelServices.UnregisterChannel (chn); } }