public async Task SendEnumerableEnsuresNotClosed()
        {
            var producer = new AmqpProducer("aHub", null, Mock.Of <AmqpConnectionScope>(), new AmqpMessageConverter(), Mock.Of <EventHubsRetryPolicy>());
            await producer.CloseAsync(CancellationToken.None);

            Assert.That(async() => await producer.SendAsync(Enumerable.Empty <EventData>(), new SendOptions(), CancellationToken.None), Throws.InstanceOf <EventHubsClientClosedException>());
        }
        public void CloseRespectsTheCancellationToken()
        {
            var producer = new AmqpProducer("aHub", null, Mock.Of <AmqpConnectionScope>(), Mock.Of <AmqpMessageConverter>(), Mock.Of <EventHubsRetryPolicy>());

            using var cancellationSource = new CancellationTokenSource();

            cancellationSource.Cancel();
            Assert.That(async() => await producer.CloseAsync(cancellationSource.Token), Throws.InstanceOf <TaskCanceledException>(), "Cancellation should trigger the appropriate exception.");
            Assert.That(producer.Closed, Is.False, "Cancellation should have interrupted closing and left the producer in an open state.");
        }
        public async Task CloseMarksTheProducerAsClosed()
        {
            var producer = new AmqpProducer("aHub", "0", Mock.Of <AmqpConnectionScope>(), Mock.Of <AmqpMessageConverter>(), Mock.Of <EventHubsRetryPolicy>());

            Assert.That(producer.Closed, Is.False, "The producer should not be closed on creation");

            await producer.CloseAsync(CancellationToken.None);

            Assert.That(producer.Closed, Is.True, "The producer should be marked as closed after closing");
        }