Skip to content

Commit

Permalink
Use TheoryData for strongly typed test data
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDesmond-ca committed Nov 29, 2024
1 parent c206b3a commit 4d3edf3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions BenchmarkMockNet.Tests/BenchmarkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ public static class BenchmarkTests
{ typeof(Verify), result => result is null }
};

public static IEnumerable<object[]> Matrix
public static TheoryData<Type, MethodInfo> Matrix
{
get
{
var matrix = new List<object[]>();
var matrix = new TheoryData<Type, MethodInfo>();
foreach (var benchmark in Benchmarks)
{
matrix.AddRange(Methods.Select(method => new object[] { benchmark.Key, method }));
foreach (var method in Methods)
{
matrix.Add(benchmark.Key, method);
}
}

return matrix;
Expand All @@ -42,7 +45,7 @@ public static void RunAll(Type type, MethodInfo library)
var method = benchmark?.GetType().GetMethod(library.Name);

//act
var result = method?.Invoke(benchmark, Array.Empty<object>());
var result = method?.Invoke(benchmark, []);

//assert
var assertion = Benchmarks[type];
Expand Down

0 comments on commit 4d3edf3

Please sign in to comment.