Testable ITransactionalSession?

Hi all

What do you use to get a Testable ITransactionalSession ala TestableMessageSession(for IMessageSession dependencies).

Is this a gap in the NServiceBus.Testing nuget to work with custom mocks for?

-Kostas

Hey @Konstantinos_Konstan, I looked at the TestableMessageSession, it looks pretty simple. It’s not clear from that what you may desire in an TestableTransactionalSession class. Would you be able to provide one or more examples of tests that you that you would write assuming that a TestableTransactionalSession class did exist? That will help to better understand your needs.

Hi Adam

Particular provides NServiceBus.Testing/src/NServiceBus.Testing/NSB.Testing.Fakes/TestableMessageSession.cs at master · Particular/NServiceBus.Testing as a Fake for IMessageSession dependant code.
The above implements IMessageSession.

To the best of my knowledge, there’s no Fake for ITransactionalSession which you have to depend on for Transactional MS SQL message sessions for API endpoints that write to the database and send messages.
NServiceBus.TransactionalSession/src/NServiceBus.TransactionalSession/ITransactionalSession.cs at 9fb08f7ef2c71add7648ec7c80bd44ed206d2f83 · Particular/NServiceBus.TransactionalSession

For now, I have inherited from TestableMessageSession and implemented ITransactionalSession in my own Fake which seems to do the trick for the most part. Just curious if Particular has a Fake that I may have missed.

Hi @Konstantinos_Konstan,

It sounds like that you have what you need. To confirm, there is not a fake implementation provided in the NServiceBus libraries intended to be explicity used in transactional session tests.

If you find that you do need something more, or if it becomes challenging to maintain your own version of the code, you should feel free to open an issue in the NServiceBus repository describing what you would like the feature to include. It seems like at the moment the features of the TestableMessageSession (via inheritance) is providing enough for your current scenarios.