private static Task <AS4Message> SerializeDeserializeMime(AS4Message msg)
        {
            var serializer = new MimeMessageSerializer(new SoapEnvelopeSerializer());
            var memory     = new MemoryStream();

            serializer.Serialize(msg, memory, CancellationToken.None);
            memory.Position = 0;

            return(serializer.DeserializeAsync(memory, msg.ContentType));
        }
Пример #2
0
        protected MimeMessage SerializeMimeMessage(AS4Message message, MemoryStream mimeStream)
        {
            ISerializer serializer = new MimeMessageSerializer(new SoapEnvelopeSerializer());

            serializer.Serialize(message, mimeStream);

            mimeStream.Position = 0;

            return(MimeMessage.Load(mimeStream));
        }
Пример #3
0
            private static MimeMessage SerializeMimeMessage(AS4Message message, Stream mimeStream)
            {
                ISerializer serializer = new MimeMessageSerializer(new SoapEnvelopeSerializer());

                serializer.Serialize(message, mimeStream);

                mimeStream.Position = 0;

                return(MimeMessage.Load(mimeStream));
            }
        private static async Task <AS4Message> SerializeDeserialize(AS4Message message)
        {
            var serializer = new MimeMessageSerializer(new SoapEnvelopeSerializer());

            var memory = new MemoryStream();

            serializer.Serialize(message, memory);
            memory.Position = 0;

            return(await serializer.DeserializeAsync(memory, message.ContentType));
        }
        private static StubMessageBodyRetriever StubMessageStoreThatRetreives(AS4Message signedUserMessage)
        {
            return(new StubMessageBodyRetriever(() =>
            {
                var serializer = new MimeMessageSerializer(new SoapEnvelopeSerializer());
                var memory = new VirtualStream(VirtualStream.MemoryFlag.AutoOverFlowToDisk);
                serializer.Serialize(signedUserMessage, memory);
                memory.Position = 0;

                return memory;
            }));
        }
Пример #6
0
            public void ThenSerializeAS4MessageSucceeds()
            {
                using (Stream messageStream = SerializeAnonymousMessage())
                {
                    // Arrange
                    AS4Message as4Message = CreateAnonymousMessage();
                    var        sut        = new MimeMessageSerializer(new SoapEnvelopeSerializer());

                    // Act
                    sut.Serialize(as4Message, messageStream);

                    // Assert
                    Assert.True(messageStream.CanRead);
                    Assert.True(messageStream.Length > 0);
                }
            }