Esempio n. 1
0
        public async Task Update_RetryReliability_To_Pending_When_Receiver_Is_Offline()
        {
            // Arrange
            string     ebmsMessageId   = $"user-{Guid.NewGuid()}";
            AS4Message tobeSendMessage = AS4Message.Create(new UserMessage(ebmsMessageId));

            var outMessage = new OutMessage(ebmsMessageId);

            GetDataStoreContext.InsertOutMessage(outMessage);
            GetDataStoreContext.InsertRetryReliability(
                RetryReliability.CreateForOutMessage(
                    refToOutMessageId: outMessage.Id,
                    maxRetryCount: 2,
                    retryInterval: TimeSpan.FromSeconds(1),
                    type: RetryType.Send));

            var ctx = new MessagingContext(
                tobeSendMessage,
                new ReceivedEntityMessage(
                    outMessage,
                    tobeSendMessage.ToStream(),
                    tobeSendMessage.ContentType),
                MessagingContextMode.Send)
            {
                SendingPMode = CreateSendPModeWithPushUrl()
            };

            var   sabotageException = new WebException("Remote host not available");
            IStep sut = CreateSendStepWithResponse(
                StubHttpClient.ThatThrows(sabotageException));

            // Act
            StepResult result = await sut.ExecuteAsync(ctx);

            // Assert
            Assert.False(result.Succeeded);
            GetDataStoreContext.AssertRetryRelatedOutMessage(
                outMessage.Id,
                r =>
            {
                Assert.NotNull(r);
                Assert.Equal(RetryStatus.Pending, r.Status);
            });
        }