ImmediateEnumerableCommand.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections;
  3. using NUnit.Framework.Internal;
  4. using NUnit.Framework.Internal.Commands;
  5. using UnityEngine.TestRunner.NUnitExtensions.Runner;
  6. namespace UnityEngine.TestTools
  7. {
  8. internal class ImmediateEnumerableCommand : DelegatingTestCommand
  9. {
  10. public ImmediateEnumerableCommand(TestCommand innerCommand)
  11. : base(innerCommand) { }
  12. public override TestResult Execute(ITestExecutionContext context)
  13. {
  14. if (innerCommand is IEnumerableTestMethodCommand)
  15. {
  16. var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
  17. foreach (var iterator in executeEnumerable)
  18. {
  19. if (iterator != null)
  20. {
  21. throw new Exception("Only null can be yielded at this point.");
  22. }
  23. }
  24. return context.CurrentResult;
  25. }
  26. return innerCommand.Execute(context);
  27. }
  28. }
  29. }