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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
using System.Linq;
using System.Collections.Generic;
using NUnit.Framework;
using System.Runtime.CompilerServices;
using System.IO;
using Mono.Linker.Tests.TestCasesRunner;
namespace Mono.Linker.Tests.TestCases
{
static class TestDatabase
{
public static IEnumerable<TestCaseData> XmlTests()
{
return NUnitCasesByPrefix("LinkXml.");
}
public static IEnumerable<TestCaseData> BasicTests()
{
return NUnitCasesByPrefix("Basic.");
}
public static IEnumerable<TestCaseData> VirtualMethodsTests()
{
return NUnitCasesByPrefix("VirtualMethods.");
}
public static IEnumerable<TestCaseData> AttributeTests()
{
return NUnitCasesByPrefix("Attributes.");
}
public static IEnumerable<TestCaseData> GenericsTests()
{
return NUnitCasesByPrefix("Generics.");
}
public static IEnumerable<TestCaseData> CoreLinkTests()
{
return NUnitCasesByPrefix("CoreLink.");
}
public static IEnumerable<TestCaseData> StaticsTests()
{
return NUnitCasesByPrefix("Statics.");
}
public static IEnumerable<TestCaseData> InteropTests()
{
return NUnitCasesByPrefix("Interop.");
}
public static IEnumerable<TestCaseData> ReferencesTests()
{
return NUnitCasesByPrefix("References.");
}
public static IEnumerable<TestCaseData> OtherTests()
{
var allGroupedTestNames = new HashSet<string>(
XmlTests()
.Concat(BasicTests())
.Concat(XmlTests())
.Concat(VirtualMethodsTests())
.Concat(AttributeTests())
.Concat(GenericsTests())
.Concat(CoreLinkTests())
.Concat(StaticsTests())
.Concat(InteropTests())
.Concat(ReferencesTests ())
.Select(c => ((TestCase)c.Arguments[0]).ReconstructedFullTypeName));
return AllCases().Where(c => !allGroupedTestNames.Contains(c.ReconstructedFullTypeName)).Select(c => CreateNUnitTestCase(c, c.DisplayName));
}
static IEnumerable<TestCase> AllCases()
{
string rootSourceDirectory;
string testCaseAssemblyPath;
GetDirectoryPaths(out rootSourceDirectory, out testCaseAssemblyPath);
return new TestCaseCollector(rootSourceDirectory, testCaseAssemblyPath)
.Collect()
.OrderBy(c => c.DisplayName)
.ToArray();
}
static IEnumerable<TestCaseData> NUnitCasesByPrefix(string testNamePrefix)
{
return AllCases()
.Where(c => c.DisplayName.StartsWith(testNamePrefix))
.Select(c => CreateNUnitTestCase(c, c.DisplayName.Substring(testNamePrefix.Length)))
.OrderBy(c => c.TestName);
}
static TestCaseData CreateNUnitTestCase(TestCase testCase, string displayName)
{
var data = new TestCaseData(testCase);
data.SetName(displayName);
return data;
}
static void GetDirectoryPaths(out string rootSourceDirectory, out string testCaseAssemblyPath, [CallerFilePath] string thisFile = null)
{
var thisDirectory = Path.GetDirectoryName(thisFile);
rootSourceDirectory = Path.GetFullPath(Path.Combine(thisDirectory, "..", "Mono.Linker.Tests.Cases"));
testCaseAssemblyPath = Path.GetFullPath(Path.Combine(rootSourceDirectory, "bin", "Debug", "Mono.Linker.Tests.Cases.dll"));
}
}
}
|