EnumerableApplyChangesToContextCommand.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using NUnit.Framework.Interfaces;
  4. using NUnit.Framework.Internal;
  5. using NUnit.Framework.Internal.Commands;
  6. using UnityEngine.TestRunner.NUnitExtensions.Runner;
  7. namespace UnityEngine.TestTools
  8. {
  9. internal class EnumerableApplyChangesToContextCommand : ApplyChangesToContextCommand, IEnumerableTestMethodCommand
  10. {
  11. public EnumerableApplyChangesToContextCommand(TestCommand innerCommand, IEnumerable<IApplyToContext> changes)
  12. : base(innerCommand, changes) { }
  13. public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
  14. {
  15. ApplyChanges(context);
  16. if (innerCommand is IEnumerableTestMethodCommand)
  17. {
  18. var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
  19. foreach (var iterator in executeEnumerable)
  20. {
  21. yield return iterator;
  22. }
  23. }
  24. else
  25. {
  26. context.CurrentResult = innerCommand.Execute(context);
  27. }
  28. }
  29. }
  30. }