Automatic cancellation support
See original GitHub issueI have a lot of dependencies with (usually async
) methods that accept a CancellationToken
. When the token is cancelled, these methods throw an OperationCanceledException
. This is the expected implicit behavior for these methods, but by default, fakes don’t throw anything when they receive a call with a cancelled token. So my thinking is that this behavior could be baked into FakeItEasy as a default rule. Currently I use a method like this:
private static void ConfigureCancellation(object obj)
{
A.CallTo(obj)
.WhenArgumentsMatch(args => args.OfType<CancellationToken>().Any(ct => ct.IsCancellationRequested))
.Invokes(call => call.Arguments.OfType<CancellationToken>().FirstOrDefault(ct => ct.IsCancellationRequested).ThrowIfCancellationRequested());
}
It works fine, but I have to remember to call it on each fake.
Note that enabling this by default would, technically, be a breaking change, although probably not one that would affect many users.
Issue Analytics
- State:
- Created 7 years ago
- Comments:28 (28 by maintainers)
Top Results From Across the Web
Automatic cancellation Sample Clauses
Automatic cancellation. The Commitment of each Lender will be automatically cancelled at the close of business on the last day of the Availability...
Read more >Auto Cancellation Rule FAQs
My reservation is cancelled due to the auto cancellation rule. However, I still need to travel. Will I be able to obtain the...
Read more >How do I stop automatic payments from my bank account?
Further, cancelling your automatic payment does not cancel your contract with the company. If you want to cancel a contract for a service,...
Read more >Automatic Cancellation
Automatic Cancellation. How is it possible that I return all of the equipment I purchased from Simplisafe, they credit me for that return, ......
Read more >Travel: Auto Cancel Fact Sheet
Concur Travel's auto-cancel process supports agent-claimed trips. The auto-cancel robot will look for the presence of a standard remark in the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m fine with it being part of 3.0.0.
There’s no firm definition of the phases, but the way I see it is:
I think beta is the “grey zone” and is the tough one to call. Alpha and RC are relatively easy. I think it’s reasonable to call beta if nothing more is planned to change at that time the beta is released, and this is what we did in this case.
I’m fine with leaving it open if we still want to explore other ways of doing it.