public async Task SignalMessage_Gets_Saved_As_Duplicate_When_InMessage_Exists_With_Same_EbmsRefToMessageId() { // Arrange string ebmsMessageId = $"receipt-{Guid.NewGuid()}"; string ebmsRefToMessageId = $"user-{Guid.NewGuid()}"; GetDataStoreContext.InsertInMessage( new InMessage(ebmsMessageId) { EbmsRefToMessageId = ebmsRefToMessageId }); var receipt = new Receipt(ebmsMessageId, ebmsRefToMessageId); var context = new MessagingContext( AS4Message.Create(receipt), new ReceivedMessage(Stream.Null), MessagingContextMode.Receive); // Act await Step.ExecuteAsync(context); // Assert InMessage actual = GetDataStoreContext.GetInMessage( m => m.EbmsMessageId == ebmsMessageId && m.EbmsRefToMessageId == ebmsRefToMessageId && m.IsDuplicate); Assert.True(actual != null, "Saved Receipt should be marked as duplicate"); }
private InMessage GetUserInMessageForEbmsMessageId(MessageUnit userMessage) { InMessage inMessage = GetDataStoreContext .GetInMessage(m => m.EbmsMessageId.Equals(userMessage.MessageId)); Assert.NotNull(inMessage); Assert.Equal(MessageType.UserMessage, inMessage.EbmsMessageType); return(inMessage); }
public async Task ThenExecuteStepIgnoresPullRequests() { // Arrange var pr = AS4Message.Create( new PullRequest( $"pr-msg-id-{Guid.NewGuid()}", $"pr-mpc-{Guid.NewGuid()}")); // Act using (MessagingContext ctx = CreateReceivedMessagingContext(pr, new ReceivingProcessingMode())) { await Step.ExecuteAsync(ctx); } // Assert InMessage im = GetDataStoreContext.GetInMessage( m => m.EbmsMessageId == pr.GetPrimaryMessageId()); Assert.Null(im); }
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"); }); }
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"); }); }