-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,13 +15,29 @@ public ClassAutoNSubstituteDataAttribute(Type @class) | |
|
||
public override IEnumerable<object[]> GetData(MethodInfo testMethod) | ||
{ | ||
var parameters = testMethod.GetParameters(); | ||
var frozenValues = parameters | ||
.Select((p, i) => (Index: i, Parameter: p, p.ParameterType)) | ||
.Where(x => x.Parameter.GetCustomAttribute<FrozenAttribute>() != null) | ||
.ToArray(); | ||
var injectMethod = typeof(FixtureRegistrar) | ||
.GetMethod( | ||
nameof(FixtureRegistrar.Inject), | ||
BindingFlags.Public | BindingFlags.Static); | ||
|
||
var data = base.GetData(testMethod); | ||
foreach (var values in data) | ||
{ | ||
var fixture = FixtureFactory.Create(); | ||
foreach (var frozenValue in frozenValues) | ||
{ | ||
injectMethod? | ||
.MakeGenericMethod(frozenValue.ParameterType) | ||
.Invoke(null, [fixture, values[frozenValue.Index]]); | ||
Check failure on line 36 in src/Atc.Test/ClassAutoNSubstituteDataAttribute.cs GitHub Actions / dotnet-build (ubuntu-latest)
Check failure on line 36 in src/Atc.Test/ClassAutoNSubstituteDataAttribute.cs GitHub Actions / dotnet-build (ubuntu-latest)
Check failure on line 36 in src/Atc.Test/ClassAutoNSubstituteDataAttribute.cs GitHub Actions / dotnet-build (ubuntu-latest)
Check failure on line 36 in src/Atc.Test/ClassAutoNSubstituteDataAttribute.cs GitHub Actions / dotnet-build (ubuntu-latest)
Check failure on line 36 in src/Atc.Test/ClassAutoNSubstituteDataAttribute.cs GitHub Actions / dotnet-build (macos-latest)
Check failure on line 36 in src/Atc.Test/ClassAutoNSubstituteDataAttribute.cs GitHub Actions / dotnet-build (macos-latest)
Check failure on line 36 in src/Atc.Test/ClassAutoNSubstituteDataAttribute.cs GitHub Actions / dotnet-build (macos-latest)
Check failure on line 36 in src/Atc.Test/ClassAutoNSubstituteDataAttribute.cs GitHub Actions / dotnet-build (macos-latest)
|
||
} | ||
|
||
yield return values | ||
.Concat(testMethod | ||
.GetParameters() | ||
.Concat(parameters | ||
.Skip(values.Length) | ||
.Select(p => GetSpecimen(fixture, p))) | ||
.ToArray(); | ||
|