RemoteTestResultDataFactory.cs
1.78 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
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework.Interfaces;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestRunner.TestLaunchers
{
internal class RemoteTestResultDataFactory : IRemoteTestResultDataFactory
{
public RemoteTestResultDataWithTestData CreateFromTestResult(ITestResult result)
{
var tests = CreateTestDataList(result.Test);
tests.First().testCaseTimeout = UnityTestExecutionContext.CurrentContext.TestCaseTimeout;
return new RemoteTestResultDataWithTestData()
{
results = CreateTestResultDataList(result),
tests = tests
};
}
public RemoteTestResultDataWithTestData CreateFromTest(ITest test)
{
var tests = CreateTestDataList(test);
if (UnityTestExecutionContext.CurrentContext != null)
{
tests.First().testCaseTimeout = UnityTestExecutionContext.CurrentContext.TestCaseTimeout;
}
return new RemoteTestResultDataWithTestData()
{
tests = tests
};
}
private RemoteTestData[] CreateTestDataList(ITest test)
{
var list = new List<RemoteTestData>();
list.Add(new RemoteTestData(test));
list.AddRange(test.Tests.SelectMany(CreateTestDataList));
return list.ToArray();
}
private static RemoteTestResultData[] CreateTestResultDataList(ITestResult result)
{
var list = new List<RemoteTestResultData>();
list.Add(new RemoteTestResultData(result));
list.AddRange(result.Children.SelectMany(CreateTestResultDataList));
return list.ToArray();
}
}
}