* ActivationTests.cs: New tests.
authorLluis Sanchez <lluis@novell.com>
Wed, 23 Jun 2004 10:25:15 +0000 (10:25 -0000)
committerLluis Sanchez <lluis@novell.com>
Wed, 23 Jun 2004 10:25:15 +0000 (10:25 -0000)
* BaseCalls.cs, CallSeq.cs: Use Assert instead of the deprecated Assertion.

svn path=/trunk/mcs/; revision=30173

mcs/class/System.Runtime.Remoting/Test/ActivationTests.cs [new file with mode: 0644]
mcs/class/System.Runtime.Remoting/Test/BaseCalls.cs
mcs/class/System.Runtime.Remoting/Test/CallSeq.cs
mcs/class/System.Runtime.Remoting/Test/ChangeLog

diff --git a/mcs/class/System.Runtime.Remoting/Test/ActivationTests.cs b/mcs/class/System.Runtime.Remoting/Test/ActivationTests.cs
new file mode 100644 (file)
index 0000000..b7dfbd8
--- /dev/null
@@ -0,0 +1,192 @@
+//
+// MonoTests.Remoting.TcpCalls.cs
+//
+// Author: Lluis Sanchez Gual (lluis@ximian.com)
+//
+// 2003 (C) Copyright, Ximian, Inc.
+//
+
+using System;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.Remoting.Channels.Tcp;
+using System.Runtime.Remoting.Channels.Http;
+using NUnit.Framework;
+
+namespace MonoTests.Remoting
+{
+       [TestFixture]
+       public class ActivationTests
+       {
+               ActivationServer server;
+                       
+               [TestFixtureSetUp]
+               public void Run()
+               {
+                       try
+                       {
+                               AppDomain domain = AppDomain.CreateDomain ("testdomain_activation");
+                               server = (ActivationServer) domain.CreateInstanceAndUnwrap(GetType().Assembly.FullName,"MonoTests.Remoting.ActivationServer");
+                               
+                               RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject1), "tcp://localhost:32433");
+                               RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject2), "http://localhost:32434");
+                               RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall1), "tcp://localhost:32433/wkoSingleCall1");
+                               RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton1), "tcp://localhost:32433/wkoSingleton1");
+                               RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall2), "http://localhost:32434/wkoSingleCall2");
+                               RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton2), "http://localhost:32434/wkoSingleton2");
+                       }
+                       catch (Exception ex)
+                       {
+                               Console.WriteLine (ex);
+                       }
+               }
+               
+               [Test]
+               public void TestCreateTcpCao ()
+               {
+                       CaObject1 ca = new CaObject1 ();
+                       CaObject1 ca2 = new CaObject1 ();
+                       RunTestCreateCao (ca, ca2);
+               }
+               
+               [Test]
+               public void TestCreateHttpCao ()
+               {
+                       CaObject2 ca = new CaObject2 ();
+                       CaObject2 ca2 = new CaObject2 ();
+                       RunTestCreateCao (ca, ca2);
+               }
+               
+               public void RunTestCreateCao (BaseObject ca, BaseObject ca2)
+               {
+                       Assert.AreEqual (0, ca.counter, "#1");
+                       
+                       ca.counter++;
+                       Assert.AreEqual (1, ca.counter, "#2");
+                       
+                       Assert.AreEqual (0, ca2.counter, "#3");
+                       
+                       ca2.counter++;
+                       Assert.AreEqual (1, ca2.counter, "#4");
+                       
+                       Assert.AreEqual (1, ca.counter, "#5");
+               }
+
+               [Test]
+               public void TestCreateTcpWkoSingleCall ()
+               {
+                       WkObjectSinglecall1 ca = new WkObjectSinglecall1 ();
+                       WkObjectSinglecall1 ca2 = new WkObjectSinglecall1 ();
+                       RunTestCreateWkoSingleCall (ca, ca2);
+               }
+               
+               [Test]
+               public void TestCreateTcpWkoSingleton ()
+               {
+                       WkObjectSingleton1 ca = new WkObjectSingleton1 ();
+                       WkObjectSingleton1 ca2 = new WkObjectSingleton1 ();
+                       RunTestCreateWkoSingleton (ca, ca2);
+               }
+
+               [Test]
+               public void TestCreateHttpWkoSingleCall ()
+               {
+                       WkObjectSinglecall2 ca = new WkObjectSinglecall2 ();
+                       WkObjectSinglecall2 ca2 = new WkObjectSinglecall2 ();
+                       RunTestCreateWkoSingleCall (ca, ca2);
+               }
+               
+               [Test]
+               public void TestCreateHttpWkoSingleton ()
+               {
+                       WkObjectSingleton2 ca = new WkObjectSingleton2 ();
+                       WkObjectSingleton2 ca2 = new WkObjectSingleton2 ();
+                       RunTestCreateWkoSingleton (ca, ca2);
+               }
+               
+               public void RunTestCreateWkoSingleCall (BaseObject ca, BaseObject ca2)
+               {
+                       Assert.AreEqual (0, ca.counter, "#1");
+                       ca.counter++;
+                       Assert.AreEqual (0, ca.counter, "#2");
+
+                       Assert.AreEqual (0, ca2.counter, "#3");
+                       ca2.counter++;
+                       Assert.AreEqual (0, ca2.counter, "#4");
+               }
+
+               public void RunTestCreateWkoSingleton (BaseObject ca, BaseObject ca2)
+               {
+                       Assert.AreEqual (0, ca.counter, "#1");
+                       ca.counter++;
+                       Assert.AreEqual (1, ca.counter, "#2");
+                       ca.counter++;
+                       Assert.AreEqual (2, ca2.counter, "#3");
+                       ca2.counter++;
+                       Assert.AreEqual (3, ca2.counter, "#4");
+               }
+
+               [TestFixtureTearDown]
+               public void End ()
+               {
+                       server.Stop ();
+               }
+       }
+       
+       public class ActivationServer: MarshalByRefObject
+       {
+               TcpChannel tcp;
+               HttpChannel http;
+               
+               public ActivationServer ()
+               {
+                       TcpChannel tcp =  new TcpChannel (32433);
+                       HttpChannel http =  new HttpChannel (32434);
+                       
+                       ChannelServices.RegisterChannel (tcp);
+                       ChannelServices.RegisterChannel (http);
+                       
+                       RemotingConfiguration.RegisterActivatedServiceType (typeof(CaObject1));
+                       RemotingConfiguration.RegisterActivatedServiceType (typeof(CaObject2));
+                       RemotingConfiguration.RegisterWellKnownServiceType (typeof(WkObjectSinglecall1), "wkoSingleCall1", WellKnownObjectMode.SingleCall);
+                       RemotingConfiguration.RegisterWellKnownServiceType (typeof(WkObjectSingleton1), "wkoSingleton1", WellKnownObjectMode.Singleton);
+                       RemotingConfiguration.RegisterWellKnownServiceType (typeof(WkObjectSinglecall2), "wkoSingleCall2", WellKnownObjectMode.SingleCall);
+                       RemotingConfiguration.RegisterWellKnownServiceType (typeof(WkObjectSingleton2), "wkoSingleton2", WellKnownObjectMode.Singleton);
+               }
+               
+               public void Stop ()
+               {
+                       tcp.StopListening (null);
+                       http.StopListening (null);
+               }
+       }
+       
+       public class BaseObject: MarshalByRefObject
+       {
+               public int counter;
+       }
+       
+       public class CaObject1: BaseObject
+       {
+       }
+       
+       public class CaObject2: BaseObject
+       {
+       }
+       
+       public class WkObjectSinglecall1: BaseObject
+       {
+       }
+       
+       public class WkObjectSingleton1: BaseObject
+       {
+       }
+       
+       public class WkObjectSinglecall2: BaseObject
+       {
+       }
+       
+       public class WkObjectSingleton2: BaseObject
+       {
+       }
+}
index 15d2dde3c4dfa715252e357c4014d00d983d4980..dad5faddc1aa64fc493b9e416d62f9a117616dd6 100644 (file)
@@ -24,7 +24,7 @@ using NUnit.Framework;
 
 namespace MonoTests.Remoting
 {
-       public abstract class BaseCallTest : Assertion
+       public abstract class BaseCallTest
        {
                IChannelSender chs;
                string[] remoteUris;
@@ -234,12 +234,12 @@ namespace MonoTests.Remoting
 
                public void RunTestSimple (IRemoteObject testerSurrogate)
                {
-                       AssertEquals ("ReturnValue", 130772 + remoteDomId, testerSurrogate.Simple ());
+                       Assert.AreEqual (130772 + remoteDomId, testerSurrogate.Simple (), "ReturnValue");
                }
 
                public void RunTestPrimitiveParams (IRemoteObject testerSurrogate)
                {
-                       AssertEquals ("ReturnValue", "11-22-L-SG@"+remoteDomId, testerSurrogate.PrimitiveParams (11, 22, 'L', "SG"));
+                       Assert.AreEqual ("11-22-L-SG@"+remoteDomId, testerSurrogate.PrimitiveParams (11, 22, 'L', "SG"), "ReturnValue");
                }
 
                public void RunTestPrimitiveParamsInOut (IRemoteObject testerSurrogate)
@@ -251,17 +251,17 @@ namespace MonoTests.Remoting
 
                        string res = testerSurrogate.PrimitiveParamsInOut (ref a1, out a2, ref b1, out b2, 9821, ref c1, out c2, ref d1, out d2);
 
-                       AssertEquals ("ReturnValue", "9876543-82437.83-s-asdASDzxcZXC@" + remoteDomId, res);
+                       Assert.AreEqual ("9876543-82437.83-s-asdASDzxcZXC@" + remoteDomId, res, "ReturnValue");
 
-                       AssertEquals ("a2", 12345678, a2);
-                       AssertEquals ("b2", 53455.345f, b2);
-                       AssertEquals ("c2", 'g', c2);
-                       AssertEquals ("d2", "sfARREG$5345DGDfgY7656gDFG>><<dasdasd", d2);
+                       Assert.AreEqual (12345678, a2, "a2");
+                       Assert.AreEqual (53455.345f, b2, "b2");
+                       Assert.AreEqual ('g', c2, "c2");
+                       Assert.AreEqual ("sfARREG$5345DGDfgY7656gDFG>><<dasdasd", d2, "d2");
 
-                       AssertEquals ("a1", 65748392, a1);
-                       AssertEquals ("b1", 98395.654f, b1);
-                       AssertEquals ("c1", 'l', c1);
-                       AssertEquals ("d1", "aasbasbdyhasbduybo234243", d1);
+                       Assert.AreEqual (65748392, a1, "a1");
+                       Assert.AreEqual (98395.654f, b1, "b1");
+                       Assert.AreEqual ('l', c1, "c1");
+                       Assert.AreEqual ("aasbasbdyhasbduybo234243", d1, "d1");
                }
 
                public void RunTestComplexParams (IRemoteObject testerSurrogate)
@@ -272,16 +272,16 @@ namespace MonoTests.Remoting
 
                        Complex r = testerSurrogate.ComplexParams (list, c, "third");
 
-                       AssertNotNull ("ReturnValue is null", r);
-                       AssertNotNull ("ReturnValue.Child is null", r.Child);
-                       AssertNotNull ("ReturnValue.Child.Child is null", r.Child.Child);
+                       Assert.IsNotNull (r, "ReturnValue is null");
+                       Assert.IsNotNull (r.Child, "ReturnValue.Child is null");
+                       Assert.IsNotNull (r.Child.Child, "ReturnValue.Child.Child is null");
                        
-                       AssertEquals ("ReturnValue.Id", 33, r.Id);
-                       AssertEquals ("ReturnValue.Name", "third@"+remoteDomId, r.Name);
-                       AssertEquals ("ReturnValue.Child.Id", 22, r.Child.Id);
-                       AssertEquals ("ReturnValue.Child.Name", "second", r.Child.Name);
-                       AssertEquals ("ReturnValue.Child.Child.Id", 11, r.Child.Child.Id);
-                       AssertEquals ("ReturnValue.Child.Child.Name", "first", r.Child.Child.Name);
+                       Assert.AreEqual (33, r.Id, "ReturnValue.Id");
+                       Assert.AreEqual ("third@"+remoteDomId, r.Name, "ReturnValue.Name");
+                       Assert.AreEqual (22, r.Child.Id, "ReturnValue.Child.Id");
+                       Assert.AreEqual ("second", r.Child.Name, "ReturnValue.Child.Name");
+                       Assert.AreEqual (11, r.Child.Child.Id, "ReturnValue.Child.Child.Id");
+                       Assert.AreEqual ("first", r.Child.Child.Name, "ReturnValue.Child.Child.Name");
                }
 
                public void RunTestComplexParamsInOut (IRemoteObject testerSurrogate)
