Exemple #1
0
        public async Task GetPropertiesAsyncRespectsClosed()
        {
            using var cancellationSource = new CancellationTokenSource();

            var client = new AmqpEventHubClient("my.eventhub.com", "somePath", Mock.Of <TokenCredential>(), new EventHubClientOptions(), Mock.Of <EventHubRetryPolicy>());
            await client.CloseAsync(cancellationSource.Token);

            Assert.That(async() => await client.GetPropertiesAsync(cancellationSource.Token), Throws.InstanceOf <EventHubsObjectClosedException>());
        }
Exemple #2
0
        public void GetPropertiesAsyncRespectsTheCancellationTokenIfSetWhenCalled()
        {
            using var cancellationSource = new CancellationTokenSource();
            cancellationSource.Cancel();

            var client = new AmqpEventHubClient("my.eventhub.com", "somePath", Mock.Of <TokenCredential>(), new EventHubClientOptions(), Mock.Of <EventHubRetryPolicy>());

            Assert.That(async() => await client.GetPropertiesAsync(cancellationSource.Token), Throws.InstanceOf <TaskCanceledException>());
        }