Problem Statement
The Returns method allows you to pass a factory through which you can access the arguments passed to the method. However, it seems that this feature is missing from ReturnsAsync.
Proposed Solution
A ReturnsAsync overload which allows to pass in a factory method and return a Task<T> from the method parameters:
mock
.DoSomethingAsync(Any<Func<Task<string>>>())
.ReturnsAsync(factory => factory.Invoke());
Alternatives Considered
It is possible to use .Returns and return Task<T>.Result:
mock
.DoSomethingAsync(Any<Func<Task<string>>>())
.Returns(factory => factory.Invoke().Result); // Exists but requires `Task<T>.Result`
Feature Category
Other
How important is this feature to you?
Nice to have - would improve my experience
Additional Context
No response
Contribution
Problem Statement
The
Returnsmethod allows you to pass a factory through which you can access the arguments passed to the method. However, it seems that this feature is missing fromReturnsAsync.Proposed Solution
A
ReturnsAsyncoverload which allows to pass in a factory method and return aTask<T>from the method parameters:Alternatives Considered
It is possible to use
.Returnsand returnTask<T>.Result:Feature Category
Other
How important is this feature to you?
Nice to have - would improve my experience
Additional Context
No response
Contribution