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.

ParametrizedIgnoreCommand.cs 1.1KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using NUnit.Framework.Interfaces;
  2. using NUnit.Framework.Internal;
  3. using NUnit.Framework.Internal.Commands;
  4. using System.Linq;
  5. namespace UnityEngine.TestTools
  6. {
  7. internal class ParametrizedIgnoreCommand : TestCommand
  8. {
  9. private readonly TestCommand m_Command;
  10. public object[] Arguments { get; }
  11. public string Reason { get; }
  12. public ParametrizedIgnoreCommand(TestCommand command, object[] arguments, string reason = "") : base(command.Test)
  13. {
  14. m_Command = command;
  15. Arguments = arguments;
  16. Reason = reason;
  17. }
  18. public override TestResult Execute(ITestExecutionContext context)
  19. {
  20. if (context.CurrentTest is TestMethod testMethod)
  21. {
  22. var isIgnored = testMethod.parms.Arguments.SequenceEqual(Arguments);
  23. if (isIgnored)
  24. {
  25. context.CurrentResult.SetResult(ResultState.Ignored, Reason);
  26. return context.CurrentResult;
  27. }
  28. }
  29. return m_Command.Execute(context);
  30. }
  31. }
  32. }