Commit af571a61 authored by BlackAngle233's avatar BlackAngle233
Browse files

212

parent 1d9b5391
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
namespace UnityEngine.TestTools
{
internal class BeforeAfterTestCommandState : ScriptableObject
{
public int NextBeforeStepIndex;
public int NextBeforeStepPc;
public int NextAfterStepIndex;
public int NextAfterStepPc;
public bool TestHasRun;
public TestStatus CurrentTestResultStatus;
public string CurrentTestResultLabel;
public FailureSite CurrentTestResultSite;
public string CurrentTestMessage;
public string CurrentTestStrackTrace;
public bool TestAfterStarted;
public void Reset()
{
NextBeforeStepIndex = 0;
NextBeforeStepPc = 0;
NextAfterStepIndex = 0;
NextAfterStepPc = 0;
TestHasRun = false;
CurrentTestResultStatus = TestStatus.Inconclusive;
CurrentTestResultLabel = null;
CurrentTestResultSite = default(FailureSite);
CurrentTestMessage = null;
CurrentTestStrackTrace = null;
TestAfterStarted = false;
}
public void StoreTestResult(TestResult result)
{
CurrentTestResultStatus = result.ResultState.Status;
CurrentTestResultLabel = result.ResultState.Label;
CurrentTestResultSite = result.ResultState.Site;
CurrentTestMessage = result.Message;
CurrentTestStrackTrace = result.StackTrace;
}
public void ApplyTestResult(TestResult result)
{
result.SetResult(new ResultState(CurrentTestResultStatus, CurrentTestResultLabel, CurrentTestResultSite), CurrentTestMessage, CurrentTestStrackTrace);
}
}
}
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
namespace UnityEngine.TestTools
{
internal class BeforeAfterTestCommandState : ScriptableObject
{
public int NextBeforeStepIndex;
public int NextBeforeStepPc;
public int NextAfterStepIndex;
public int NextAfterStepPc;
public bool TestHasRun;
public TestStatus CurrentTestResultStatus;
public string CurrentTestResultLabel;
public FailureSite CurrentTestResultSite;
public string CurrentTestMessage;
public string CurrentTestStrackTrace;
public bool TestAfterStarted;
public void Reset()
{
NextBeforeStepIndex = 0;
NextBeforeStepPc = 0;
NextAfterStepIndex = 0;
NextAfterStepPc = 0;
TestHasRun = false;
CurrentTestResultStatus = TestStatus.Inconclusive;
CurrentTestResultLabel = null;
CurrentTestResultSite = default(FailureSite);
CurrentTestMessage = null;
CurrentTestStrackTrace = null;
TestAfterStarted = false;
}
public void StoreTestResult(TestResult result)
{
CurrentTestResultStatus = result.ResultState.Status;
CurrentTestResultLabel = result.ResultState.Label;
CurrentTestResultSite = result.ResultState.Site;
CurrentTestMessage = result.Message;
CurrentTestStrackTrace = result.StackTrace;
}
public void ApplyTestResult(TestResult result)
{
result.SetResult(new ResultState(CurrentTestResultStatus, CurrentTestResultLabel, CurrentTestResultSite), CurrentTestMessage, CurrentTestStrackTrace);
}
}
}
fileFormatVersion: 2
guid: 7f65567c9026afb4db5de3355accc636
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 7f65567c9026afb4db5de3355accc636
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class EnumerableApplyChangesToContextCommand : ApplyChangesToContextCommand, IEnumerableTestMethodCommand
{
public EnumerableApplyChangesToContextCommand(TestCommand innerCommand, IEnumerable<IApplyToContext> changes)
: base(innerCommand, changes) { }
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
ApplyChanges(context);
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
}
else
{
context.CurrentResult = innerCommand.Execute(context);
}
}
}
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class EnumerableApplyChangesToContextCommand : ApplyChangesToContextCommand, IEnumerableTestMethodCommand
{
public EnumerableApplyChangesToContextCommand(TestCommand innerCommand, IEnumerable<IApplyToContext> changes)
: base(innerCommand, changes) { }
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
ApplyChanges(context);
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
}
else
{
context.CurrentResult = innerCommand.Execute(context);
}
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 3b4429eff9fcffb48b006e8edcc90338
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 3b4429eff9fcffb48b006e8edcc90338
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Reflection;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class EnumerableRepeatedTestCommand : DelegatingTestCommand, IEnumerableTestMethodCommand
{
private int repeatCount;
public EnumerableRepeatedTestCommand(RepeatAttribute.RepeatedTestCommand commandToReplace) : base(commandToReplace.GetInnerCommand())
{
repeatCount = (int) typeof(RepeatAttribute.RepeatedTestCommand)
.GetField("repeatCount", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(commandToReplace);
}
public override TestResult Execute(ITestExecutionContext context)
{
throw new NotImplementedException("Use ExecuteEnumerable");
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
var unityContext = (UnityTestExecutionContext)context;
int count = unityContext.EnumerableRepeatedTestState;
while (count < repeatCount)
{
count++;
unityContext.EnumerableRepeatedTestState = count;
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
}
else
{
context.CurrentResult = innerCommand.Execute(context);
}
if (context.CurrentResult.ResultState != ResultState.Success)
{
break;
}
}
unityContext.EnumerableRepeatedTestState = 0;
}
}
using System;
using System.Collections;
using System.Reflection;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class EnumerableRepeatedTestCommand : DelegatingTestCommand, IEnumerableTestMethodCommand
{
private int repeatCount;
public EnumerableRepeatedTestCommand(RepeatAttribute.RepeatedTestCommand commandToReplace) : base(commandToReplace.GetInnerCommand())
{
repeatCount = (int) typeof(RepeatAttribute.RepeatedTestCommand)
.GetField("repeatCount", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(commandToReplace);
}
public override TestResult Execute(ITestExecutionContext context)
{
throw new NotImplementedException("Use ExecuteEnumerable");
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
var unityContext = (UnityTestExecutionContext)context;
int count = unityContext.EnumerableRepeatedTestState;
while (count < repeatCount)
{
count++;
unityContext.EnumerableRepeatedTestState = count;
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
}
else
{
context.CurrentResult = innerCommand.Execute(context);
}
if (context.CurrentResult.ResultState != ResultState.Success)
{
break;
}
}
unityContext.EnumerableRepeatedTestState = 0;
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: e273462feb9a65948826739f683cc9a9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: e273462feb9a65948826739f683cc9a9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Reflection;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class EnumerableRetryTestCommand : DelegatingTestCommand, IEnumerableTestMethodCommand
{
private int retryCount;
public EnumerableRetryTestCommand(RetryAttribute.RetryCommand commandToReplace) : base(commandToReplace.GetInnerCommand())
{
retryCount = (int) typeof(RetryAttribute.RetryCommand)
.GetField("_retryCount", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(commandToReplace);
}
public override TestResult Execute(ITestExecutionContext context)
{
throw new NotImplementedException("Use ExecuteEnumerable");
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
var unityContext = (UnityTestExecutionContext)context;
int count = unityContext.EnumerableRetryTestState;
while (count < retryCount)
{
count++;
unityContext.EnumerableRetryTestState = count;
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
}
else
{
context.CurrentResult = innerCommand.Execute(context);
}
if (context.CurrentResult.ResultState != ResultState.Failure)
{
break;
}
}
unityContext.EnumerableRetryTestState = 0;
}
}
using System;
using System.Collections;
using System.Reflection;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class EnumerableRetryTestCommand : DelegatingTestCommand, IEnumerableTestMethodCommand
{
private int retryCount;
public EnumerableRetryTestCommand(RetryAttribute.RetryCommand commandToReplace) : base(commandToReplace.GetInnerCommand())
{
retryCount = (int) typeof(RetryAttribute.RetryCommand)
.GetField("_retryCount", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(commandToReplace);
}
public override TestResult Execute(ITestExecutionContext context)
{
throw new NotImplementedException("Use ExecuteEnumerable");
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
var unityContext = (UnityTestExecutionContext)context;
int count = unityContext.EnumerableRetryTestState;
while (count < retryCount)
{
count++;
unityContext.EnumerableRetryTestState = count;
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
}
else
{
context.CurrentResult = innerCommand.Execute(context);
}
if (context.CurrentResult.ResultState != ResultState.Failure)
{
break;
}
}
unityContext.EnumerableRetryTestState = 0;
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 6de2f178a24cd2e48a0816cacd9a0583
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 6de2f178a24cd2e48a0816cacd9a0583
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Linq;
using System.Reflection;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class EnumerableSetUpTearDownCommand : BeforeAfterTestCommandBase<MethodInfo>
{
public EnumerableSetUpTearDownCommand(TestCommand innerCommand)
: base(innerCommand, "SetUp", "TearDown")
{
if (Test.TypeInfo.Type != null)
{
BeforeActions = GetMethodsWithAttributeFromFixture(Test.TypeInfo.Type, typeof(UnitySetUpAttribute));
AfterActions = GetMethodsWithAttributeFromFixture(Test.TypeInfo.Type, typeof(UnityTearDownAttribute)).Reverse().ToArray();
}
}
private static MethodInfo[] GetMethodsWithAttributeFromFixture(Type fixtureType, Type setUpType)
{
MethodInfo[] methodsWithAttribute = Reflect.GetMethodsWithAttribute(fixtureType, setUpType, true);
return methodsWithAttribute.Where(x => x.ReturnType == typeof(IEnumerator)).ToArray();
}
protected override IEnumerator InvokeBefore(MethodInfo action, Test test, UnityTestExecutionContext context)
{
return (IEnumerator)Reflect.InvokeMethod(action, context.TestObject);
}
protected override IEnumerator InvokeAfter(MethodInfo action, Test test, UnityTestExecutionContext context)
{
return (IEnumerator)Reflect.InvokeMethod(action, context.TestObject);
}
protected override BeforeAfterTestCommandState GetState(UnityTestExecutionContext context)
{
return context.SetUpTearDownState;
}
}
}
using System;
using System.Collections;
using System.Linq;
using System.Reflection;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class EnumerableSetUpTearDownCommand : BeforeAfterTestCommandBase<MethodInfo>
{
public EnumerableSetUpTearDownCommand(TestCommand innerCommand)
: base(innerCommand, "SetUp", "TearDown")
{
if (Test.TypeInfo.Type != null)
{
BeforeActions = GetMethodsWithAttributeFromFixture(Test.TypeInfo.Type, typeof(UnitySetUpAttribute));
AfterActions = GetMethodsWithAttributeFromFixture(Test.TypeInfo.Type, typeof(UnityTearDownAttribute)).Reverse().ToArray();
}
}
private static MethodInfo[] GetMethodsWithAttributeFromFixture(Type fixtureType, Type setUpType)
{
MethodInfo[] methodsWithAttribute = Reflect.GetMethodsWithAttribute(fixtureType, setUpType, true);
return methodsWithAttribute.Where(x => x.ReturnType == typeof(IEnumerator)).ToArray();
}
protected override IEnumerator InvokeBefore(MethodInfo action, Test test, UnityTestExecutionContext context)
{
return (IEnumerator)Reflect.InvokeMethod(action, context.TestObject);
}
protected override IEnumerator InvokeAfter(MethodInfo action, Test test, UnityTestExecutionContext context)
{
return (IEnumerator)Reflect.InvokeMethod(action, context.TestObject);
}
protected override BeforeAfterTestCommandState GetState(UnityTestExecutionContext context)
{
return context.SetUpTearDownState;
}
}
}
fileFormatVersion: 2
guid: dd85a35169d313840a0874aea1a28629
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: dd85a35169d313840a0874aea1a28629
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using NUnit.Framework.Internal.Execution;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
using UnityEngine.TestTools.TestRunner;
namespace UnityEngine.TestTools
{
internal class EnumerableTestMethodCommand : TestCommand, IEnumerableTestMethodCommand
{
private readonly TestMethod testMethod;
public EnumerableTestMethodCommand(TestMethod testMethod)
: base(testMethod)
{
this.testMethod = testMethod;
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
yield return null;
var currentExecutingTestEnumerator = new TestEnumeratorWrapper(testMethod).GetEnumerator(context);
if (currentExecutingTestEnumerator != null)
{
var testEnumeraterYieldInstruction = new TestEnumerator(context, currentExecutingTestEnumerator);
yield return testEnumeraterYieldInstruction;
var enumerator = testEnumeraterYieldInstruction.Execute();
var executingEnumerator = ExecuteEnumerableAndRecordExceptions(enumerator, context);
while (executingEnumerator.MoveNext())
{
yield return executingEnumerator.Current;
}
}
else
{
if (context.CurrentResult.ResultState != ResultState.Ignored)
{
context.CurrentResult.SetResult(ResultState.Success);
}
}
}
private static IEnumerator ExecuteEnumerableAndRecordExceptions(IEnumerator enumerator, ITestExecutionContext context)
{
while (true)
{
try
{
if (!enumerator.MoveNext())
{
break;
}
}
catch (Exception ex)
{
context.CurrentResult.RecordException(ex);
break;
}
if (enumerator.Current is IEnumerator)
{
var current = (IEnumerator)enumerator.Current;
yield return ExecuteEnumerableAndRecordExceptions(current, context);
}
else
{
yield return enumerator.Current;
}
}
}
public override TestResult Execute(ITestExecutionContext context)
{
throw new NotImplementedException("Use ExecuteEnumerable");
}
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using NUnit.Framework.Internal.Execution;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
using UnityEngine.TestTools.TestRunner;
namespace UnityEngine.TestTools
{
internal class EnumerableTestMethodCommand : TestCommand, IEnumerableTestMethodCommand
{
private readonly TestMethod testMethod;
public EnumerableTestMethodCommand(TestMethod testMethod)
: base(testMethod)
{
this.testMethod = testMethod;
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
yield return null;
var currentExecutingTestEnumerator = new TestEnumeratorWrapper(testMethod).GetEnumerator(context);
if (currentExecutingTestEnumerator != null)
{
var testEnumeraterYieldInstruction = new TestEnumerator(context, currentExecutingTestEnumerator);
yield return testEnumeraterYieldInstruction;
var enumerator = testEnumeraterYieldInstruction.Execute();
var executingEnumerator = ExecuteEnumerableAndRecordExceptions(enumerator, context);
while (executingEnumerator.MoveNext())
{
yield return executingEnumerator.Current;
}
}
else
{
if (context.CurrentResult.ResultState != ResultState.Ignored)
{
context.CurrentResult.SetResult(ResultState.Success);
}
}
}
private static IEnumerator ExecuteEnumerableAndRecordExceptions(IEnumerator enumerator, ITestExecutionContext context)
{
while (true)
{
try
{
if (!enumerator.MoveNext())
{
break;
}
}
catch (Exception ex)
{
context.CurrentResult.RecordException(ex);
break;
}
if (enumerator.Current is IEnumerator)
{
var current = (IEnumerator)enumerator.Current;
yield return ExecuteEnumerableAndRecordExceptions(current, context);
}
else
{
yield return enumerator.Current;
}
}
}
public override TestResult Execute(ITestExecutionContext context)
{
throw new NotImplementedException("Use ExecuteEnumerable");
}
}
}
fileFormatVersion: 2
guid: 19a6f000f81e24c4a826c1abd43e77c7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 19a6f000f81e24c4a826c1abd43e77c7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class ImmediateEnumerableCommand : DelegatingTestCommand
{
public ImmediateEnumerableCommand(TestCommand innerCommand)
: base(innerCommand) { }
public override TestResult Execute(ITestExecutionContext context)
{
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
if (iterator != null)
{
throw new Exception("Only null can be yielded at this point.");
}
}
return context.CurrentResult;
}
return innerCommand.Execute(context);
}
}
}
using System;
using System.Collections;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class ImmediateEnumerableCommand : DelegatingTestCommand
{
public ImmediateEnumerableCommand(TestCommand innerCommand)
: base(innerCommand) { }
public override TestResult Execute(ITestExecutionContext context)
{
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
if (iterator != null)
{
throw new Exception("Only null can be yielded at this point.");
}
}
return context.CurrentResult;
}
return innerCommand.Execute(context);
}
}
}
fileFormatVersion: 2
guid: 8349e42a2b30c7a4abd8678c203428ba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 8349e42a2b30c7a4abd8678c203428ba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class OuterUnityTestActionCommand : BeforeAfterTestCommandBase<IOuterUnityTestAction>
{
public OuterUnityTestActionCommand(TestCommand innerCommand)
: base(innerCommand, "BeforeTest", "AfterTest")
{
if (Test.TypeInfo.Type != null)
{
BeforeActions = GetUnityTestActionsFromMethod(Test.Method.MethodInfo);
AfterActions = BeforeActions;
}
}
private static IOuterUnityTestAction[] GetUnityTestActionsFromMethod(MethodInfo method)
{
var attributes = method.GetCustomAttributes(false);
List<IOuterUnityTestAction> actions = new List<IOuterUnityTestAction>();
foreach (var attribute in attributes)
{
if (attribute is IOuterUnityTestAction)
actions.Add(attribute as IOuterUnityTestAction);
}
return actions.ToArray();
}
protected override IEnumerator InvokeBefore(IOuterUnityTestAction action, Test test, UnityTestExecutionContext context)
{
return action.BeforeTest(test);
}
protected override IEnumerator InvokeAfter(IOuterUnityTestAction action, Test test, UnityTestExecutionContext context)
{
return action.AfterTest(test);
}
protected override BeforeAfterTestCommandState GetState(UnityTestExecutionContext context)
{
return context.OuterUnityTestActionState;
}
}
}
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class OuterUnityTestActionCommand : BeforeAfterTestCommandBase<IOuterUnityTestAction>
{
public OuterUnityTestActionCommand(TestCommand innerCommand)
: base(innerCommand, "BeforeTest", "AfterTest")
{
if (Test.TypeInfo.Type != null)
{
BeforeActions = GetUnityTestActionsFromMethod(Test.Method.MethodInfo);
AfterActions = BeforeActions;
}
}
private static IOuterUnityTestAction[] GetUnityTestActionsFromMethod(MethodInfo method)
{
var attributes = method.GetCustomAttributes(false);
List<IOuterUnityTestAction> actions = new List<IOuterUnityTestAction>();
foreach (var attribute in attributes)
{
if (attribute is IOuterUnityTestAction)
actions.Add(attribute as IOuterUnityTestAction);
}
return actions.ToArray();
}
protected override IEnumerator InvokeBefore(IOuterUnityTestAction action, Test test, UnityTestExecutionContext context)
{
return action.BeforeTest(test);
}
protected override IEnumerator InvokeAfter(IOuterUnityTestAction action, Test test, UnityTestExecutionContext context)
{
return action.AfterTest(test);
}
protected override BeforeAfterTestCommandState GetState(UnityTestExecutionContext context)
{
return context.OuterUnityTestActionState;
}
}
}
fileFormatVersion: 2
guid: 0d4fc309a0784294c8ab658b53b12320
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 0d4fc309a0784294c8ab658b53b12320
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using NUnit.Framework.Internal.Execution;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class SetUpTearDownCommand : BeforeAfterTestCommandBase<MethodInfo>
{
public SetUpTearDownCommand(TestCommand innerCommand)
: base(innerCommand, "SetUp", "TearDown", true)
{
if (Test.TypeInfo.Type != null)
{
BeforeActions = GetMethodsWithAttributeFromFixture(Test.TypeInfo.Type, typeof(SetUpAttribute));
AfterActions = GetMethodsWithAttributeFromFixture(Test.TypeInfo.Type, typeof(TearDownAttribute)).Reverse().ToArray();
}
}
private static MethodInfo[] GetMethodsWithAttributeFromFixture(Type fixtureType, Type setUpType)
{
MethodInfo[] methodsWithAttribute = Reflect.GetMethodsWithAttribute(fixtureType, setUpType, true);
return methodsWithAttribute.Where(x => x.ReturnType == typeof(void)).ToArray();
}
protected override IEnumerator InvokeBefore(MethodInfo action, Test test, UnityTestExecutionContext context)
{
Reflect.InvokeMethod(action, context.TestObject);
yield return null;
}
protected override IEnumerator InvokeAfter(MethodInfo action, Test test, UnityTestExecutionContext context)
{
Reflect.InvokeMethod(action, context.TestObject);
yield return null;
}
protected override BeforeAfterTestCommandState GetState(UnityTestExecutionContext context)
{
return null;
}
}
}
using System;
using System.Collections;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using NUnit.Framework.Internal.Execution;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class SetUpTearDownCommand : BeforeAfterTestCommandBase<MethodInfo>
{
public SetUpTearDownCommand(TestCommand innerCommand)
: base(innerCommand, "SetUp", "TearDown", true)
{
if (Test.TypeInfo.Type != null)
{
BeforeActions = GetMethodsWithAttributeFromFixture(Test.TypeInfo.Type, typeof(SetUpAttribute));
AfterActions = GetMethodsWithAttributeFromFixture(Test.TypeInfo.Type, typeof(TearDownAttribute)).Reverse().ToArray();
}
}
private static MethodInfo[] GetMethodsWithAttributeFromFixture(Type fixtureType, Type setUpType)
{
MethodInfo[] methodsWithAttribute = Reflect.GetMethodsWithAttribute(fixtureType, setUpType, true);
return methodsWithAttribute.Where(x => x.ReturnType == typeof(void)).ToArray();
}
protected override IEnumerator InvokeBefore(MethodInfo action, Test test, UnityTestExecutionContext context)
{
Reflect.InvokeMethod(action, context.TestObject);
yield return null;
}
protected override IEnumerator InvokeAfter(MethodInfo action, Test test, UnityTestExecutionContext context)
{
Reflect.InvokeMethod(action, context.TestObject);
yield return null;
}
protected override BeforeAfterTestCommandState GetState(UnityTestExecutionContext context)
{
return null;
}
}
}
fileFormatVersion: 2
guid: e0db3f3921670cd4ca2e925737c3fba4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: e0db3f3921670cd4ca2e925737c3fba4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using NUnit.Framework;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class TestActionCommand : BeforeAfterTestCommandBase<ITestAction>
{
public TestActionCommand(TestCommand innerCommand)
: base(innerCommand, "BeforeTest", "AfterTest", true)
{
if (Test.TypeInfo.Type != null)
{
BeforeActions = GetTestActionsFromMethod(Test.Method.MethodInfo);
AfterActions = BeforeActions;
}
}
private static ITestAction[] GetTestActionsFromMethod(MethodInfo method)
{
var attributes = method.GetCustomAttributes(false);
List<ITestAction> actions = new List<ITestAction>();
foreach (var attribute in attributes)
{
if (attribute is ITestAction)
actions.Add(attribute as ITestAction);
}
return actions.ToArray();
}
protected override IEnumerator InvokeBefore(ITestAction action, Test test, UnityTestExecutionContext context)
{
action.BeforeTest(test);
yield return null;
}
protected override IEnumerator InvokeAfter(ITestAction action, Test test, UnityTestExecutionContext context)
{
action.AfterTest(test);
yield return null;
}
protected override BeforeAfterTestCommandState GetState(UnityTestExecutionContext context)
{
return null;
}
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using NUnit.Framework;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class TestActionCommand : BeforeAfterTestCommandBase<ITestAction>
{
public TestActionCommand(TestCommand innerCommand)
: base(innerCommand, "BeforeTest", "AfterTest", true)
{
if (Test.TypeInfo.Type != null)
{
BeforeActions = GetTestActionsFromMethod(Test.Method.MethodInfo);
AfterActions = BeforeActions;
}
}
private static ITestAction[] GetTestActionsFromMethod(MethodInfo method)
{
var attributes = method.GetCustomAttributes(false);
List<ITestAction> actions = new List<ITestAction>();
foreach (var attribute in attributes)
{
if (attribute is ITestAction)
actions.Add(attribute as ITestAction);
}
return actions.ToArray();
}
protected override IEnumerator InvokeBefore(ITestAction action, Test test, UnityTestExecutionContext context)
{
action.BeforeTest(test);
yield return null;
}
protected override IEnumerator InvokeAfter(ITestAction action, Test test, UnityTestExecutionContext context)
{
action.AfterTest(test);
yield return null;
}
protected override BeforeAfterTestCommandState GetState(UnityTestExecutionContext context)
{
return null;
}
}
}
fileFormatVersion: 2
guid: 2de8ba3b840049641897e0da7ce1d5cd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 2de8ba3b840049641897e0da7ce1d5cd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment