We are using Outbox and RavenDB. In the handlers SaveChangesAsync() should not be called on the RavenDB session since it will all be handled by the Outbox after the code in the handler is finished running to commit the transaction.
When writing tests with TestableMessageHandlerContext and TestableRavenStorageSession the changes are not automatically saved and I have to call SaveChangesAsync() manually after running every Handler.
Is this correct or is there some setting I am not aware of to turn on automatically calling SaveChangesAsync() after the handler completes to simulate running with Outbox?
When writing tests with TestableMessageHandlerContext and TestableRavenStorageSession the changes are not automatically saved and I have to call SaveChangesAsync() manually after running every Handler.
Is this correct or is there some setting I am not aware of to turn on automatically calling SaveChangesAsync() after the handler completes to simulate running with Outbox?
Yes, that is correct. The TestableMessageHandlerContext lacks the pipeline. You are indeed responsible in invoking the RavenDB session as you are likely also creating and managing its lifetime.
Could you share an actual test where you use TestableMessageHandlerContext? Does not have to contains existing code, just the “template“ / structure or your test to review.