Skip to content

Add a TestableITransactionalSession #322

@sanisoclem

Description

@sanisoclem

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions