private static MessagingContext AS4MessageContext(Attachment attachment, SendingProcessingMode pmode) { var userMessage = new UserMessage($"user-{Guid.NewGuid()}", PartInfo.CreateFor(attachment)); AS4Message as4Message = AS4Message.Create(userMessage, pmode); as4Message.AddAttachment(attachment); return(new MessagingContext(as4Message, MessagingContextMode.Unknown) { SendingPMode = pmode }); }
public async Task Deliver_Bundled_UserMessage_As_Different_DeliverMessages() { // Arrange var attachmentPdf = new Attachment("pdf", new MemoryStream(pdf_document), "application/pdf"); var userMessage1 = new UserMessage( $"user1-{Guid.NewGuid()}", new CollaborationInfo( new AgreementReference("http://eu.europe.org/bundled")), Party.DefaultFrom, Party.DefaultTo, new [] { PartInfo.CreateFor(attachmentPdf) }, Enumerable.Empty <MessageProperty>()); var attachmentImage = new Attachment("earth", new MemoryStream(earth), "image/jpg"); var userMessage2 = new UserMessage( $"user2-{Guid.NewGuid()}", new CollaborationInfo( Maybe <AgreementReference> .Nothing, new Service("http://eu.europe.org/service"), "http://eu.europe.org/action", conversationId: "7881"), Party.DefaultFrom, Party.DefaultTo, new [] { PartInfo.CreateFor(attachmentImage) }, Enumerable.Empty <MessageProperty>()); AS4Message as4Message = AS4Message.Create(new [] { userMessage1, userMessage2 }); as4Message.AddAttachments(new[] { attachmentPdf, attachmentImage }); FileSystemUtils.ClearDirectory(DeliveryRoot); // Act await InsertToBeDeliveredMessagesAsync(as4Message); // Assert await PollUntilPresent( () => Directory.GetFiles(DeliveryRoot, $"{userMessage1.MessageId}.xml").FirstOrDefault(), timeout : TimeSpan.FromSeconds(25)); await PollUntilPresent( () => Directory.GetFiles(DeliveryRoot, $"{userMessage2.MessageId}.xml").FirstOrDefault(), timeout : TimeSpan.FromSeconds(25)); }