예제 #1
0
        public async Task Updates_Error_InMessage_With_Retry_Info_When_Specified(bool enabled, int count, string intervalString)
        {
            TimeSpan interval = intervalString.AsTimeSpan();

            // Arrange
            string     ebmsMessageId = "error-" + Guid.NewGuid();
            OutMessage om            = GetDataStoreContext.InsertOutMessage(
                CreateOutMessage(ebmsMessageId));

            var error = Error.FromErrorResult(
                $"error-{Guid.NewGuid()}",
                ebmsMessageId,
                new ErrorResult("Some Error occured", ErrorAlias.ConnectionFailure));

            SendingProcessingMode pmode = CreateNotifyAllSendingPMode();

            pmode.ErrorHandling.Reliability =
                new RetryReliability
            {
                IsEnabled     = enabled,
                RetryCount    = 5,
                RetryInterval = "0:00:01:00"
            };

            // Act
            await ExerciseUpdateReceivedMessage(
                AS4Message.Create(error),
                pmode,
                receivePMode : null);

            // Assert
            GetDataStoreContext.AssertRetryRelatedInMessage(
                om.Id,
                rr =>
            {
                Assert.True(enabled == (rr != null), "RetryReliability inserted while not enabled");
                Assert.True(enabled == (0 == rr?.CurrentRetryCount), "CurrentRetryCount != 0 when enabled");
                Assert.True(enabled == (count == rr?.MaxRetryCount), $"MaxRetryCount {count} != {rr?.MaxRetryCount} when enabled");
                Assert.True(
                    enabled == (interval == rr?.RetryInterval),
                    $"RetryInterval {interval} != {rr?.RetryInterval} when enabled");
            });
        }
예제 #2
0
        public async Task Updates_Receipt_InMessage_With_Info_When_Specified(bool enabled, int count, string intervalString)
        {
            TimeSpan interval = intervalString.AsTimeSpan();

            // Arrange
            string ebmsMessageId = Guid.NewGuid().ToString();

            GetDataStoreContext.InsertOutMessage(
                new OutMessage(ebmsMessageId));

            AS4Message            receipt = AS4Message.Create(new Receipt($"receipt-{Guid.NewGuid()}", ebmsMessageId));
            SendingProcessingMode pmode   = CreateNotifyAllSendingPMode();

            pmode.ReceiptHandling.Reliability =
                new RetryReliability
            {
                IsEnabled     = enabled,
                RetryCount    = 3,
                RetryInterval = "0:00:00:10"
            };

            // Act
            await ExerciseUpdateReceivedMessage(receipt, pmode, receivePMode : null);

            // Assert
            long id = GetDataStoreContext.GetInMessage(m => m.EbmsRefToMessageId == ebmsMessageId).Id;

            GetDataStoreContext.AssertRetryRelatedInMessage(
                id,
                rr =>
            {
                Assert.True(enabled == (rr != null), "RetryReliability inserted while not enabled");
                Assert.True(enabled == (0 == rr?.CurrentRetryCount), "CurrentRetryCount != 0 when enabled");
                Assert.True(enabled == (count == rr?.MaxRetryCount), $"MaxRetryCount {count} != {rr?.MaxRetryCount} when enabled");
                Assert.True(
                    enabled == (interval == rr?.RetryInterval),
                    $"RetryInterval {interval} != {rr?.RetryInterval} when enabled");
            });
        }
예제 #3
0
        public async Task Updates_UserMessage_InMessage_With_Retry_Info_When_Specified(
            bool enabled,
            string action,
            int count,
            string intervalString)
        {
            TimeSpan interval = intervalString.AsTimeSpan();

            // Arrange
            string ebmsMessageId = "user-" + Guid.NewGuid();
            var    userMessage   = new UserMessage(
                ebmsMessageId,
                new CollaborationInfo(
                    Maybe <AgreementReference> .Nothing,
                    Service.TestService,
                    action,
                    conversationId: "1"));

            var pmode = new ReceivingProcessingMode
            {
                MessageHandling =
                {
                    MessageHandlingType = MessageHandlingChoiceType.Deliver,
                    DeliverInformation  =
                    {
                        IsEnabled   = true,
                        Reliability = new RetryReliability
                        {
                            IsEnabled     = enabled,
                            RetryCount    =                                 3,
                            RetryInterval = "0:00:00:05"
                        }
                    }
                }
            };

            // Act
            await ExerciseUpdateReceivedMessage(
                AS4Message.Create(userMessage),
                sendPMode : null,
                receivePMode : pmode);

            // Assert
            InMessage actual             = GetDataStoreContext.GetInMessage(m => m.EbmsMessageId == ebmsMessageId);
            bool      needsToBeDelivered = enabled && !userMessage.IsTest;

            Assert.True(
                !userMessage.IsTest == (Operation.ToBeDelivered == actual.Operation),
                "InMessage.Operation <> ToBeDelivered when not test message");

            GetDataStoreContext.AssertRetryRelatedInMessage(
                actual.Id,
                rr =>
            {
                Assert.True(
                    needsToBeDelivered == (rr != null),
                    "RetryReliability inserted while not enabled and not test message");

                Assert.True(
                    needsToBeDelivered == (0 == rr?.CurrentRetryCount),
                    "CurrentRetryCount != 0 when enabled and not test message");

                Assert.True(
                    needsToBeDelivered == (count == rr?.MaxRetryCount),
                    $"MaxRetryCount {count} != {rr?.MaxRetryCount} when enabled and not test message");

                Assert.True(
                    needsToBeDelivered == (interval == rr?.RetryInterval),
                    $"RetryInterval {interval} != {rr?.RetryInterval} when enabled");
            });
        }