Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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>());
        }
Пример #4
0
        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>());
        }
Пример #5
0
        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));
        }