2 // MonoTests.Remoting.ServerObject.cs
4 // Author: Lluis Sanchez Gual (lluis@ximian.com)
6 // 2003 (C) Copyright, Ximian, Inc.
10 using System
.Runtime
.Remoting
;
11 using System
.Runtime
.Remoting
.Lifetime
;
12 using System
.Collections
;
13 using NUnit
.Framework
;
15 namespace MonoTests
.Remoting
17 // A list of ServerObject instances
19 [ContextHook("x", false)]
20 public class ServerList
:
24 ArrayList values
= new ArrayList();
25 public int NumVal
= 0;
26 public string StrVal
= "val";
30 Assert
.IsTrue (RemotingServices
.IsTransparentProxy(this));
31 CallSeq
.Add ("List created");
36 Assert
.IsTrue (RemotingServices
.IsTransparentProxy(this));
37 CallSeq
.Add ("List disposed");
41 public void Add (ServerObject v
)
43 Assert
.IsTrue (RemotingServices
.IsTransparentProxy(this));
45 CallSeq
.Add ("Added " + v
.Name
);
48 public void ProcessItems ()
50 Assert
.IsTrue (RemotingServices
.IsTransparentProxy(this));
51 CallSeq
.Add ("Processing");
54 foreach (ServerObject ob
in values
)
55 total
+= ob
.GetValue();
57 CallSeq
.Add ("Total: " + total
);
62 Assert
.IsTrue (RemotingServices
.IsTransparentProxy(this));
63 CallSeq
.Add ("Clearing");
67 public void ParameterTest1 (int a
, out string b
)
69 Assert
.IsTrue (RemotingServices
.IsTransparentProxy(this));
73 public void ParameterTest2 (int a
, out int b
)
75 Assert
.IsTrue (RemotingServices
.IsTransparentProxy(this));
79 public ServerObject
NewItem(string name
)
81 Assert
.IsTrue (RemotingServices
.IsTransparentProxy(this));
82 ServerObject obj
= new ServerObject(name
);
87 public ServerObject
CreateItem(string name
, int val
)
89 Assert
.IsTrue (RemotingServices
.IsTransparentProxy(this));
90 ServerObject obj
= new ServerObject(name
);
95 public ComplexData
SetComplexData (ComplexData data
)
97 Assert
.IsTrue (RemotingServices
.IsTransparentProxy(this));
98 CallSeq
.Add ("Showing content of ComplexData");
103 public override ObjRef
CreateObjRef (Type type
)
105 Assert
.IsTrue (RemotingServices
.IsTransparentProxy(this));
106 CallSeq
.Add ("### ServerList.CreateObjRef");
107 return base.CreateObjRef (type
);
111 // A remotable object
113 public class ServerObject
:
114 // ContextBoundObject
120 public ServerObject (string name
)
127 get { return _name; }
130 public void SetValue (int v
)
132 CallSeq
.Add ("ServerObject " + _name
+ ": setting " + v
);
136 public int GetValue ()
138 CallSeq
.Add ("ServerObject " + _name
+ ": getting " + _value
);
142 public override ObjRef
CreateObjRef (Type type
)
144 CallSeq
.Add ("### ServerObject.CreateObjRef");
145 return base.CreateObjRef (type
);
149 // Some complex data for testing serialization
151 public enum AnEnum { a,b,c,d,e }
;
154 public class ComplexData
156 public AnEnum Val
= AnEnum
.a
;
158 public object[] Info
;
160 public ComplexData (AnEnum va
, object[] info
)
168 CallSeq
.Add ("Content:");
169 CallSeq
.Add ("Val: " + Val
);
170 foreach (object ob
in Info
)
171 CallSeq
.Add ("Array item: " + ob
);