コード例 #1
0
        public void Test_AttachFile_filepath()
        {
            var filename = Path.GetTempFileName();
            var mail     = BasicMailBuilder
                           .AttachFile(filename)
                           .Build();

            var message = new SendGridMessage();

            message.AddAttachment(filename);
            CollectionAssert.AreEquivalent(message.Attachments, mail.Attachments);
            CollectionAssert.AreEquivalent(message.StreamedAttachments, mail.StreamedAttachments);
        }
コード例 #2
0
        public void Test_AttachFile_attachment()
        {
            var filename   = Path.GetTempFileName();
            var attachment = new Attachment(filename);
            var mail       = BasicMailBuilder
                             .AttachFile(attachment)
                             .Build();

            var message = new SendGridMessage();

            message.AddAttachment(attachment.ContentStream, attachment.Name);
            Assert.AreEqual(1, message.StreamedAttachments.Count);
            Assert.AreEqual(1, mail.StreamedAttachments.Count);
            Assert.IsTrue(message.StreamedAttachments.ContainsKey(attachment.Name));
            Assert.IsTrue(mail.StreamedAttachments.ContainsKey(attachment.Name));
            Assert.AreEqual(message.StreamedAttachments[attachment.Name].Length, mail.StreamedAttachments[attachment.Name].Length);
        }