public async Task ProcessAsync_NoConnection_ShoulFailTest() { var throwingDeviceProxy = ThrowingDeviceProxyBuilder .Create() .WithActiveStatus(false) .Build(); var messageProcessor = this.CreateMessageProcessor(throwingDeviceProxy); var message1 = GetMessage(); var message2 = GetMessage(); ISinkResult <IRoutingMessage> result = await messageProcessor.ProcessAsync(message1, CancellationToken.None); Assert.NotNull(result); Assert.Empty(result.Succeeded); Assert.Equal(1, result.Failed.Count); Assert.Empty(result.InvalidDetailsList); Assert.True(result.SendFailureDetails.HasValue); ISinkResult <IRoutingMessage> resultBatch = await messageProcessor.ProcessAsync(new[] { message1, message2 }, CancellationToken.None); Assert.NotNull(resultBatch); Assert.Empty(resultBatch.Succeeded); Assert.Equal(2, resultBatch.Failed.Count); Assert.Empty(resultBatch.InvalidDetailsList); Assert.True(resultBatch.SendFailureDetails.HasValue); }
public async Task ProcessAsync_SendThrowsNonRetryable_Test() { var throwingDeviceProxy = ThrowingDeviceProxyBuilder .Create() .WithThrow <Exception>() .Build(); var messageProcessor = this.CreateMessageProcessor(throwingDeviceProxy); var message1 = GetMessage(); var message2 = GetMessage(); ISinkResult <IRoutingMessage> result = await messageProcessor.ProcessAsync(message1, CancellationToken.None); Assert.NotNull(result); Assert.Empty(result.Succeeded); Assert.Empty(result.Failed); Assert.Equal(1, result.InvalidDetailsList.Count); Assert.False(result.SendFailureDetails.HasValue); ISinkResult <IRoutingMessage> resultBatch = await messageProcessor.ProcessAsync(new[] { message1, message2 }, CancellationToken.None); Assert.NotNull(resultBatch); Assert.Empty(resultBatch.Succeeded); Assert.Empty(resultBatch.Failed); Assert.Equal(2, resultBatch.InvalidDetailsList.Count); Assert.False(resultBatch.SendFailureDetails.HasValue); }
public async Task ProcessAsync_FastFailMessages_AfterOneFailedWithRetriable() { var throwingDeviceProxy = ThrowingDeviceProxyBuilder .Create() .WithSuccess() .WithThrow <EdgeHubIOException>() .WithSuccess() .Build(); var messageProcessor = this.CreateMessageProcessor(throwingDeviceProxy); var messages = GetMessages(5); var result = await messageProcessor.ProcessAsync(messages, CancellationToken.None); Assert.False(result.IsSuccessful); Assert.Equal(1, result.Succeeded.Count); Assert.Equal(4, result.Failed.Count); Assert.Equal(FailureKind.Transient, result.SendFailureDetails.Expect(() => new Exception()).FailureKind); }
public async Task ProcessAsync_DontFastFailMessages_AfterOneFailedWithNonRetriable() { var throwingDeviceProxy = ThrowingDeviceProxyBuilder .Create() .WithSuccess() .WithThrow <Exception>() .WithSuccess() .Build(); var messageProcessor = this.CreateMessageProcessor(throwingDeviceProxy); var messages = GetMessages(5); var result = await messageProcessor.ProcessAsync(messages, CancellationToken.None); Assert.True(result.IsSuccessful); // non-retriable is not reported as failure Assert.Equal(4, result.Succeeded.Count); Assert.Equal(1, result.InvalidDetailsList.Count); Assert.Equal(0, result.Failed.Count); // SendFailureDetails is not reported for Non-Retriable - this is not consistent with cloud proxy, skip the assert for now }