A game about forced loneliness, made by TACStudios
1using System; 2using System.Collections; 3using NUnit.Framework.Interfaces; 4using NUnit.Framework.Internal; 5using NUnit.Framework.Internal.Commands; 6using UnityEngine.TestTools; 7 8namespace UnityEngine.TestRunner.NUnitExtensions.Runner 9{ 10 internal class EditModeTestCallbacks 11 { 12 public static Action RestoringTestContext { get; set; } 13 } 14 15 internal class DefaultTestWorkItem : UnityWorkItem 16 { 17 private TestCommand _command; 18 public DefaultTestWorkItem(TestMethod test, ITestFilter filter) 19 : base(test, null) 20 { 21 _command = TestCommandBuilder.BuildTestCommand(test, filter); 22 } 23 24 protected override IEnumerable PerformWork() 25 { 26 if (m_DontRunRestoringResult && EditModeTestCallbacks.RestoringTestContext != null) 27 { 28 EditModeTestCallbacks.RestoringTestContext(); 29 Result = Context.CurrentResult; 30 yield break; 31 } 32 33 try 34 { 35 if (_command is SkipCommand || _command is FailCommand) 36 { 37 Result = _command.Execute(Context); 38 yield break; 39 } 40 41 if (!(_command is IEnumerableTestMethodCommand)) 42 { 43 Debug.LogError("Cannot perform work on " + _command.GetType().Name); 44 yield break; 45 } 46 if (Context.TestCaseTimeout == 0) 47 { 48 Context.TestCaseTimeout = k_DefaultTimeout; 49 } 50 foreach (var workItemStep in ((IEnumerableTestMethodCommand)_command).ExecuteEnumerable(Context)) 51 { 52 ResultedInDomainReload = false; 53 54 if (workItemStep is IEditModeTestYieldInstruction) 55 { 56 var editModeTestYieldInstruction = (IEditModeTestYieldInstruction)workItemStep; 57 yield return editModeTestYieldInstruction; 58 var enumerator = editModeTestYieldInstruction.Perform(); 59 while (true) 60 { 61 bool moveNext; 62 try 63 { 64 moveNext = enumerator.MoveNext(); 65 } 66 catch (Exception e) 67 { 68 Context.CurrentResult.RecordException(e); 69 break; 70 } 71 72 if (!moveNext) 73 { 74 break; 75 } 76 77 yield return null; 78 } 79 } 80 else 81 { 82 yield return workItemStep; 83 } 84 } 85 86 Result = Context.CurrentResult; 87 } 88 finally 89 { 90 WorkItemComplete(); 91 } 92 } 93 } 94}