private MockMessage CreateAsynchronousMessageProtected() { var certificateStore = new MockCertificateStore(); var messageProtection = new SignThenEncryptMessageProtection(TestCertificates.HelsenorgePrivateSigntature, TestCertificates.HelsenorgePrivateEncryption); var messageId = Guid.NewGuid().ToString("D"); var path = Path.Combine("Files", "Helsenorge_Message.xml"); var file = File.Exists(path) ? new XDocument(XElement.Load(path)) : null; var protect = messageProtection.Protect(file == null ? GenericMessage.ToStream() : file.ToStream(), TestCertificates.HelsenorgePublicEncryption); return(new MockMessage(protect) { MessageFunction = "DIALOG_INNBYGGER_EKONTAKT", ApplicationTimestamp = DateTime.Now, ContentType = ContentType.SignedAndEnveloped, MessageId = messageId, CorrelationId = messageId, FromHerId = MockFactory.OtherHerId, ToHerId = MockFactory.HelsenorgeHerId, ScheduledEnqueueTimeUtc = DateTime.UtcNow, TimeToLive = TimeSpan.FromSeconds(15), ReplyTo = MockFactory.OtherParty.Asynchronous.Name, Queue = MockFactory.Helsenorge.Asynchronous.Messages, }); }