Closed as not planned
Closed as not planned
Description
Category
- Feature request
Describe the feature
When mocking async methods that require a cancellation token you can use It.IsAny<CancellationToken>()
syntax like this:
myMock.Setup(m => m.DoSomethingAsync(It.IsAny<CancellationToken>()));
I propose adding a new method to It
class for matching cancellation tokens, that does exactly the same:
myMock.Setup(m => m.DoSomethingAsync(It.IsCancellationToken()));
Rationale:
- It's slightly more readable and less verbose than
It.IsAny<>
syntax.. Readable code is good 👍 - Async methods are extremely common and mocking them is common as well.
- It's purely syntactic sugar. It breaks nothing.
- Code completion will be easier. Right now you need to do it in two steps (IsAny + CancellationToken in generic params).
It
class is static, so you cannot add an extension method with similar behaviour on your own.