Skip to content

Migrate Test Method With Generics #945

Answered by thomhurst
viceroypenguin asked this question in Q&A
Discussion options

You must be logged in to vote

@viceroypenguin I had to make some changes to TUnit to support generic tests like this, but it works!
Example here: https://github.com/thomhurst/TUnit/blob/main/TUnit.TestProject/GenericMethodTests.cs

public class GenericMethodTests
{
    [Test]
    [MethodDataSource(nameof(AggregateBy_Numeric_TestData))]
    [MethodDataSource(nameof(AggregateBy_String_TestData))]
    public void AggregateBy_HasExpectedOutput<TSource, TKey, TAccumulate>(
        IEnumerable<TSource> source,
        Func<TSource, TKey> keySelector,
        Func<TKey, TAccumulate> seedSelector,
        Func<TAccumulate, TSource, TAccumulate> func,
        IEqualityComparer<TKey>? comparer,
        IEnumerable<KeyValuePair<TKey

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@thomhurst
Comment options

@viceroypenguin
Comment options

@thomhurst
Comment options

@thomhurst
Comment options

Answer selected by viceroypenguin
@viceroypenguin
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants