No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OuterUnityTestActionCommand.cs 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Reflection;
  5. using NUnit.Framework.Internal;
  6. using NUnit.Framework.Internal.Commands;
  7. using UnityEngine.TestRunner.NUnitExtensions.Runner;
  8. namespace UnityEngine.TestTools
  9. {
  10. internal class OuterUnityTestActionCommand : BeforeAfterTestCommandBase<IOuterUnityTestAction>
  11. {
  12. private static readonly Dictionary<MethodInfo, List<IOuterUnityTestAction>> m_TestActionsCache = new Dictionary<MethodInfo, List<IOuterUnityTestAction>>();
  13. public OuterUnityTestActionCommand(TestCommand innerCommand)
  14. : base(innerCommand, "BeforeTest", "AfterTest")
  15. {
  16. if (Test.TypeInfo.Type != null)
  17. {
  18. BeforeActions = GetTestActions(m_TestActionsCache, Test.Method.MethodInfo);
  19. AfterActions = BeforeActions;
  20. }
  21. }
  22. protected override IEnumerator InvokeBefore(IOuterUnityTestAction action, Test test, UnityTestExecutionContext context)
  23. {
  24. return action.BeforeTest(test);
  25. }
  26. protected override IEnumerator InvokeAfter(IOuterUnityTestAction action, Test test, UnityTestExecutionContext context)
  27. {
  28. return action.AfterTest(test);
  29. }
  30. protected override BeforeAfterTestCommandState GetState(UnityTestExecutionContext context)
  31. {
  32. return context.OuterUnityTestActionState;
  33. }
  34. }
  35. }