Skip to content
Discussion options

You must be logged in to vote

Hi! Thanks for the report — the docs were misleading.

ClassDataSource<T> injects a single instance of T into the test; it does not enumerate T even when T : IEnumerable<U>. The example in the docs was wrong. I have just fixed it on main (commit 17294ad).

For your scenario you have two clean options:

1. MethodDataSource (simplest) — works directly with IEnumerable<T>:

public static class UsersDataSource
{
    public static IEnumerable<Users> All()
    {
        yield return new Users { Id = 1, Name = "1" };
        yield return new Users { Id = 2, Name = "2" };
    }
}

public class MyTest
{
    [Test]
    [MethodDataSource(typeof(UsersDataSource), nameof(UsersDataSource.All))]
    public a…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@elTRexx
Comment options

Answer selected by elTRexx
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