-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Snowflake.Data.Tests.Util | ||
{ | ||
public class TestRepeater<T> | ||
{ | ||
private readonly List<T> _result; | ||
|
||
private TestRepeater(List<T> result) | ||
{ | ||
_result = result; | ||
} | ||
|
||
public void ForEach(Action<T> action) => _result.ForEach(action); | ||
|
||
public TestRepeater<T> SkipLargest<TKey>(Func<T, TKey> keySelector) | ||
{ | ||
var resultsWithoutLargest = _result.OrderBy(keySelector).SkipLast(1).ToList(); | ||
Check failure on line 20 in Snowflake.Data.Tests/Util/TestRepeater.cs GitHub Actions / Tests on Windows (net471, GCP)
Check failure on line 20 in Snowflake.Data.Tests/Util/TestRepeater.cs GitHub Actions / Tests on Windows (net471, GCP)
Check failure on line 20 in Snowflake.Data.Tests/Util/TestRepeater.cs GitHub Actions / Tests on Windows (net471, AWS)
Check failure on line 20 in Snowflake.Data.Tests/Util/TestRepeater.cs GitHub Actions / Tests on Windows (net471, AWS)
Check failure on line 20 in Snowflake.Data.Tests/Util/TestRepeater.cs GitHub Actions / Tests on Windows (net471, AZURE)
Check failure on line 20 in Snowflake.Data.Tests/Util/TestRepeater.cs GitHub Actions / Tests on Windows (net471, AZURE)
Check failure on line 20 in Snowflake.Data.Tests/Util/TestRepeater.cs GitHub Actions / Tests on Windows (net472, AWS)
Check failure on line 20 in Snowflake.Data.Tests/Util/TestRepeater.cs GitHub Actions / Tests on Windows (net472, AWS)
Check failure on line 20 in Snowflake.Data.Tests/Util/TestRepeater.cs GitHub Actions / Tests on Windows (net472, GCP)
Check failure on line 20 in Snowflake.Data.Tests/Util/TestRepeater.cs GitHub Actions / Tests on Windows (net472, GCP)
Check failure on line 20 in Snowflake.Data.Tests/Util/TestRepeater.cs GitHub Actions / Tests on Windows (net472, AZURE)
Check failure on line 20 in Snowflake.Data.Tests/Util/TestRepeater.cs GitHub Actions / Tests on Windows (net472, AZURE)
|
||
return new TestRepeater<T>(resultsWithoutLargest); | ||
} | ||
|
||
public static TestRepeater<T> Test(int times, Func<T> testFunction) | ||
{ | ||
var resultList = Enumerable.Repeat(0, times) | ||
.Select(_ => testFunction()) | ||
.ToList(); | ||
return new TestRepeater<T>(resultList); | ||
} | ||
} | ||
} |