コード例 #1
0
 public void TestAddUniqueIdentifier()
 {
     var test = new Header();
     test.AddUniqueIdentifier(new Dictionary<string, string>(){{"foo", "bar"}});
     var result = test.AsJson();
     Assert.AreEqual("{\"unique_args\" : {\"foo\" : \"bar\"}}", result);
 }
コード例 #2
0
 public void TestAddSubVal()
 {
     var test = new Header();
     test.AddSubVal("foo", new List<string>{"bar", "raz"});
     var result = test.AsJson();
     Assert.AreEqual("{\"sub\" : {\"foo\" : [\"bar\", \"raz\"]}}", result);
 }
コード例 #3
0
 public void TestAddFilterSetting()
 {
     var test = new Header();
     test.AddFilterSetting("foo", new List<string> { "a", "b" }, "bar");
     var result = test.AsJson();
     Assert.AreEqual("{\"filters\" : {\"foo\" : {\"settings\" : {\"a\" : {\"b\" : \"bar\"}}}}}", result);
 }
コード例 #4
0
 public void TestEnable()
 {
     var test = new Header();
     test.Enable("foo");
     var result = test.AsJson();
     Assert.AreEqual("{\"filters\" : {\"foo\" : {\"settings\" : {\"enable\" : \"1\"}}}}", result);
 }
コード例 #5
0
ファイル: TestHeader.cs プロジェクト: kernkw/sendgrid-csharp
 public void TestAddSection()
 {
     var test = new Header();
     test.AddSection("foo", "bar");
     var result = test.AsJson();
     Assert.AreEqual("{\"section\" : {\"foo\" : \"bar\"}}", result);
 }
コード例 #6
0
 public void TestAddHeader()
 {
     var test = new Header();
     test.AddSubVal("foo", new List<string> { "a", "b" });
     var mime = new MailMessage();
     test.AddHeader(mime);
     var result = mime.Headers.Get("x-smtpapi");
     Assert.AreEqual("{\"sub\" : {\"foo\" : [\"a\", \"b\"]}}", result);
 }
コード例 #7
0
        public void DisableClickTracking()
        {
            var header = new Header();
            var sendgrid = new SendGrid(header);

            sendgrid.DisableClickTracking();

            var json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"clicktrack\" : {\"settings\" : {\"enable\" : \"0\"}}}}", json);
        }
コード例 #8
0
        public void DisableBcc()
        {
            var header = new Header();
            var sendgrid = new SendGrid(header);

            sendgrid.DisableBcc();

            String json = header.AsJson();
            Assert.AreEqual("{\"filters\" : {\"bcc\" : {\"settings\" : {\"enable\" : \"0\"}}}}", json);
        }
コード例 #9
0
        public void DisableBypassListManagement()
        {
            var header = new Header();
            var sendgrid = new SendGrid(header);

            sendgrid.DisableBypassListManagement();

            var json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"bypass_list_management\" : {\"settings\" : {\"enable\" : \"0\"}}}}", json);
        }
コード例 #10
0
        public void TestDisableGravatar()
        {
            var header = new Header();
            var sendgrid = new SendGrid(header);

            sendgrid.DisableGravatar();

            var json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"gravatar\" : {\"settings\" : {\"enable\" : \"0\"}}}}", json);
        }
コード例 #11
0
        public void EnableTemplate()
        {
            var header = new Header();
            var sendgrid = new SendGrid(header);
            var html = "<% hadhdhd %>";

            var escHtml = "<% hadhdhd %>";
            sendgrid.EnableTemplate(html);

            var json = header.JsonString();
            Assert.AreEqual(
                "{\"filters\" : {\"template\" : {\"settings\" : {\"enable\" : \"1\",\"text\\/html\" : \"" + escHtml + "\"}}}}", json);

            escHtml = "bad";
            Assert.Throws<Exception>(() => sendgrid.EnableTemplate(escHtml));
        }
コード例 #12
0
        public void EnableUnsubscribe()
        {
            var header = new Header();
            var sendgrid = new SendGrid(header);

            var text = "<% %>";
            var html = "<% name %>";

            var jsonText = "\"text\\/plain\" : \"" + text + "\"";
            var jsonHtml = "\"text\\/html\" : \"" + html + "\"";

            sendgrid.EnableUnsubscribe(text, html);

            var json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"subscriptiontrack\" : {\"settings\" : {\"enable\" : \"1\"," +
                            jsonText + "," + jsonHtml + "}}}}", json);

            header = new Header();
            sendgrid = new SendGrid(header);

            var replace = "John";
            var jsonReplace = "\"replace\" : \"" + replace + "\"";

            sendgrid.EnableUnsubscribe(replace);

            json = header.JsonString();
            Assert.AreEqual(
                "{\"filters\" : {\"subscriptiontrack\" : {\"settings\" : {\"enable\" : \"1\"," + jsonReplace + "}}}}", json);

            text = "bad";
            html = "<% name %>";
            Assert.Throws<Exception>(() => sendgrid.EnableUnsubscribe(text, html));

            text = "<% %>";
            html = "bad";
            Assert.Throws<Exception>(() => sendgrid.EnableUnsubscribe(text, html));
        }
コード例 #13
0
        public void EnableOpenTracking()
        {
            var header = new Header();
            var sendgrid = new SendGrid(header);

            sendgrid.EnableOpenTracking();

            var json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"opentrack\" : {\"settings\" : {\"enable\" : \"1\"}}}}", json);
        }
