示例#1
0
        public void DefaultFromTest()
        {
            var options = Options.Create(new PostbodeOptions()
            {
                DefaultFromAddress = "*****@*****.**",
                DefaultFromName    = "test"
            });
            var postbode = new PostbodeClient(options);

            Assert.Equal(postbode.Mail.From.Email, options.Value.DefaultFromAddress);

            Assert.Equal(postbode.Mail.From.Name, options.Value.DefaultFromName);
        }
示例#2
0
        public void RecipientTest()
        {
            var postbode = new PostbodeClient()
                           .SetRecipients(new IRecipient[] { new Recipient("*****@*****.**", "test"), new Recipient("*****@*****.**", "test2") },
                                          RecipientType.To)
                           .SetRecipients(new IRecipient[] { new Recipient("*****@*****.**", "test"), new Recipient("*****@*****.**", "test2") },
                                          RecipientType.Cc)
                           .SetRecipients(new IRecipient[] { new Recipient("*****@*****.**", "test"), new Recipient("*****@*****.**", "test2") },
                                          RecipientType.Bcc);

            Assert.Equal(2, postbode.Mail.To.Length);
            Assert.Equal(2, postbode.Mail.Cc.Length);
            Assert.Equal(2, postbode.Mail.Bcc.Length);
        }
示例#3
0
        public async void SendgridFailTest()
        {
            var       sendgridClient = new SendgridDeliveryService(apikey: "0x000", httpClient: new TestHttpClient(HttpStatusCode.BadRequest, ""));
            IPostbode postbode       = new PostbodeClient();

            postbode =
                postbode.Use(sendgridClient)
                .SetRecipient("*****@*****.**")
                .SetSender("*****@*****.**")
                .SetSubject("test")
                .SetTextContent("HALLLOOOO");

            postbode.Mail.Headers = new Dictionary <string, string>()
            {
                { "test-key", "test-value" }
            };

            var result = await postbode.SendAsync();

            Assert.False(result.Succes);
        }
示例#4
0
        public async void MailgunTest()
        {
            var       mailgunClient = new MailgunDeliveryService(domain: "test.nl", apikey: "0x000", httpClient: new TestHttpClient(HttpStatusCode.OK, ""));
            IPostbode postbode      = new PostbodeClient();

            postbode =
                postbode.Use(mailgunClient)
                .SetRecipient("*****@*****.**")
                .SetSender("*****@*****.**")
                .SetSubject("test")
                .SetTextContent("HALLLOOOO");

            postbode.Mail.Headers = new Dictionary <string, string>()
            {
                { "test-key", "test-value" }
            };

            var result = await postbode.SendAsync();

            Assert.True(result.Succes);
        }
示例#5
0
        public void SendgridNameTest()
        {
            var client = new PostbodeClient().UseSendgrid();

            Assert.Equal(client.DeliveryService.Name.ToLowerInvariant(), "sendgrid");
        }
示例#6
0
        public void TestHtmlContent()
        {
            var response = new PostbodeClient().SetHtmlContent("<h1>Test</h1>");

            Assert.Equal("text/html", response.Mail.Content.Type);
        }
示例#7
0
        public void SmtpNameTest()
        {
            var client = new PostbodeClient().UseSmtp();

            Assert.Equal(client.DeliveryService.Name.ToLowerInvariant(), "system.net.smtp");
        }
示例#8
0
 public async void TestSmtpDelivery()
 {
     var postbode = new PostbodeClient().SetSender("*****@*****.**").SetRecipient("*****@*****.**", type: RecipientType.Cc)
                    .SetTextContent("test").Use(new SmtpDeliveryService());
     await Assert.ThrowsAsync <NotImplementedException>(() => postbode.SendAsync());
 }
示例#9
0
        public void MailgunNameTest()
        {
            var client = new PostbodeClient().UseMailgun();

            Assert.Equal(client.DeliveryService.Name.ToLowerInvariant(), "mailgun");
        }