(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Runtime.Remoting / Test / ServerObject.cs
blob352714c704bf62bbe6ced0fefc4ae9c78fdff441
1 //
2 // MonoTests.Remoting.ServerObject.cs
3 //
4 // Author: Lluis Sanchez Gual (lluis@ximian.com)
5 //
6 // 2003 (C) Copyright, Ximian, Inc.
7 //
9 using System;
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:
21 ContextBoundObject,
22 IDisposable
24 ArrayList values = new ArrayList();
25 public int NumVal = 0;
26 public string StrVal = "val";
28 public ServerList()
30 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
31 CallSeq.Add ("List created");
34 public void Dispose()
36 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
37 CallSeq.Add ("List disposed");
41 public void Add (ServerObject v)
43 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
44 values.Add (v);
45 CallSeq.Add ("Added " + v.Name);
48 public void ProcessItems ()
50 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
51 CallSeq.Add ("Processing");
53 int total = 0;
54 foreach (ServerObject ob in values)
55 total += ob.GetValue();
57 CallSeq.Add ("Total: " + total);
60 public void Clear()
62 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
63 CallSeq.Add ("Clearing");
64 values.Clear();
67 public void ParameterTest1 (int a, out string b)
69 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
70 b = "adeu " + a;
73 public void ParameterTest2 (int a, out int b)
75 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
76 b = a+1;
79 public ServerObject NewItem(string name)
81 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
82 ServerObject obj = new ServerObject(name);
83 Add (obj);
84 return obj;
87 public ServerObject CreateItem(string name, int val)
89 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
90 ServerObject obj = new ServerObject(name);
91 obj.SetValue (val);
92 return obj;
95 public ComplexData SetComplexData (ComplexData data)
97 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
98 CallSeq.Add ("Showing content of ComplexData");
99 data.Dump ();
100 return data;
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
115 MarshalByRefObject
117 int _value;
118 string _name;
120 public ServerObject (string name)
122 _name = name;
125 public string Name
127 get { return _name; }
130 public void SetValue (int v)
132 CallSeq.Add ("ServerObject " + _name + ": setting " + v);
133 _value = v;
136 public int GetValue ()
138 CallSeq.Add ("ServerObject " + _name + ": getting " + _value);
139 return _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 };
153 [Serializable]
154 public class ComplexData
156 public AnEnum Val = AnEnum.a;
158 public object[] Info;
160 public ComplexData (AnEnum va, object[] info)
162 Info = info;
163 Val = va;
166 public void Dump ()
168 CallSeq.Add ("Content:");
169 CallSeq.Add ("Val: " + Val);
170 foreach (object ob in Info)
171 CallSeq.Add ("Array item: " + ob);