Skip to content

TestCaseSource to recognize new async streams #3391

Description

@SavchukSergey

Would be nice to have support new .net core 3.0 async streams feature.

[Test, TestCaseSource(nameof(EnumerateAsync))]
public void AsyncStreamTest(object val) {
    Assert.IsNotNull(val);
}

public static async IAsyncEnumerable<object> EnumerateAsync()  {
    yield return await Create();
    yield return await Create();
}

public static Task<object> Create() {
    return Task.FromResult(new object());
}

Currently it says:

  X AsyncStreamTest [< 1ms]
  Error Message:
   System.InvalidCastException : Unable to cast object of type '<EnumerateAsync>d__1' to type 'System.Collections.IEnumerable'.
  Stack Trace:
     at NUnit.Framework.TestCaseSourceAttribute.GetTestCaseSource(IMethodInfo method)
   at NUnit.Framework.TestCaseSourceAttribute.GetTestCasesFor(IMethodInfo method)

Activity

  1. AnthonyMastrean commented on Jan 20, 2022

    @AnthonyMastrean

    Duplicates #2729?

  2. SavchukSergey commented on Jan 20, 2022

    @SavchukSergey
    Author

    Hello @AnthonyMastrean

    This issue is little different from #2729

    #3391 refers to IAsyncEnumerable interface while #2729 refers to pure IEnumerable

  3. self-assigned this
    on Oct 10, 2023
  4. stevenaw commented on Oct 14, 2023

    @stevenaw
    Member

    Closing this as I think this is a duplicate of #3043

  5. removed this from the Closed Without Action milestone on Oct 15, 2023
  6. stevenaw commented on Oct 15, 2023

    @stevenaw
    Member

    Reopening. I'd originally thought this may make sense to tackle in #3391 but I'm reconsidering now

  7. added this to the 4.0 milestone on Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions