mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
58 lines
1.4 KiB
C#
58 lines
1.4 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|
|
}
|