Beispiel #1
1
        public void TestParse()
        {
            Assert.IsNotNull(m_Stream);
            MIMER.RFC2045.MailReader m = new MailReader();
            MIMER.IEndCriteriaStrategy endofmessage = new BasicEndOfMessageStrategy();

            MIMER.RFC2045.IMimeMailMessage message = m.ReadMimeMessage(ref m_Stream, endofmessage);
            Assert.AreEqual("*****@*****.**", message.To[0].Address);
            Assert.AreEqual("*****@*****.**", message.CarbonCopy[0].Address);
            Assert.AreEqual("Testing the .eml format", message.Subject);
            Assert.AreEqual(3, message.Attachments.Count);
            Assert.That(message.Attachments.Count(x=>x.Name != null && x.Name.Equals("cp_bg_black800.gif")), Iz.EqualTo(1));
            System.Net.Mail.MailMessage mailmessage = message.ToMailMessage();
            Assert.IsNull(mailmessage.From);
            Assert.AreEqual("*****@*****.**", mailmessage.CC[0].Address);
            Assert.AreEqual(message.TextMessage, mailmessage.Body);
            Assert.AreEqual(message.Attachments.Count, mailmessage.Attachments.Count);
        }
Beispiel #2
0
 public void TestThatXmlFilesGetsParsed()
 {
     Assert.That(m_Stream, Iz.Not.Null);
     MIMER.IEndCriteriaStrategy endofmessage = new BasicEndOfMessageStrategy();
     var message = new MailReader().ReadMimeMessage(ref m_Stream, endofmessage);
     Assert.That(message.Attachments.Count(a => a.Type.Equals("text") && a.SubType.Equals("xml")), Iz.EqualTo(1));
 }
Beispiel #3
0
 public void TestThatCorrectNumberOfImagesGetsParsed()
 {
     Assert.That(m_Stream, Iz.Not.Null);
     MIMER.IEndCriteriaStrategy endofmessage = new BasicEndOfMessageStrategy();
     var message = new MailReader().ReadMimeMessage(ref m_Stream, endofmessage);
     Assert.That(message.Attachments.Count(a => a.Type.Equals("image")), Iz.EqualTo(105));
 }
Beispiel #4
0
        public void TestSetup()
        {
            m_EndOfMessageStrategy = new BasicEndOfMessageStrategy();
            m_Reader = new MailReader();
            char[] ar = MIMERTests.Strings.MailMessage1.ToCharArray();
            byte[] bar = Array.ConvertAll<char, byte>(ar, new Converter<char, byte>(
                delegate(char input) { return (byte)input; }));
            m_Stream = new MemoryStream(bar);

            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < 100; i++)
            {
                builder.Append(MIMERTests.Strings.MailMessage1);
            }

            var multiMessageBytes = from char c in builder.ToString() select Convert.ToByte(c);
            m_MultiMessageStream = new MemoryStream(multiMessageBytes.ToArray());

            m_EmptyStream = new MemoryStream();

            IEnumerable<byte> mailMessageWithAttachmentBytes = from char c in Strings.MailMessageWithAttachment select Convert.ToByte(c);
            m_AttachmentStream = new MemoryStream(mailMessageWithAttachmentBytes.ToArray());

            m_EmbeddedMessagaesStream =
                new MemoryStream(System.Text.Encoding.ASCII.GetBytes(
                MIMERTests.Strings.MailMessageWithRecursivlyEmbeddedMessage));

            m_EmbeddedWithAttachmentsStream =
                new MemoryStream(System.Text.Encoding.ASCII.GetBytes(
                MIMERTests.Strings.MailMessageWithEmbeddedWithAttachments));
        }