Skip to content

Commit

Permalink
Merge pull request #836 from stevenaw/iasync-enumerable
Browse files Browse the repository at this point in the history
A few points for Task<> and IAsyncEnumerable<> support on *Source attributes
  • Loading branch information
stevenaw authored Nov 11, 2023
2 parents e0d5f3f + d3a0437 commit f59fe5b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ It has the following characteristics:
* It **must** be static. This is a change from NUnit 2.x.
* It must return an `IEnumerable` or a type that implements `IEnumerable`. For fields an array is generally used. For
properties and methods, you may return an array or implement your own iterator.
* Methods may also return an `IAsyncEnumerable` or a type that implements `IAsyncEnumerable`. (_NUnit 4+_)
* Methods may be async by wrapping the return type in a `Task<T>`. (_NUnit 3.14+_)
* The individual items returned by the enumerator must be compatible with the signature of the method on which the
attribute appears. See the **Test Case Construction** section below for details.

Expand All @@ -53,6 +55,8 @@ characteristics:
* It **must** be static. This is a change from NUnit 2.x.
* It must return an `IEnumerable` or a type that implements `IEnumerable`. For fields an array is generally used. For
properties and methods, you may return an array or implement your own iterator.
* Methods may also return an `IAsyncEnumerable` or a type that implements `IAsyncEnumerable`. (_NUnit 4+_)
* Methods may be async by wrapping the return type in a `Task<T>`. (_NUnit 3.14+_)
* The individual items returned by the enumerator must be compatible with the signature of the method on which the
attribute appears. See the **Test Case Construction** section below for details.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ constructing the `TestFixture`. It has the following characteristics:
* It **must** be static.
* It must return an `IEnumerable` or a type that implements `IEnumerable`. For fields an array is generally used. For
properties and methods, you may return an array or implement your own iterator.
* Methods may also return an `IAsyncEnumerable` or a type that implements `IAsyncEnumerable`. (_NUnit 4+_)
* Methods may be async by wrapping the return type in a `Task<T>`. (_NUnit 3.14+_)
* The individual items returned by the enumerator must either be object arrays or derive from the
`TestFixtureParameters` class. Arguments must be consistent with the fixture constructor.

Expand Down Expand Up @@ -66,6 +68,8 @@ characteristics:
* It **must** be static.
* It must return an `IEnumerable` or a type that implements `IEnumerable`. For fields an array is generally used. For
properties and methods, you may return an array or implement your own iterator.
* Methods may also return an `IAsyncEnumerable` or a type that implements `IAsyncEnumerable`. (_NUnit 4+_)
* Methods may be async by wrapping the return type in a `Task<T>`. (_NUnit 3.14+_)
* The individual items returned by the enumerator must either be object arrays or derive from the
`TestFixtureParameters` class. Arguments must be consistent with the fixture constructor.

Expand Down
4 changes: 3 additions & 1 deletion docs/articles/nunit/writing-tests/attributes/valuesource.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ characteristics:

* It may be a field, a non-indexed property or a method taking no arguments.
* It must be a static member.
* It must return an IEnumerable or a type that implements IEnumerable.
* It must return an `IEnumerable` or a type that implements `IEnumerable`.
* Methods may also return an `IAsyncEnumerable` or a type that implements `IAsyncEnumerable`. (_NUnit 4+_)
* Methods may be async by wrapping the return type in a `Task<T>`. (_NUnit 3.14+_)
* The individual items returned from the enumerator must be compatible with the type of the parameter on which the
attribute appears.

Expand Down

0 comments on commit f59fe5b

Please sign in to comment.