public void GetPropertiesAsyncValidatesTheRetryPolicy() { using var cancellationSource = new CancellationTokenSource(); var client = new AmqpClient("my.eventhub.com", "somePath", Mock.Of <TokenCredential>(), new EventHubConnectionOptions()); Assert.That(async() => await client.GetPropertiesAsync(null, cancellationSource.Token), Throws.ArgumentNullException); }
public async Task GetPropertiesAsyncRespectsClosed() { 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.GetPropertiesAsync(Mock.Of <EventHubRetryPolicy>(), cancellationSource.Token), Throws.InstanceOf <EventHubsClientClosedException>()); }
public void GetPropertiesAsyncRespectsTheCancellationTokenIfSetWhenCalled() { 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.GetPropertiesAsync(Mock.Of <EventHubsRetryPolicy>(), cancellationSource.Token), Throws.InstanceOf <TaskCanceledException>()); }
public async Task GetPropertiesAsyncRespectsClosed() { 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.GetPropertiesAsync(Mock.Of <EventHubsRetryPolicy>(), cancellationSource.Token), Throws.InstanceOf <EventHubsException>().And.Property(nameof(EventHubsException.Reason)).EqualTo(EventHubsException.FailureReason.ClientClosed)); }