summaryrefslogtreecommitdiff
path: root/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEngine.TestRunner/NUnitExtensions/ActionDelegator.cs
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-04-20 19:09:33 -0400
committerAndrew Lee <alee14498@protonmail.com>2020-04-20 19:09:33 -0400
commit7c1e566113d59699af1624186c64eca67f063fc6 (patch)
tree5a6850a695986872d5d0b09d7dab8421628fe33e /Library/PackageCache/com.unity.test-framework@1.1.11/UnityEngine.TestRunner/NUnitExtensions/ActionDelegator.cs
parentdd117b77aae1d8be7563b360d05b842a73b7dab2 (diff)
downloadProject-Sandbox-7c1e566113d59699af1624186c64eca67f063fc6.tar.gz
Project-Sandbox-7c1e566113d59699af1624186c64eca67f063fc6.tar.bz2
Project-Sandbox-7c1e566113d59699af1624186c64eca67f063fc6.zip
Upgraded Unity
Diffstat (limited to 'Library/PackageCache/com.unity.test-framework@1.1.11/UnityEngine.TestRunner/NUnitExtensions/ActionDelegator.cs')
-rw-r--r--Library/PackageCache/com.unity.test-framework@1.1.11/UnityEngine.TestRunner/NUnitExtensions/ActionDelegator.cs79
1 files changed, 0 insertions, 79 deletions
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEngine.TestRunner/NUnitExtensions/ActionDelegator.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEngine.TestRunner/NUnitExtensions/ActionDelegator.cs
deleted file mode 100644
index d13a7e0..0000000
--- a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEngine.TestRunner/NUnitExtensions/ActionDelegator.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-using System;
-using System.Linq;
-using UnityEngine.TestRunner.NUnitExtensions.Runner;
-using UnityEngine.TestTools.Logging;
-using UnityEngine.TestTools.TestRunner;
-
-namespace UnityEngine.TestTools.NUnitExtensions
-{
- /// <summary>
- /// This class delegates actions from the NUnit thread that should be executed on the main thread.
- /// NUnit thread calls Delegate which blocks the execution on the thread until the action is executed.
- /// The main thread will poll for awaiting actions (HasAction) and invoke them (Execute).
- /// Once the action is executed, the main thread releases the lock and executino on the NUnit thread is continued.
- /// </summary>
- internal class ActionDelegator : BaseDelegator
- {
- private Func<object> m_Action;
- public object Delegate(Action action)
- {
- return Delegate(() => { action(); return null; });
- }
-
- public object Delegate(Func<object> action)
- {
- if (m_Aborted)
- {
- return null;
- }
-
- AssertState();
- m_Context = UnityTestExecutionContext.CurrentContext;
-
- m_Signal.Reset();
- m_Action = action;
-
- WaitForSignal();
-
- return HandleResult();
- }
-
- private void AssertState()
- {
- if (m_Action != null)
- {
- throw new Exception("Action not executed yet");
- }
- }
-
- public bool HasAction()
- {
- return m_Action != null;
- }
-
- public void Execute(LogScope logScope)
- {
- try
- {
- SetCurrentTestContext();
- m_Result = m_Action();
- if (logScope.AnyFailingLogs())
- {
- var failingLog = logScope.FailingLogs.First();
- throw new UnhandledLogMessageException(failingLog);
- }
- if (logScope.ExpectedLogs.Any())
- throw new UnexpectedLogMessageException(LogScope.Current.ExpectedLogs.Peek());
- }
- catch (Exception e)
- {
- m_Exception = e;
- }
- finally
- {
- m_Action = null;
- m_Signal.Set();
- }
- }
- }
-}