public async Task Should_call_PreSend_and_PostSend_on_message_SendAsync()
        {
            var sendObserver = new TestSendObserver();
            var address      = Guid.NewGuid().ToString();

            await using var testFixture = await TestFixture.CreateAsync(_testOutputHelper, builder =>
            {
                builder.Services.AddSingleton(sendObserver);
                builder.AddProducer <TestProducer>(address)
                .AddSendObserver <TestSendObserver>();
            });

            var testProducer = testFixture.Services.GetService <TestProducer>();
            await testProducer.Producer.SendAsync(new Message("foo"), testFixture.CancellationToken);

            Assert.True(sendObserver.PreSendCalled);
            Assert.True(sendObserver.PostSendCalled);
        }
        public async Task Should_call_PreReceive_and_PostReceive_when_message_received()
        {
            var receiveObserver = new TestReceiveObserver();
            var address         = Guid.NewGuid().ToString();

            await using var testFixture = await TestFixture.CreateAsync(_testOutputHelper, builder =>
            {
                builder.Services.AddSingleton(receiveObserver);
                builder.AddConsumer(address, RoutingType.Multicast, async(message, consumer, token, provider) =>
                {
                    await consumer.AcceptAsync(message);
                });
                builder.AddReceiveObserver <TestReceiveObserver>();
            });

            var producer = await testFixture.Connection.CreateProducerAsync(address, RoutingType.Multicast, testFixture.CancellationToken);

            await producer.SendAsync(new Message("foo"), testFixture.CancellationToken);

            Assert.Equal(receiveObserver.PreReceiveCalled.Task, await Task.WhenAny(receiveObserver.PreReceiveCalled.Task, Task.Delay(TimeSpan.FromSeconds(5))));
            Assert.Equal(receiveObserver.PostReceiveCalled.Task, await Task.WhenAny(receiveObserver.PostReceiveCalled.Task, Task.Delay(TimeSpan.FromSeconds(5))));
        }