public async Task SendEnumerableEnsuresNotClosed() { var producer = new AmqpEventHubProducer("aHub", null, Mock.Of <AmqpConnectionScope>(), new AmqpMessageConverter(), Mock.Of <EventHubRetryPolicy>()); await producer.CloseAsync(CancellationToken.None); Assert.That(async() => await producer.SendAsync(Enumerable.Empty <EventData>(), new SendOptions(), CancellationToken.None), Throws.InstanceOf <EventHubsClientClosedException>()); }
public void SendEnumerableRespectsTheCancellationTokenIfSetWhenCalled() { using CancellationTokenSource cancellationSource = new CancellationTokenSource(); cancellationSource.Cancel(); var producer = new AmqpEventHubProducer("aHub", null, Mock.Of <AmqpConnectionScope>(), new AmqpMessageConverter(), Mock.Of <EventHubRetryPolicy>()); Assert.That(async() => await producer.SendAsync(new[] { new EventData(new byte[] { 0x15 }) }, new SendOptions(), cancellationSource.Token), Throws.InstanceOf <TaskCanceledException>()); }
public void SendBatchValidatesTheBatch() { var producer = new AmqpEventHubProducer("aHub", null, Mock.Of <AmqpConnectionScope>(), new AmqpMessageConverter(), Mock.Of <EventHubRetryPolicy>()); Assert.That(async() => await producer.SendAsync(null, CancellationToken.None), Throws.ArgumentNullException); }