Skip to content

Commit 6c73818

Browse files
authored
repeat tests to stabilize coverage (#429)
* repeat * repeat lfu * undo lfu ---------
1 parent b1b7b7c commit 6c73818

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

BitFaster.Caching.UnitTests/Buffers/MpmcBoundedBufferSoakTests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ public MpmcBoundedBufferSoakTests(ITestOutputHelper testOutputHelper)
2121
this.testOutputHelper = testOutputHelper;
2222
}
2323

24-
[Fact]
25-
public async Task WhenAddIsContendedBufferCanBeFilled()
24+
[Theory]
25+
[Repeat(3)]
26+
public async Task WhenAddIsContendedBufferCanBeFilled(int iteration)
2627
{
28+
this.testOutputHelper.WriteLine($"Iteration {iteration}");
29+
2730
await Threaded.Run(4, () =>
2831
{
2932
while (buffer.TryAdd("hello") != BufferStatus.Full)

BitFaster.Caching.UnitTests/Buffers/MpscBoundedBufferSoakTests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ public MpscBoundedBufferSoakTests(ITestOutputHelper testOutputHelper)
2121
this.testOutputHelper = testOutputHelper;
2222
}
2323

24-
[Fact]
25-
public async Task WhenAddIsContendedBufferCanBeFilled()
24+
[Theory]
25+
[Repeat(3)]
26+
public async Task WhenAddIsContendedBufferCanBeFilled(int iteration)
2627
{
28+
this.testOutputHelper.WriteLine($"Iteration {iteration}");
29+
2730
await Threaded.Run(4, () =>
2831
{
2932
while (buffer.TryAdd("hello") != BufferStatus.Full)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Linq;
2+
3+
namespace BitFaster.Caching.UnitTests
4+
{
5+
public sealed class RepeatAttribute : Xunit.Sdk.DataAttribute
6+
{
7+
private readonly int count;
8+
9+
public RepeatAttribute(int count)
10+
{
11+
if (count < 1)
12+
{
13+
throw new System.ArgumentOutOfRangeException(
14+
paramName: nameof(count),
15+
message: "Repeat count must be greater than 0."
16+
);
17+
}
18+
this.count = count;
19+
}
20+
21+
public override System.Collections.Generic.IEnumerable<object[]> GetData(System.Reflection.MethodInfo testMethod)
22+
{
23+
foreach (var iterationNumber in Enumerable.Range(start: 1, count: this.count))
24+
{
25+
yield return new object[] { iterationNumber };
26+
}
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)