コード例 #14
0
        public void EnableSpamCheck()
        {
            var header = new Header();
            var sendgrid = new SendGrid(header);

            var score = 5;
            var url = "http://www.example.com";
            sendgrid.EnableSpamCheck(score, url);

            var json = header.JsonString();
            Assert.AreEqual(
                "{\"filters\" : {\"spamcheck\" : {\"settings\" : {\"enable\" : \"1\",\"maxscore\" : \"5\",\"url\" : \"http:\\/\\/www.example.com\"}}}}",
                json);
        }
コード例 #15
0
        public void EnableFooter()
        {
            var header = new Header();
            var sendgrid = new SendGrid(header);

            var text = "My Text";
            var html = "<body><p>hello, <% name %></p></body>";
            var escHtml = "<body><p>hello, <% name %><\\/p><\\/body>";

            sendgrid.EnableFooter(text, html);

            var json = header.JsonString();
            Assert.AreEqual(
                "{\"filters\" : {\"footer\" : {\"settings\" : {\"enable\" : \"1\",\"text\\/plain\" : \"" + text +
                "\",\"text\\/html\" : \"" + escHtml + "\"}}}}", json);
        }
コード例 #16
0
        public void EnableGoogleAnalytics()
        {
            var header = new Header();
            var sendgrid = new SendGrid(header);

            var source = "SomeDomain.com";
            var medium = "Email";
            var term = "keyword1, keyword2, keyword3";
            var content = "PG, PG13";
            var campaign = "my_campaign";

            sendgrid.EnableGoogleAnalytics(source, medium, term, content, campaign);

            var jsonSource = "\"utm_source\" : \"SomeDomain.com\"";
            var jsonMedium = "\"utm_medium\" : \"" + medium + "\"";
            var jsonTerm = "\"utm_term\" : \"" + term + "\"";
            var jsonContent = "\"utm_content\" : \"" + content + "\"";
            var jsonCampaign = "\"utm_campaign\" : \"" + campaign + "\"";

            var json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"ganalytics\" : {\"settings\" : {\"enable\" : \"1\"," +
                            jsonSource + "," + jsonMedium + "," + jsonTerm + "," + jsonContent + "," + jsonCampaign + "}}}}",
                json);
        }
コード例 #17
0
 public void TestSetCategories()
 {
     var test = new Header();
     test.SetCategories(new List<string>{"dogs","animals","pets","mammals"});
     var result = test.AsJson();
     Assert.AreEqual("{\"category\" : [\"dogs\", \"animals\", \"pets\", \"mammals\"]}", result);
 }
コード例 #18
0
        public void EnableBcc()
        {
            var header = new Header();
            var sendgrid = new SendGrid(header);

            var email = "*****@*****.**";
            sendgrid.EnableBcc(email);

            var json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"bcc\" : {\"settings\" : {\"enable\" : \"1\",\"email\" : \"" + email + "\"}}}}",
                json);
        }
コード例 #19
0
ファイル: SendGrid.cs プロジェクト: SmgIgor/SenchaDemo
 /// <summary>
 /// Creates an instance of SendGrid's custom message object
 /// </summary>
 /// <returns></returns>
 public static SendGrid GetInstance()
 {
     var header = new Header();
     return new SendGrid(header);
 }
コード例 #20
0
        public void TestDisableOpenTracking()
        {
            var header = new Header();
            var sendgrid = new SendGrid(header);

            sendgrid.DisableOpenTracking();

            String json = header.AsJson();
            Assert.AreEqual("{\"filters\" : {\"opentrack\" : {\"settings\" : {\"enable\" : \"0\"}}}}", json);
        }
コード例 #21
0
        public void EnableGravatar()
        {
            var header = new Header();
            var sendgrid = new SendGrid(header);

            sendgrid.EnableGravatar();

            String json = header.AsJson();
            Assert.AreEqual("{\"filters\" : {\"gravatar\" : {\"settings\" : {\"enable\" : \"1\"}}}}", json);
        }
コード例 #22
0
        public void EnableClickTracking()
        {
            var header = new Header();
            var sendgrid = new SendGrid(header);
            bool includePlainText = true;
            sendgrid.EnableClickTracking(includePlainText);

            String json = header.AsJson();
            Assert.AreEqual("{\"filters\" : {\"clicktrack\" : {\"settings\" : {\"enable\" : \"1\",\"enable_text\" : \"1\"}}}}", json);
        }
コード例 #23
0
 public void TestSetCategory()
 {
     var test = new Header();
     test.SetCategory("foo");
     var result = test.AsJson();
     Assert.AreEqual("{\"category\" : \"foo\"}", result);
 }
コード例 #24
0
ファイル: SendGrid.cs プロジェクト: SmgIgor/SenchaDemo
 /// <summary>
 /// Creates an instance of SendGrid's custom message object with mail parameters
 /// </summary>
 /// <param name="from">The email address of the sender</param>
 /// <param name="to">An array of the recipients</param>
 /// <param name="cc">Supported over SMTP, with future plans for support in the Web transport</param>
 /// <param name="bcc">Blind recipients</param>
 /// <param name="subject">The subject of the message</param>
 /// <param name="html">the html content for the message</param>
 /// <param name="text">the plain text part of the message</param>
 /// <param name="transport">Transport class to use for sending the message</param>
 /// <returns></returns>
 public static SendGrid GetInstance(MailAddress from, MailAddress[] to, MailAddress[] cc, MailAddress[] bcc,
                                         String subject, String html, String text)
 {
     var header = new Header();
     return new SendGrid(from, to, cc, bcc, subject, html, text, header);
 }
コード例 #25
0
        public void DisableGoogleAnalytics()
        {
            var header = new Header();
            var sendgrid = new SendGrid(header);

            sendgrid.DisableGoogleAnalytics();

            var json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"ganalytics\" : {\"settings\" : {\"enable\" : \"0\"}}}}", json);
        }