A game about forced loneliness, made by TACStudios
1using System;
2using System.Threading;
3using NUnit.Framework.Internal;
4
5namespace UnityEngine.TestTools.NUnitExtensions
6{
7 internal abstract class BaseDelegator
8 {
9 protected ManualResetEvent m_Signal = new ManualResetEvent(false);
10
11 protected object m_Result;
12 protected Exception m_Exception;
13 protected ITestExecutionContext m_Context;
14
15 protected bool m_Aborted;
16
17 protected object HandleResult()
18 {
19 SetCurrentTestContext();
20 if (m_Exception != null)
21 {
22 var temp = m_Exception;
23 m_Exception = null;
24 throw temp;
25 }
26 var tempResult = m_Result;
27 m_Result = null;
28 return tempResult;
29 }
30
31 protected void WaitForSignal()
32 {
33 while (!m_Signal.WaitOne(100))
34 {
35 if (m_Aborted)
36 {
37 m_Aborted = false;
38 Reflect.MethodCallWrapper = null;
39 throw new Exception();
40 }
41 }
42 }
43
44 public void Abort()
45 {
46 m_Aborted = true;
47 }
48
49 protected void SetCurrentTestContext()
50 {
51 var prop = typeof(TestExecutionContext).GetProperty("CurrentContext");
52 if (prop != null)
53 {
54 prop.SetValue(null, m_Context, null);
55 }
56 }
57 }
58}