-
-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathDataSourceContext.cs
More file actions
82 lines (70 loc) · 2.21 KB
/
Copy pathDataSourceContext.cs
File metadata and controls
82 lines (70 loc) · 2.21 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
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
using System.Reflection;
namespace TUnit.Core;
/// <summary>
/// Context object providing information about where data is being requested from
/// </summary>
public sealed class DataSourceContext
{
/// <summary>
/// The type containing the test (for all levels)
/// </summary>
public Type TestClassType { get; }
/// <summary>
/// The member being targeted (TypeInfo for class, MethodInfo for method, PropertyInfo for property)
/// </summary>
public MemberInfo? TargetMember { get; }
/// <summary>
/// The parameter being targeted (null if not parameter-level)
/// </summary>
public ParameterInfo? TargetParameter { get; }
/// <summary>
/// The level at which the data source is being applied
/// </summary>
public DataSourceLevel Level { get; }
/// <summary>
/// Attributes on the target member or parameter
/// </summary>
public IReadOnlyList<Attribute> Attributes { get; }
/// <summary>
/// Service provider for dependency resolution (optional)
/// </summary>
public IServiceProvider? ServiceProvider { get; }
public DataSourceContext(
Type testClassType,
DataSourceLevel level,
MemberInfo? targetMember = null,
ParameterInfo? targetParameter = null,
IReadOnlyList<Attribute>? attributes = null,
IServiceProvider? serviceProvider = null)
{
TestClassType = testClassType ?? throw new ArgumentNullException(nameof(testClassType));
Level = level;
TargetMember = targetMember;
TargetParameter = targetParameter;
Attributes = attributes ?? [
];
ServiceProvider = serviceProvider;
}
}
/// <summary>
/// Indicates the level at which a data source is being applied
/// </summary>
public enum DataSourceLevel
{
/// <summary>
/// Data source applied at the class level (constructor parameters)
/// </summary>
Class,
/// <summary>
/// Data source applied at the method level (test method parameters)
/// </summary>
Method,
/// <summary>
/// Data source applied to a property
/// </summary>
Property,
/// <summary>
/// Data source applied to a specific parameter
/// </summary>
Parameter
}