A game about forced loneliness, made by TACStudios
1using System; 2using System.Collections.Generic; 3using System.Globalization; 4using System.IO; 5using NUnit.Framework; 6using NUnit.Framework.Constraints; 7using NUnit.Framework.Interfaces; 8using NUnit.Framework.Internal; 9using NUnit.Framework.Internal.Execution; 10using UnityEngine.TestTools; 11 12namespace UnityEngine.TestRunner.NUnitExtensions.Runner 13{ 14 internal class UnityTestExecutionContext : ITestExecutionContext 15 { 16 private readonly UnityTestExecutionContext _priorContext; 17 private TestResult _currentResult; 18 private int _assertCount; 19 20 public static UnityTestExecutionContext CurrentContext { get; set; } 21 22 public UnityTestExecutionContext Context { get; private set; } 23 24 public bool Automated { get; set; } 25 26 public Test CurrentTest { get; set; } 27 public DateTime StartTime { get; set; } 28 public long StartTicks { get; set; } 29 public TestResult CurrentResult 30 { 31 get { return _currentResult; } 32 set 33 { 34 _currentResult = value; 35 if (value != null) 36 OutWriter = value.OutWriter; 37 } 38 } 39 40 public object TestObject { get; set; } 41 public string WorkDirectory { get; set; } 42 43 44 private TestExecutionStatus _executionStatus; 45 public TestExecutionStatus ExecutionStatus 46 { 47 get 48 { 49 // ExecutionStatus may have been set to StopRequested or AbortRequested 50 // in a prior context. If so, reflect the same setting in this context. 51 if (_executionStatus == TestExecutionStatus.Running && _priorContext != null) 52 _executionStatus = _priorContext.ExecutionStatus; 53 54 return _executionStatus; 55 } 56 set 57 { 58 _executionStatus = value; 59 60 // Push the same setting up to all prior contexts 61 if (_priorContext != null) 62 _priorContext.ExecutionStatus = value; 63 } 64 } 65 66 public List<ITestAction> UpstreamActions { get; private set; } 67 public int TestCaseTimeout { get; set; } 68 public CultureInfo CurrentCulture { get; set; } 69 public CultureInfo CurrentUICulture { get; set; } 70 public ITestListener Listener { get; set; } 71 72 public UnityTestExecutionContext() 73 { 74 UpstreamActions = new List<ITestAction>(); 75 SetUpTearDownState = new BeforeAfterTestCommandState(); 76 OuterUnityTestActionState = new BeforeAfterTestCommandState(); 77 EnumerableTestState = new EnumerableTestState(); 78 } 79 80 public UnityTestExecutionContext(BeforeAfterTestCommandState setUpTearDownState, 81 BeforeAfterTestCommandState outerUnityTestActionState, EnumerableTestState enumerableTestState) : this() 82 { 83 SetUpTearDownState = setUpTearDownState; 84 OuterUnityTestActionState = outerUnityTestActionState; 85 EnumerableTestState = enumerableTestState; 86 } 87 88 public UnityTestExecutionContext(UnityTestExecutionContext other) 89 { 90 _priorContext = other; 91 92 CurrentTest = other.CurrentTest; 93 CurrentResult = other.CurrentResult; 94 TestObject = other.TestObject; 95 WorkDirectory = other.WorkDirectory; 96 Listener = other.Listener; 97 TestCaseTimeout = other.TestCaseTimeout; 98 UpstreamActions = new List<ITestAction>(other.UpstreamActions); 99 SetUpTearDownState = other.SetUpTearDownState; 100 OuterUnityTestActionState = other.OuterUnityTestActionState; 101 EnumerableTestState = other.EnumerableTestState; 102 103 TestContext.CurrentTestExecutionContext = this; 104 105 CurrentCulture = other.CurrentCulture; 106 CurrentUICulture = other.CurrentUICulture; 107 TestMode = other.TestMode; 108 IgnoreTests = other.IgnoreTests; 109 FeatureFlags = other.FeatureFlags; 110 CurrentContext = this; 111 Automated = other.Automated; 112 RepeatCount = other.RepeatCount; 113 RetryCount = other.RetryCount; 114 } 115 116 public TextWriter OutWriter { get; private set; } 117 public bool StopOnError { get; set; } 118 119 public IWorkItemDispatcher Dispatcher { get; set; } 120 121 public ParallelScope ParallelScope { get; set; } 122 public string WorkerId { get; private set; } 123 public Randomizer RandomGenerator { get; private set; } 124 public ValueFormatter CurrentValueFormatter { get; private set; } 125 public bool IsSingleThreaded { get; set; } 126 public BeforeAfterTestCommandState SetUpTearDownState { get; set; } 127 public BeforeAfterTestCommandState OuterUnityTestActionState { get; set; } 128 public EnumerableTestState EnumerableTestState { get; set; } 129 public IgnoreTest[] IgnoreTests { get; set; } 130 public FeatureFlags FeatureFlags { get; set; } 131 public int RetryCount { get; set; } 132 public int RepeatCount { get; set; } 133 public EnumerableTestState RetryRepeatState { get; set; } 134 135 internal int AssertCount 136 { 137 get 138 { 139 return _assertCount; 140 } 141 } 142 143 public TestPlatform TestMode { get; set; } 144 145 public void IncrementAssertCount() 146 { 147 _assertCount += 1; 148 } 149 150 public void AddFormatter(ValueFormatterFactory formatterFactory) 151 { 152 throw new NotImplementedException(); 153 } 154 } 155}