public static void TestCopyTo() { RecipientInfoCollection col = CreateTestCollection(); RecipientInfo[] recipients = new RecipientInfo[3]; col.CopyTo(recipients, 0); ValidateMembers(recipients); }
public static void TestCopyToOffset() { RecipientInfoCollection col = CreateTestCollection(); RecipientInfo[] recipients = new RecipientInfo[6]; col.CopyTo(recipients, 2); Assert.Null(recipients[0]); Assert.Null(recipients[1]); Assert.Null(recipients[5]); ValidateMembers(recipients.Skip(2).Take(3)); }
public static void TestCopyToExceptions() { RecipientInfoCollection col = CreateTestCollection(); Assert.Throws <ArgumentNullException>(() => col.CopyTo(null, 0)); RecipientInfo[] recipients = new RecipientInfo[6]; col.CopyTo(recipients, 3); AssertExtensions.Throws <ArgumentException>("destinationArray", null, () => col.CopyTo(recipients, 4)); Assert.Throws <ArgumentOutOfRangeException>(() => col.CopyTo(recipients, -1)); Assert.Throws <ArgumentOutOfRangeException>(() => col.CopyTo(recipients, 6)); ICollection ic = col; AssertExtensions.Throws <ArgumentException>(null, () => ic.CopyTo(recipients, 4)); Assert.Throws <ArgumentOutOfRangeException>(() => ic.CopyTo(recipients, -1)); Assert.Throws <ArgumentOutOfRangeException>(() => ic.CopyTo(recipients, 6)); Assert.Throws <ArgumentOutOfRangeException>(() => ic.CopyTo(recipients, 6)); AssertExtensions.Throws <ArgumentException>(null, () => ic.CopyTo(new RecipientInfo[2, 2], 0)); }
private static void VerifyRecipients3(byte[] encodedMessage) { string[] expectedIssuers = s_certs.Select(c => c.Issuer).OrderBy(s => s).ToArray(); EnvelopedCms ecms = new EnvelopedCms(); ecms.Decode(encodedMessage); RecipientInfoCollection col = ecms.RecipientInfos; int numRecipients = col.Count; Assert.Equal(3, numRecipients); RecipientInfo[] recipients = new RecipientInfo[numRecipients]; col.CopyTo(recipients, 0); string[] actualIssuers = recipients.Select(r => r.RecipientIdentifier.Value).Cast <X509IssuerSerial>().Select(xis => xis.IssuerName).OrderBy(s => s).ToArray(); Assert.Equal <string>(expectedIssuers, actualIssuers); }