summaryrefslogtreecommitdiff
path: root/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEngine.TestRunner/NUnitExtensions/BaseDelegator.cs
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-04-19 17:19:32 -0400
committerAndrew Lee <alee14498@protonmail.com>2020-04-19 17:19:32 -0400
commitc55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 (patch)
treeee4d51c7c1d633e11f46453ef1edd3c77c4ef9f7 /Library/PackageCache/com.unity.test-framework@1.1.11/UnityEngine.TestRunner/NUnitExtensions/BaseDelegator.cs
downloadProject-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.gz
Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.bz2
Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.zip
Inital commit
Diffstat (limited to 'Library/PackageCache/com.unity.test-framework@1.1.11/UnityEngine.TestRunner/NUnitExtensions/BaseDelegator.cs')
-rw-r--r--Library/PackageCache/com.unity.test-framework@1.1.11/UnityEngine.TestRunner/NUnitExtensions/BaseDelegator.cs58
1 files changed, 58 insertions, 0 deletions
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEngine.TestRunner/NUnitExtensions/BaseDelegator.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEngine.TestRunner/NUnitExtensions/BaseDelegator.cs
new file mode 100644
index 0000000..596c000
--- /dev/null
+++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEngine.TestRunner/NUnitExtensions/BaseDelegator.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Threading;
+using NUnit.Framework.Internal;
+
+namespace UnityEngine.TestTools.NUnitExtensions
+{
+ internal abstract class BaseDelegator
+ {
+ protected ManualResetEvent m_Signal = new ManualResetEvent(false);
+
+ protected object m_Result;
+ protected Exception m_Exception;
+ protected ITestExecutionContext m_Context;
+
+ protected bool m_Aborted;
+
+ protected object HandleResult()
+ {
+ SetCurrentTestContext();
+ if (m_Exception != null)
+ {
+ var temp = m_Exception;
+ m_Exception = null;
+ throw temp;
+ }
+ var tempResult = m_Result;
+ m_Result = null;
+ return tempResult;
+ }
+
+ protected void WaitForSignal()
+ {
+ while (!m_Signal.WaitOne(100))
+ {
+ if (m_Aborted)
+ {
+ m_Aborted = false;
+ Reflect.MethodCallWrapper = null;
+ throw new Exception();
+ }
+ }
+ }
+
+ public void Abort()
+ {
+ m_Aborted = true;
+ }
+
+ protected void SetCurrentTestContext()
+ {
+ var prop = typeof(TestExecutionContext).GetProperty("CurrentContext");
+ if (prop != null)
+ {
+ prop.SetValue(null, m_Context, null);
+ }
+ }
+ }
+}