Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a TestableITransactionalSession #322

Open
sanisoclem opened this issue Apr 26, 2024 · 2 comments
Open

Add a TestableITransactionalSession #322

sanisoclem opened this issue Apr 26, 2024 · 2 comments
Labels

Comments

@sanisoclem
Copy link

Describe the feature.

Is your feature related to a problem? Please describe.

When testing code that has a dependency on ITransactionalSession, we don't have the PublishedMessages, SentMessages, etc API.

Not sure if this is the right repo to raise this issue, if not please feel free to move it.

Describe the requested feature

It would be nice to have a TestableITransactionalSession for ITransactionalSession.

Describe alternatives you've considered

made a simple wrapper over TestableMessageSession and I use the underlying TestableMessageSession for assertions:

class MockTransactionalSession(IMessageSession inner) : ITransactionalSession
{
    public ISynchronizedStorageSession SynchronizedStorageSession => null!;

    public string SessionId => null!;

    public Task Commit(CancellationToken cancellationToken = default) => Task.CompletedTask;
    public void Dispose()
    {
    }

    public Task Open(OpenSessionOptions options, CancellationToken cancellationToken = default) => Task.CompletedTask;

    public Task Publish(object message, PublishOptions publishOptions, CancellationToken cancellationToken = default)
    {
        return inner.Publish(message, publishOptions, cancellationToken);
    }

    public Task Publish<T>(Action<T> messageConstructor, PublishOptions publishOptions, CancellationToken cancellationToken = default)
    {
        return inner.Publish(messageConstructor, publishOptions, cancellationToken);
    }

    public Task Send(object message, SendOptions sendOptions, CancellationToken cancellationToken = default)
    {
        return inner.Send(message, sendOptions, cancellationToken);
    }

    public Task Send<T>(Action<T> messageConstructor, SendOptions sendOptions, CancellationToken cancellationToken = default)
    {
        return inner.Send(messageConstructor, sendOptions, cancellationToken);
    }
}

Additional Context

No response

@kentdr kentdr transferred this issue from Particular/NServiceBus.Testing Apr 29, 2024
@kentdr
Copy link
Member

kentdr commented Apr 29, 2024

@sanisoclem, Thank you for the feature suggestion. We will look into adding this in the future.

@timbussmann
Copy link
Contributor

also adding a vote to this feature request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants