2 // MonoTests.System.Runtime.Remoting.CallSeq.cs
\r
4 // Author: Lluis Sanchez Gual (lluis@ximian.com)
\r
6 // 2003 (C) Copyright, Ximian, Inc.
\r
10 using System.Threading;
\r
11 using System.Collections;
\r
12 using NUnit.Framework;
\r
14 namespace MonoTests.System.Runtime.Remoting
\r
16 public class CallSeq
\r
18 static ArrayList calls = new ArrayList();
\r
19 static int checkPos = 0;
\r
20 static int writePos = 0;
\r
21 static string name = "";
\r
22 static ArrayList contexts = new ArrayList ();
\r
24 public static void Add (string msg)
\r
28 msg = writePos.ToString ("000") + " (d" + CommonDomainId + ",c" + CommonContextId + ") " + msg;
\r
32 public static int CommonContextId
\r
36 int id = Thread.CurrentContext.ContextID;
\r
37 int idc = contexts.IndexOf (id);
\r
40 idc = contexts.Count;
\r
47 public static int CommonDomainId
\r
51 if (Thread.GetDomainID() != 1) return 2;
\r
56 public static void Init (string str)
\r
58 calls = new ArrayList();
\r
59 contexts = new ArrayList ();
\r
65 public static void Check (string msg, int domain)
\r
67 bool optional = false;
\r
68 if (msg.StartsWith ("#"))
\r
71 msg = msg.Substring (1);
\r
74 if (msg[6].ToString() != domain.ToString()) return;
\r
76 if (checkPos >= calls.Count)
\r
78 if (!optional) Assertion.Fail ("[" + name + "] Call check failed. Expected call not made: \"" + msg + "\"");
\r
82 string call = (string) calls[checkPos++];
\r
84 if (msg.Substring (3) != call.Substring (3))
\r
86 if (optional) checkPos--;
\r
87 else Assertion.Fail ("[" + name + "] Call check failed in step " + (checkPos+1) + ". Expected \"" + msg + "\" found \"" + call + "\"");
\r
91 public static void Check (string[] msgs, int domain)
\r
93 foreach (string msg in msgs)
\r
94 Check (msg, domain);
\r
97 public static ArrayList Seq
\r
99 get { return calls; }
\r
100 set { calls = value; }
\r