-
Notifications
You must be signed in to change notification settings - Fork 391
/
Copy pathTestData.cs
114 lines (96 loc) · 3.69 KB
/
TestData.cs
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
109
110
111
112
113
114
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Collections;
using System.Reflection;
namespace System.CommandLine.Subsystems.Tests;
internal class TestData
{
internal static readonly string? AssemblyVersionString = (Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly())
?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
?.InformationalVersion;
internal class Version : IEnumerable<object[]>
{
// This data only works if the CLI has a --version with a -v alias and also has a -x option
private readonly List<object[]> _data =
[
["--version", true],
["-v", true],
["-vx", true],
["-xv", true],
["-x", false],
[null, false],
["", false],
];
public IEnumerator<object[]> GetEnumerator() => _data.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
internal class Diagram : IEnumerable<object[]>
{
// The tests define an x command, but -o and -v are just random values
private readonly List<object[]> _data =
[
["[diagram]", true],
["[diagram] x", true],
["[diagram] -o", true],
["[diagram] -v", true],
["[diagram] x -v", true],
["[diagramX]", false],
["[diagram] [other]", true],
["x", false],
["-o", false],
["x -x", false],
[null, false],
["", false]
];
public IEnumerator<object[]> GetEnumerator() => _data.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
internal class Directive : IEnumerable<object[]>
{
private readonly List<object[]> _data =
[
["[diagram]", true, false, null],
["[other:Hello]", false, true, "Hello"],
["[diagram] x", true, false, null],
["[diagram] -o", true, false, null],
["[diagram] -v", true, false, null],
["[diagram] x -v", true, false, null],
["[diagramX]", false, false, null],
["[diagram] [other:Hello]", true, true, "Hello"],
["x", false, false, null],
["-o", false, false, null],
["x -x", false, false, null],
[null, false, false, null],
["", false, false, null],
//["[diagram] [other Goodbye]", true, true, "Goodbye"],This is a new test that demos new feature, but is also broken
];
public IEnumerator<object[]> GetEnumerator() => _data.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
internal class Value : IEnumerable<object[]>
{
private readonly List<object[]> _data =
[
["--intValue", 42],
["--stringValue", "43"],
["--boolValue", true]
];
public IEnumerator<object[]> GetEnumerator() => _data.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
internal class Help : IEnumerable<object[]>
{
private readonly List<object[]> _data =
[
["--help", true],
["-h", true],
["-hx", true],
["-xh", true],
["-x", false],
[null, false],
["", false],
];
public IEnumerator<object[]> GetEnumerator() => _data.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}