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); } }
public void ExecuteMessage() { var port = NetworkHelpers.FindFreePort(); TcpChannel chn = new TcpChannel(port); 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:{port}/" + objMarshal.Uri)); MarshalObject objRem = (MarshalObject)proxy.GetTransparentProxy(); objRem.Method1(); // Tests RemotingServices.GetMethodBaseFromMethodMessage() Assert.AreEqual("Method1", proxy.MthBase.Name, "#A09"); Assert.IsFalse(proxy.IsMethodOverloaded, "#A09.1"); objRem.Method2(); Assert.IsTrue(proxy.IsMethodOverloaded, "#A09.2"); // Tests RemotingServices.ExecuteMessage(); // If ExecuteMessage does it job well, Method1 should be called 2 times Assert.AreEqual(2, MarshalObject.Called, "#A10"); } finally { ChannelServices.UnregisterChannel(chn); } }