コード例 #1
0
        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);
        }
コード例 #2
0
        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>());
        }
コード例 #3
0
        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>());
        }