public void GetPartitionPropertiesAsyncValidatesTheRetryPolicy() { var credential = new Mock <EventHubTokenCredential>(Mock.Of <TokenCredential>()); var client = new AmqpClient("my.eventhub.com", "somePath", credential.Object, new EventHubConnectionOptions()); Assert.That(async() => await client.GetPartitionPropertiesAsync("1", null, CancellationToken.None), Throws.ArgumentNullException); }
public void GetPartitionPropertiesAsyncValidatesThePartition(string partition) { ExactTypeConstraint typeConstraint = partition is null ? Throws.ArgumentNullException : Throws.ArgumentException; var client = new AmqpClient("my.eventhub.com", "somePath", Mock.Of <TokenCredential>(), new EventHubConnectionOptions()); Assert.That(async() => await client.GetPartitionPropertiesAsync(partition, Mock.Of <EventHubRetryPolicy>(), CancellationToken.None), typeConstraint); }
public async Task GetPartitionPropertiesAsyncValidatesClosed() { using var cancellationSource = new CancellationTokenSource(); var client = new AmqpClient("my.eventhub.com", "somePath", Mock.Of <TokenCredential>(), new EventHubConnectionOptions()); await client.CloseAsync(cancellationSource.Token); Assert.That(async() => await client.GetPartitionPropertiesAsync("Fred", Mock.Of <EventHubRetryPolicy>(), cancellationSource.Token), Throws.InstanceOf <EventHubsClientClosedException>()); }
public void GetPartitionPropertiesAsyncRespectsTheCancellationTokenIfSetWhenCalled() { using var cancellationSource = new CancellationTokenSource(); cancellationSource.Cancel(); var client = new AmqpClient("my.eventhub.com", "somePath", Mock.Of <TokenCredential>(), new EventHubConnectionOptions()); Assert.That(async() => await client.GetPartitionPropertiesAsync("Fred", Mock.Of <EventHubRetryPolicy>(), cancellationSource.Token), Throws.InstanceOf <TaskCanceledException>()); }
public async Task GetPartitionPropertiesAsyncValidatesClosed() { using var cancellationSource = new CancellationTokenSource(); var credential = new Mock <EventHubTokenCredential>(Mock.Of <TokenCredential>()); var client = new AmqpClient("my.eventhub.com", "somePath", credential.Object, new EventHubConnectionOptions()); await client.CloseAsync(cancellationSource.Token); Assert.That(async() => await client.GetPartitionPropertiesAsync("Fred", Mock.Of <EventHubsRetryPolicy>(), cancellationSource.Token), Throws.InstanceOf <EventHubsException>().And.Property(nameof(EventHubsException.Reason)).EqualTo(EventHubsException.FailureReason.ClientClosed)); }