BeforeAfterTestCommandState.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using NUnit.Framework.Interfaces;
  2. using NUnit.Framework.Internal;
  3. namespace UnityEngine.TestTools
  4. {
  5. internal class BeforeAfterTestCommandState : ScriptableObject
  6. {
  7. public int NextBeforeStepIndex;
  8. public int NextBeforeStepPc;
  9. public int NextAfterStepIndex;
  10. public int NextAfterStepPc;
  11. public bool TestHasRun;
  12. public TestStatus CurrentTestResultStatus;
  13. public string CurrentTestResultLabel;
  14. public FailureSite CurrentTestResultSite;
  15. public string CurrentTestMessage;
  16. public string CurrentTestStrackTrace;
  17. public bool TestAfterStarted;
  18. public void Reset()
  19. {
  20. NextBeforeStepIndex = 0;
  21. NextBeforeStepPc = 0;
  22. NextAfterStepIndex = 0;
  23. NextAfterStepPc = 0;
  24. TestHasRun = false;
  25. CurrentTestResultStatus = TestStatus.Inconclusive;
  26. CurrentTestResultLabel = null;
  27. CurrentTestResultSite = default(FailureSite);
  28. CurrentTestMessage = null;
  29. CurrentTestStrackTrace = null;
  30. TestAfterStarted = false;
  31. }
  32. public void StoreTestResult(TestResult result)
  33. {
  34. CurrentTestResultStatus = result.ResultState.Status;
  35. CurrentTestResultLabel = result.ResultState.Label;
  36. CurrentTestResultSite = result.ResultState.Site;
  37. CurrentTestMessage = result.Message;
  38. CurrentTestStrackTrace = result.StackTrace;
  39. }
  40. public void ApplyTestResult(TestResult result)
  41. {
  42. result.SetResult(new ResultState(CurrentTestResultStatus, CurrentTestResultLabel, CurrentTestResultSite), CurrentTestMessage, CurrentTestStrackTrace);
  43. }
  44. }
  45. }