public void ToHeader(int addressCount, string source, string headerName)
        {
            DirectAddressCollection addresses = null;

            Assert.Null(Record.Exception(() => addresses = DirectAddressCollection.Parse(source)));
            Assert.True(addresses.Count == addressCount);

            Header header = null;

            Assert.Null(Record.Exception(() => header = addresses.ToHeader(headerName)));
            Assert.True(string.Equals(header.Name, headerName));

            string foldedText = null;

            Assert.Null(Record.Exception(() => foldedText = header.SourceText.ToString()));
            Assert.True(!string.IsNullOrEmpty(foldedText));

            string[] foldedParts = foldedText.Split(new string[] { MailStandard.CRLF }, StringSplitOptions.None);
            Assert.True(foldedParts.Length == addressCount);

            string entity = foldedText + MailStandard.CRLF;

            Header[] reparsedHeaders = null;
            Assert.Null(Record.Exception(() => reparsedHeaders = MimeParser.ReadHeaders(entity).ToArray()));
            Assert.True(reparsedHeaders.Length == 1);
            Assert.True(reparsedHeaders[0].Name == headerName);

            DirectAddressCollection reparsedAddresses = null;

            Assert.Null(Record.Exception(() => reparsedAddresses = DirectAddressCollection.Parse(reparsedHeaders[0].Value)));
            Assert.True(reparsedAddresses.Count == addressCount);
        }
        public void ToHeaderNull()
        {
            DirectAddressCollection addresses = new DirectAddressCollection();
            Header header = null;

            Assert.Null(Record.Exception(() => header = addresses.ToHeader(MailStandard.Headers.To)));
            Assert.True(header == null);
        }
        public void ToHeaderNull()
        {
            DirectAddressCollection addresses = new DirectAddressCollection();
            Header header = null;

            Assert.DoesNotThrow(() => header = addresses.ToHeader(MailStandard.Headers.To));
            Assert.True(header == null);
        }
        public void ToHeaderUnfolded(int addressCount, string source, string headerName)
        {
            DirectAddressCollection addresses = null;

            Assert.Null(Record.Exception(() => addresses = DirectAddressCollection.Parse(source)));

            Header header = null;

            Assert.Null(Record.Exception(() => header = addresses.ToHeader(headerName)));
            Assert.True(string.Equals(header.Name, headerName));

            DirectAddressCollection reparsedAddresses = null;

            Assert.Null(Record.Exception(() => reparsedAddresses = DirectAddressCollection.Parse(header.Value)));
            Assert.True(reparsedAddresses.Count == addressCount);
        }
 public void ToHeaderNull()
 {
     DirectAddressCollection addresses = new DirectAddressCollection();
     Header header = null;
     Assert.DoesNotThrow(() => header = addresses.ToHeader(MailStandard.Headers.To));
     Assert.True(header == null);
 }
Beispiel #6
0
 void UpdateRecipientHeader(DirectAddressCollection recipients, string headerName, IEnumerable<DirectAddress> rejectedRecipients)
 {
     if (recipients != null) 
     {
         recipients.Remove(rejectedRecipients);
         this.Message.Headers[headerName] = recipients.ToHeader(headerName);
     }
 }