public void GetPartitionPropertiesAsyncValidatesThePartition(string partition) { ExactTypeConstraint typeConstraint = partition is null ? Throws.ArgumentNullException : Throws.ArgumentException; var client = new AmqpEventHubClient("my.eventhub.com", "somePath", Mock.Of <TokenCredential>(), new EventHubClientOptions(), Mock.Of <EventHubRetryPolicy>()); Assert.That(async() => await client.GetPartitionPropertiesAsync(partition, CancellationToken.None), typeConstraint); }
public async Task GetPartitionPropertiesAsyncValidatesClosed() { 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.GetPartitionPropertiesAsync("Fred", cancellationSource.Token), Throws.InstanceOf <EventHubsObjectClosedException>()); }
public void GetPartitionPropertiesAsyncRespectsTheCancellationTokenIfSetWhenCalled() { 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.GetPartitionPropertiesAsync("Fred", cancellationSource.Token), Throws.InstanceOf <TaskCanceledException>()); }