TestEnumerator.cs
1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
namespace UnityEngine.TestTools
{
internal class TestEnumerator
{
private readonly ITestExecutionContext m_Context;
private static IEnumerator m_TestEnumerator;
public static IEnumerator Enumerator { get { return m_TestEnumerator; } }
public static void Reset()
{
m_TestEnumerator = null;
}
public TestEnumerator(ITestExecutionContext context, IEnumerator testEnumerator)
{
m_Context = context;
m_TestEnumerator = testEnumerator;
}
public IEnumerator Execute()
{
m_Context.CurrentResult.SetResult(ResultState.Success);
while (true)
{
object current = null;
try
{
if (!m_TestEnumerator.MoveNext())
{
yield break;
}
if (!m_Context.CurrentResult.ResultState.Equals(ResultState.Success))
{
yield break;
}
current = m_TestEnumerator.Current;
}
catch (Exception exception)
{
m_Context.CurrentResult.RecordException(exception);
yield break;
}
yield return current;
}
}
}
}