4 using System
.Collections
;
5 using System
.Runtime
.Remoting
;
6 using System
.Runtime
.Remoting
.Channels
;
7 using System
.Runtime
.Remoting
.Channels
.Http
;
10 namespace MonoTests
.Remoting
.Http
12 //Test for Bug 324362 - SoapFormatter cannot deserialize the same MBR twice
14 public class Bug324362
17 // [Category ("NotWorking")] // the assertion fails, and if it's removed, there's an exception
18 [Ignore ("This test somehow keeps http channel registered and then blocks any further http tests working. This also happens under .NET, so this test itself is wrong with nunit 2.4.8.")]
21 new HttpChannel (8086);
22 RemotingServices
.Marshal (new Service (), "test");
24 Service remObj
= (Service
) RemotingServices
.Connect (
25 typeof (Service
), "http://localhost:8086/test");
28 remObj
.Test (out list
);
29 // it's of type 'ObjRef' instead of 'Service':
30 Assert
.IsTrue (list
[0] is Service
);
33 remObj
.Test (out array
);
36 public class Service
: MarshalByRefObject
38 public Service
Test (out Service
[] a
)
40 Service obj
= new Service ();
41 a
= new Service
[] { obj }
;
43 // return null or return otherObj works
46 public Service
Test (out ArrayList a
)
49 Service obj
= new Service ();
52 // return null or return otherObj works
57 //Bug 321420 - SoapReader fails to deserialize some method calls
59 public class Bug321420
: MarshalByRefObject
63 public void Method (string p1
, string p2
)
70 channel
= new HttpChannel (3344);
71 ChannelServices
.RegisterChannel (channel
);
72 RemotingConfiguration
.RegisterWellKnownServiceType
73 (typeof (Bug321420
),"Server.soap", WellKnownObjectMode
.Singleton
);
75 Bug321420 s
= (Bug321420
) Activator
.GetObject (typeof
76 (Bug321420
), "http://localhost:3344/Server.soap");
78 // this works: s.Method ("a", "b");
86 ChannelServices
.UnregisterChannel (channel
);
90 //Bug 315570 - Remoting over HTTP fails when returning a null reference.
92 public class Bug315570
97 [Ignore ("This test somehow keeps http channel registered and then blocks any further http tests working. This also happens under .NET, so this test itself is wrong with nunit 2.4.8.")]
100 Foo foo
= (Foo
) Activator
.GetObject (typeof (Foo
),
101 "http://localhost:4321/Test");
103 Bar bar
= foo
.Login ();
111 AppDomain domain
= BaseCallTest
.CreateDomain ("testdomain");
112 server
= (Server
) domain
.CreateInstanceAndUnwrap
113 (typeof (Server
).Assembly
.FullName
, typeof (Server
).FullName
);
117 [TestFixtureTearDown
]
123 public class Foo
: MarshalByRefObject
131 public class Bar
: MarshalByRefObject
133 public void Foobar ()
135 // Console.WriteLine("Bar::foo()");
139 public class Server
: MarshalByRefObject
145 c
= new HttpChannel (4321);
146 ChannelServices
.RegisterChannel (c
);
148 Type t
= typeof(Foo
);
149 RemotingConfiguration
.RegisterWellKnownServiceType (t
, "Test",
150 WellKnownObjectMode
.SingleCall
);
155 c
.StopListening (null);
156 ChannelServices
.UnregisterChannel (c
);
161 //Bug 315170 - exception thrown in remoting if interface parameter names differ from the impelmentation method parameter names
163 public class Bug315170
171 channel
= new HttpChannel (0);
173 ChannelServices
.RegisterChannel (channel
);
174 MarshalByRefObject obj
= (MarshalByRefObject
) RemotingServices
.Connect (
176 "http://localhost:60000/MyEndPoint");
177 IFactorial cal
= (IFactorial
) obj
;
178 Assert
.AreEqual (cal
.CalculateFactorial (4), 24);
180 ChannelServices
.UnregisterChannel (channel
);
187 AppDomain domain
= BaseCallTest
.CreateDomain ("testdomain");
188 server
= (Server
) domain
.CreateInstanceAndUnwrap
189 (typeof (Server
).Assembly
.FullName
, typeof (Server
).FullName
);
193 [TestFixtureTearDown
]
198 ChannelServices
.UnregisterChannel (channel
);
201 public interface IFactorial
203 // With this line everything works
204 //ulong CalculateFactorial(uint a);
205 // With this line it doesn't
206 ulong CalculateFactorial(uint b
);
210 public class Server
: MarshalByRefObject
216 c
= new HttpChannel (60000);
217 ChannelServices
.RegisterChannel (c
);
219 Type t
= typeof(Calculator
);
220 RemotingConfiguration
.RegisterWellKnownServiceType (t
, "MyEndPoint",
221 WellKnownObjectMode
.Singleton
);
226 c
.StopListening (null);
227 ChannelServices
.UnregisterChannel (c
);
231 public class Calculator
: MarshalByRefObject
, IFactorial
233 public ulong CalculateFactorial (uint a
)
236 for (uint i
=1 ; i
<=a
; i
++)