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>()); }
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>()); }