@@ -297,31 +297,31 @@ namespace MonoTests.Remoting
                        Complex c;
                        Complex r = testerSurrogate.ComplexParamsInOut (ref list, out c, bytes, sb, "third");
 
-                       AssertNotNull ("ReturnValue is null", r);
-                       AssertNotNull ("c is null", c);
-                       AssertNotNull ("list is null", list);
-                       Assert ("Invalid list count", list.Count == 3);
-                       AssertNotNull ("list[0] is null", list[0]);
-                       AssertNotNull ("list[1] is null", list[1]);
-                       AssertNotNull ("list[2] is null", list[2]);
-                       AssertNotNull ("bytes is null", bytes);
-                       AssertNotNull ("sb is null", sb);
+                       Assert.IsNotNull (r, "ReturnValue is null");
+                       Assert.IsNotNull (c, "c is null");
+                       Assert.IsNotNull (list, "list is null");
+                       Assert.IsTrue (list.Count == 3, "Invalid list count");
+                       Assert.IsNotNull (list[0], "list[0] is null");
+                       Assert.IsNotNull (list[1], "list[1] is null");
+                       Assert.IsNotNull (list[2], "list[2] is null");
+                       Assert.IsNotNull (bytes, "bytes is null");
+                       Assert.IsNotNull (sb, "sb is null");
                        
