felsokning
felsokning
CC#
Created by felsokning on 1/30/2025 in #help
Populate `EnvelopeRecipientCollection` on `Recipients` Property of a `MailItem` in Transport Agent
I've written an Exchange Transport Agent in C#, using the common assemblies from Exchange 2019 CU14 (namely: Microsoft.Exchange.Data.Common.dll and Microsoft.Exchange.Data.Transport.dll). I, at first, had issues populating the MailItem object on the EndOfDataEventArgs delegate. I discovered that I could do this via reflection and now I'm trying to test a condition that the message is quarantined. In order for the message to be quarantined, the recipients - which is a List<EnvelopeRecipient> has to be populated and passed into the ReceiveMessageEventSource.Quarantine method. The issue that I'm running into is that the Recipients property on the MailItem only has a getter and is of type EnvelopeRecipientCollection. So, I try to setup a Mock<EnvelopeRecipientCollection> and am able to feed that as the SetupGet(x => x.Recipients).Returns(...); however, because it's a mock, it's an empty collection and the test is failing because the recipient collection is empty. Since the constructor for EnvelopeRecipientCollection is internal, I can't instantiate an instance of the object. It looks like EnvelopeRecipientCollection depends on a struct of IEnumerator<EnvelopeRecipient>, so trying to pass the List<EnvelopeRecipient>.GetEnumerator() as the EnvelopeRecipientCollection's enumerator doesn't work, either. Is there a way to successfully "fake" an object - even if it's a List<EnvelopeRecipient> - as an EnvelopeRecipientCollection and pass that into the SetupGet, so that the test doesn't continually fail with a NullReferenceException when trying to fetch the recipients for the ReceiveMessageEventSource.Quarantine method? Recipients Property (for 2010 - but hasn't changed in 2019): https://learn.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2010/aa579340(v=exchg.140) EnvelopeRecipientCollection: https://learn.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2010/aa564107(v=exchg.140)
14 replies
CC#
Created by felsokning on 10/27/2024 in #help
Token Claims Membership Mapping
No description
1 replies