-
-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathRepeatAttribute.cs
More file actions
32 lines (26 loc) · 823 Bytes
/
RepeatAttribute.cs
File metadata and controls
32 lines (26 loc) · 823 Bytes
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
using System.Reflection;
using Xunit.Sdk;
using Xunit.v3;
namespace Xunit;
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public sealed class RepeatAttribute : DataAttribute
{
public int Count { get; }
public RepeatAttribute(int count)
{
if (count < 1)
{
throw new ArgumentOutOfRangeException(
paramName: nameof(count),
message: "Repeat count must be greater than 0.");
}
Count = count;
}
public override ValueTask<IReadOnlyCollection<ITheoryDataRow>> GetData(MethodInfo testMethod,
DisposalTracker disposalTracker)
{
var rows = Enumerable.Range(1, Count).Select(i => new TheoryDataRow(new object[] { i })).ToArray();
return new ValueTask<IReadOnlyCollection<ITheoryDataRow>>(rows);
}
public override bool SupportsDiscoveryEnumeration() => false;
}