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 Parse(int addressCount, string source, string headerName)
        {
            DirectAddressCollection addresses = null;

            Assert.Null(Record.Exception(() => addresses = DirectAddressCollection.Parse(source)));
            Assert.True(addresses.Count == addressCount);
        }
        public void Parse(int addressCount, string source, string headerName)
        {
            DirectAddressCollection addresses = null;

            Assert.DoesNotThrow(() => addresses = DirectAddressCollection.Parse(source));
            Assert.True(addresses.Count == addressCount);
        }
        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);
        }
        void CheckCollection(Header header, string[] contains, string[] doesNotContain)
        {
            Assert.True(header != null);

            DirectAddressCollection collection = null;

            Assert.DoesNotThrow(() => collection = DirectAddressCollection.Parse(header.Value));
            if (!contains.IsNullOrEmpty())
            {
                foreach (string addr in contains)
                {
                    Assert.True(collection.Contains(addr));
                }
            }
            if (!doesNotContain.IsNullOrEmpty())
            {
                foreach (string addr in doesNotContain)
                {
                    Assert.True(!collection.Contains(addr));
                }
            }
        }
Beispiel #6
0
        public void TestParseAddressCollection(string addressList, int expectedCount)
        {
            DirectAddressCollection coll = DirectAddressCollection.Parse(addressList);

            Assert.Equal <int>(expectedCount, coll.Count);
        }