public async Task Then_The_Handler_Only_Receives_The_Message_Once()
        {
            // Arrange
            var messageLock = new MessageLockStore();
            var handler     = new ExactlyOnceHandlerNoTimeout();

            var services = GivenJustSaying()
                           .ConfigureJustSaying((builder) => builder.WithLoopbackTopic <SimpleMessage>(UniqueName))
                           .ConfigureJustSaying((builder) => builder.Services((config) => config.WithMessageLock(() => messageLock)))
                           .AddJustSayingHandlers(new[] { handler });

            await WhenAsync(
                services,
                async (publisher, listener, serviceProvider, cancellationToken) =>
            {
                await listener.StartAsync(cancellationToken);
                await publisher.StartAsync(cancellationToken);

                var message = new SimpleMessage();

                // Act
                await publisher.PublishAsync(message, cancellationToken);
                await publisher.PublishAsync(message, cancellationToken);
                await Task.Delay(1.Seconds(), cancellationToken);

                // Assert
                handler.NumberOfTimesIHaveBeenCalledForMessage(message.UniqueKey()).ShouldBe(1);
            });
        }
        public async Task Then_Both_Handlers_Receive_The_Message()
        {
            // Arrange
            var handler1 = new ExactlyOnceHandlerNoTimeout();
            var handler2 = new ExactlyOnceHandlerNoTimeout();

            var services = GivenJustSaying()
                           .ConfigureJustSaying((builder) => builder.WithLoopbackTopic <SimpleMessage>(UniqueName))
                           .AddJustSayingHandlers(new[] { handler1, handler2 });

            await WhenAsync(
                services,
                async (publisher, listener, serviceProvider, cancellationToken) =>
            {
                listener.Start(cancellationToken);

                var message = new SimpleMessage();

                // Act
                await publisher.PublishAsync(message, cancellationToken);
                await Task.Delay(5.Seconds());

                // Assert
                handler1.NumberOfTimesIHaveBeenCalledForMessage(message.UniqueKey()).ShouldBe(1);
                handler2.NumberOfTimesIHaveBeenCalledForMessage(message.UniqueKey()).ShouldBe(1);
            });
        }