-                       AssertEquals ("ReturnValue.Id", 33, r.Id);
-                       AssertEquals ("ReturnValue.Name", "third@"+remoteDomId, r.Name);
-                       AssertEquals ("c.Id", 33, c.Id);
-                       AssertEquals ("c.Name", "third@"+remoteDomId, c.Name);
-
-                       AssertEquals ("list[2].Id", 33, ((Complex)list[2]).Id);
-                       AssertEquals ("list[2].Name", "third@"+remoteDomId, ((Complex)list[2]).Name);
-                       AssertEquals ("list[1].Id", 22, ((Complex)list[1]).Id);
-                       AssertEquals ("list[1].Name", "second", ((Complex)list[1]).Name);
-                       AssertEquals ("list[0].Id", 11, ((Complex)list[0]).Id);
-                       AssertEquals ("list[0].Name", "first", ((Complex)list[0]).Name);
+                       Assert.AreEqual (33, r.Id, "ReturnValue.Id");
+                       Assert.AreEqual ("third@"+remoteDomId, r.Name, "ReturnValue.Name");
+                       Assert.AreEqual (33, c.Id, "c.Id");
+                       Assert.AreEqual ("third@"+remoteDomId, c.Name, "c.Name");
+
+                       Assert.AreEqual (33, ((Complex)list[2]).Id, "list[2].Id");
+                       Assert.AreEqual ("third@"+remoteDomId, ((Complex)list[2]).Name, "list[2].Name");
+                       Assert.AreEqual (22, ((Complex)list[1]).Id, "list[1].Id");
+                       Assert.AreEqual ("second", ((Complex)list[1]).Name, "list[1].Name");
+                       Assert.AreEqual (11, ((Complex)list[0]).Id, "list[0].Id");
+                       Assert.AreEqual ("first", ((Complex)list[0]).Name, "list[0].Name");
                        
-                       AssertEquals ("sb", "hello from client and from server", sb.ToString ());
+                       Assert.AreEqual ("hello from client and from server", sb.ToString (), "sb");
                        for (int n=0; n<100; n++) 
-                               AssertEquals ("bytes["+n+"]", n+1, bytes[n]);
+                               Assert.AreEqual (n+1, bytes[n], "bytes["+n+"]");
                }
                
                public void RunTestProcessContextData (IRemoteObject testerSurrogate)
@@ -339,18 +339,18 @@ namespace MonoTests.Remoting
                        testerSurrogate.ProcessContextData ();
                        
                        cdata = CallContext.GetData ("clientData") as ContextData;
-                       AssertNotNull ("clientData is null", cdata);
-                       AssertEquals ("clientData.data", "hi from client", cdata.data);
-                       AssertEquals ("clientData.id", 1123, cdata.id);
+                       Assert.IsNotNull (cdata, "clientData is null");
+                       Assert.AreEqual ("hi from client", cdata.data, "clientData.data");
+                       Assert.AreEqual (1123, cdata.id, "clientData.id");
                        
                        cdata = CallContext.GetData ("serverData") as ContextData;
-                       AssertNotNull ("serverData is null", cdata);
-                       AssertEquals ("serverData.data", "hi from server", cdata.data);
-                       AssertEquals ("serverData.id", 3211, cdata.id);
+                       Assert.IsNotNull (cdata, "serverData is null");
+                       Assert.AreEqual ("hi from server", cdata.data, "serverData.data");
+                       Assert.AreEqual (3211, cdata.id, "serverData.id");
                        
                        string mdata = CallContext.GetData ("mustNotPass") as string;
