rebus-org / Rebus.TestHelpers

:bus: Test helpers for Rebus (i.e. fake bus, saga fixture, etc.)
https://mookid.dk/category/rebus
Other
4 stars 2 forks source link

FakeMessageContext doesn't support cancellation token #7

Closed sixten closed 2 years ago

sixten commented 2 years ago

I can understand why the FakeMessageContext doesn't contain a valid IncomingStepContext, but that unfortunately means that MessageContextExtensions.GetCancellationToken() doesn't work with the fake context. Because that's an extension method, it's also kind of difficult to get around this by mocking the message context.

Do you have any suggestions for testing handlers that use the cancellation token?

mookid8000 commented 2 years ago

You're aboslutely right – it's pretty awkward how it works now.

I've changed the ctor to have this signature:

    public FakeMessageContext(
        TransportMessage transportMessage = null, 
        Message message = null, 
        CancellationToken cancellationToken = default
    )

thus making it possible to pass in any of the desired objects. It's out as Rebus.TestHelpers 7.0.0, which is available on NuGet.org now 🙂 thanks for briging it to my attention!