File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
test/Microsoft.ML.TestFrameworkCommon/Attributes Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the MIT license.
3+ // See the LICENSE file in the project root for more information.
4+
5+ using System . Collections . Generic ;
6+ using System . Reflection ;
7+ using Xunit . Sdk ;
8+
9+ namespace Microsoft . ML . TestFrameworkCommon . Attributes
10+ {
11+ /// <summary>
12+ /// xUnit data attribute that allows looping tests. The following example shows a test which will run 50 times.
13+ /// <code>
14+ /// [Theory, IterationData(50)]
15+ /// public void IteratingTest(int iteration)
16+ /// {
17+ /// }
18+ /// </code>
19+ /// </summary>
20+ public sealed class IterationDataAttribute : DataAttribute
21+ {
22+ public IterationDataAttribute ( int iterations = 100 )
23+ {
24+ Iterations = iterations ;
25+ }
26+
27+ public int Iterations { get ; }
28+
29+ public override IEnumerable < object [ ] > GetData ( MethodInfo testMethod )
30+ {
31+ for ( var i = 0 ; i < Iterations ; i ++ )
32+ {
33+ yield return new object [ ] { i } ;
34+ }
35+ }
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments