Closed RenanCarlosPereira closed 3 months ago
@asulwer In this test I show how we can access the cancellation token without breaking changes.
users can cancel access to the cancellation token in the context.
check out the original documentation to see how actions work: https://microsoft.github.io/RulesEngine/#custom-actions π
I had some tests planned, but you beat me to it. thank you.
Nice, could you merge the PR, It's important to merge it always by another person π
oops! all PR's must have a branch associated with it. i didnt see a branch for this PR, did i miss it?
and an open issue that can close when the merge is successful
this PR didn't have a branch because I'm working on my fork and merging it into yours.
it doesn't sound easy to test your PR. i do not really want to keep a copy of other developers forks just to test their PR, assuming it works that way.
It works that way, I can open a branch in your fork, but just because Im a contributor, other people will have to fork them change whatever they are suggesting and then create a PR.
Thats the normal flow, only contributors can open branches in your fork π
thank you for the explanation
Description:
This pull request adds unit tests to verify the correct handling of cancellation tokens in the
ExecuteAllRulesAsync
andExecuteActionWorkflowAsync
methods of the Rules Engine.Changes:
New Unit Tests:
ExecuteAllRulesAsync_WithCancellationToken_CancelsProperly
to ensure the method respects the cancellation token and properly handles cancellation.ExecuteActionWorkflowAsync_WithCancellationToken_CancelsProperly
to verify that executing a single rule with a cancellation token is handled correctly.TaskCanceledException
) is thrown.Custom Action Implementation:
ReturnTrueIfCancellationRequestedAction
class to simulate an action that can be cancelled.true
if the cancellation is requested.Test Details:
TaskCanceledException
) is thrown when cancellation is requested.Quick Tip:
In the library implementation, we are not breaking the loop if the cancellation is requested. This decision is left to the users of the library, allowing them to decide whether to stop execution using the cancellation flag or by throwing an exception. This approach provides more control to the final user, enabling them to complete tasks gracefully before breaking the process if they choose to.
Please review the changes and let me know if any adjustments are needed.
Thank you!