[LoongArch64] Part-5:add loongarch support in some files for LoongArch64. (#21769)
[mono-project.git] / mcs / class / System.Runtime.Remoting / Test / CallSeq.cs
blob40780730d96a7fc32252eeb5e40768137b82b7be
1 //
2 // MonoTests.Remoting.CallSeq.cs
3 //
4 // Author: Lluis Sanchez Gual (lluis@ximian.com)
5 //
6 // 2003 (C) Copyright, Ximian, Inc.
7 //
9 using System;
10 using System.Threading;
11 using System.Collections;
12 using NUnit.Framework;
14 namespace MonoTests.Remoting
16 public class CallSeq
18 static ArrayList calls = new ArrayList();
19 static int checkPos = 0;
20 static int writePos = 0;
21 static string name = "";
22 static ArrayList contexts = new ArrayList ();
23 static int domId = 1;
25 public static void Add (string msg)
27 writePos++;
29 msg = writePos.ToString ("000") + " (d" + CommonDomainId + ",c" + CommonContextId + ") " + msg;
30 calls.Add (msg);
33 public static int CommonContextId
35 get
37 int id = Thread.CurrentContext.ContextID;
38 int idc = contexts.IndexOf (id);
39 if (idc == -1)
41 idc = contexts.Count;
42 contexts.Add (id);
44 return idc;
48 public static int CommonDomainId
50 get { return domId; }
51 set { domId = value; }
54 public static void Init (string str)
56 calls = new ArrayList();
57 contexts = new ArrayList ();
58 name = str;
59 checkPos = 0;
60 writePos = 0;
63 public static void Check (string msg, int domain)
65 bool optional = false;
66 if (msg.StartsWith ("#"))
68 optional = true;
69 msg = msg.Substring (1);
72 if (msg[6].ToString() != domain.ToString()) return;
74 if (checkPos >= calls.Count)
76 if (!optional) Assert.Fail ("[" + name + "] Call check failed. Expected call not made: \"" + msg + "\"");
77 else return;
80 string call = (string) calls[checkPos++];
82 if (msg.Substring (3) != call.Substring (3))
84 if (optional) checkPos--;
85 else Assert.Fail ("[" + name + "] Call check failed in step " + (checkPos+1) + ". Expected \"" + msg + "\" found \"" + call + "\"");
89 public static void Check (string[] msgs, int domain)
91 foreach (string msg in msgs)
92 Check (msg, domain);
95 public static ArrayList Seq
97 get { return calls; }
98 set { calls = value; }