-                       AssertNotNull ("mustNotPass is null", mdata);
-                       AssertEquals ("mustNotPass", "more data", mdata);
+                       Assert.IsNotNull (mdata, "mustNotPass is null");
+                       Assert.AreEqual ("more data", mdata, "mustNotPass");
                }
        }
 
index d1312eae1f3c3a5c4ec7ac194b7a8078d8f4743f..605b76087dc8fa7cdcc72f5960f5632f12de8052 100644 (file)
@@ -73,7 +73,7 @@ namespace MonoTests.Remoting
 \r
                        if (checkPos >= calls.Count)\r
                        {\r
-                               if (!optional) Assertion.Fail ("[" + name + "] Call check failed. Expected call not made: \"" + msg + "\"");\r
+                               if (!optional) Assert.Fail ("[" + name + "] Call check failed. Expected call not made: \"" + msg + "\"");\r
                                else return;\r
                        }\r
 \r
@@ -82,7 +82,7 @@ namespace MonoTests.Remoting
                        if (msg.Substring (3) != call.Substring (3))\r
                        {\r
                                if (optional) checkPos--;\r
-                               else Assertion.Fail ("[" + name + "] Call check failed in step " + (checkPos+1) + ". Expected \"" + msg + "\" found \"" + call + "\"");\r
+                               else Assert.Fail ("[" + name + "] Call check failed in step " + (checkPos+1) + ". Expected \"" + msg + "\" found \"" + call + "\"");\r
                        }\r
                }\r
 \r
index 67eb1ff8fb32358d00ea9915fdee444ed566a3c5..8218c9a3c597214a7b9064a1df01ec8860cb6db3 100644 (file)
@@ -1,3 +1,8 @@
+2004-06-23  Lluis Sanchez Gual <lluis@ximian.com>
+
+       * ActivationTests.cs: New tests.
+       * BaseCalls.cs, CallSeq.cs: Use Assert instead of the deprecated Assertion.
+
 2004-05-03  Lluis Sanchez Gual <lluis@ximian.com>
 
        * AsyncCalls.cs, BaseCalls.cs, DelegateCalls.cs, ReflectionCalls.cs,