File tree Expand file tree Collapse file tree 2 files changed +51
-1
lines changed
Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Original file line number Diff line number Diff line change 1+ namespace Atc . Test ;
2+
3+ /// <summary>
4+ /// Provides a data source for a data theory, with the data coming from
5+ /// a class implementing IEnumerable<object[]>, combined with auto-generated data
6+ /// specimens generated by AutoFixture and NSubstitute.
7+ /// </summary>
8+ [ AttributeUsage ( AttributeTargets . Method , AllowMultiple = true ) ]
9+ public sealed class ClassAutoNSubstituteDataAttribute : ClassDataAttribute
10+ {
11+ public ClassAutoNSubstituteDataAttribute ( Type @class )
12+ : base ( @class )
13+ {
14+ }
15+
16+ public override IEnumerable < object [ ] > GetData ( MethodInfo testMethod )
17+ {
18+ var data = base . GetData ( testMethod ) ;
19+ foreach ( var values in data )
20+ {
21+ var fixture = FixtureFactory . Create ( ) ;
22+ yield return values
23+ . Concat ( testMethod
24+ . GetParameters ( )
25+ . Skip ( values . Length )
26+ . Select ( p => GetSpecimen ( fixture , p ) ) )
27+ . ToArray ( ) ;
28+ }
29+ }
30+
31+ private static object GetSpecimen (
32+ IFixture fixture ,
33+ ParameterInfo parameter )
34+ {
35+ var attributes = parameter
36+ . GetCustomAttributes ( )
37+ . OfType < IParameterCustomizationSource > ( )
38+ . OrderBy ( x => x is FrozenAttribute ) ;
39+
40+ foreach ( var attribute in attributes )
41+ {
42+ attribute
43+ . GetCustomization ( parameter )
44+ . Customize ( fixture ) ;
45+ }
46+
47+ return new SpecimenContext ( fixture )
48+ . Resolve ( parameter ) ;
49+ }
50+ }
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ namespace Atc.Test;
33/// <summary>
44/// Provides a data source for a data theory, with the data coming from
55/// one of the following sources and combined with auto-generated data
6- /// specimens generated by AutoFixture and NSubstitute:
6+ /// specimens generated by AutoFixture and NSubstitute.
77/// <list type="number">
88/// <item>A static property</item>
99/// <item>A static field</item>
You can’t perform that action at this time.
0 commit comments