forked from SimonCropp/XunitContext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoggingContext_Parameters.cs
40 lines (33 loc) · 1.02 KB
/
LoggingContext_Parameters.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
using System.Collections.Generic;
using System.Linq;
using Xunit.Abstractions;
namespace XunitLogger
{
public partial class Context
{
List<Parameter>? parameters;
public IReadOnlyList<Parameter> Parameters
{
get => parameters ??= GetParameters(Test.TestCase);
}
static List<Parameter> empty = new List<Parameter>();
#region Parameters
static List<Parameter> GetParameters(ITestCase testCase)
{
var arguments = testCase.TestMethodArguments;
if (arguments == null || !arguments.Any())
{
return empty;
}
var items = new List<Parameter>();
var method = testCase.TestMethod;
var infos = method.Method.GetParameters().ToList();
for (var index = 0; index < infos.Count; index++)
{
items.Add(new Parameter(infos[index], arguments[index]));
}
return items;
}
#endregion
}
}