public async Task CreateConsumerValidatesClosed() { 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(() => client.CreateConsumer("group", "0", EventPosition.Earliest, new EventHubConsumerClientOptions()), Throws.InstanceOf <EventHubsClientClosedException>()); }
public async Task CreateConsumerValidatesClosed() { 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(() => client.CreateConsumer("group", "0", "id", EventPosition.Earliest, Mock.Of <EventHubsRetryPolicy>(), false, false, null, null, null), Throws.InstanceOf <EventHubsException>().And.Property(nameof(EventHubsException.Reason)).EqualTo(EventHubsException.FailureReason.ClientClosed)); }
public async Task CreateConsumerValidatesClosed() { using var cancellationSource = new CancellationTokenSource(); var credential = new Mock <EventHubTokenCredential>(Mock.Of <TokenCredential>(), "{namespace}.servicebus.windows.net"); var client = new AmqpClient("my.eventhub.com", "somePath", credential.Object, new EventHubConnectionOptions()); await client.CloseAsync(cancellationSource.Token); Assert.That(() => client.CreateConsumer("group", "0", EventPosition.Earliest, Mock.Of <EventHubsRetryPolicy>(), false, null, null), Throws.InstanceOf <EventHubsClientClosedException>()); }