コード例 #1
0
        public void DisableBypassListManagement()
        {
            var header = new Header();
            var sendgrid = new Mail(header);

            sendgrid.DisableBypassListManagement();

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

            sendgrid.DisableClickTracking();

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

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

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

            sendgrid.EnableUnsubscribe(text, html);

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

            header = new Header();
            sendgrid = new Mail(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));
        }
コード例 #4
0
        public void TestDisableGravatar()
        {
            var header = new Header();
            var sendgrid = new Mail(header);

            sendgrid.DisableGravatar();

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

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

            String json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"spamcheck\" : {\"settings\" : {\"enable\" : \"1\",\"maxscore\" : \"5\",\"url\" : \"http:\\/\\/www.example.com\"}}}}", json);
        }
コード例 #6
0
        public void EnableTemplate()
        {
            var header = new Header();
            var sendgrid = new Mail(header);
            var html = "<% hadhdhd %>";

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

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

            escHtml = "bad";
            Assert.Throws<Exception>(() => sendgrid.EnableTemplate(escHtml));
        }
コード例 #7
0
        public void EnableGoogleAnalytics()
        {
            var header = new Header();
            var sendgrid = new Mail(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 + "\"";

            String json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"ganalytics\" : {\"settings\" : {\"enable\" : \"1\","+
                            jsonSource+","+jsonMedium+","+jsonTerm+","+jsonContent+","+jsonCampaign+"}}}}", json);
        }
コード例 #8
0
        public void EnableOpenTracking()
        {
            var header = new Header();
            var sendgrid = new Mail(header);

            sendgrid.EnableOpenTracking();

            String json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"opentrack\" : {\"settings\" : {\"enable\" : \"1\"}}}}", json);
        }
コード例 #9
0
        public void EnableFooter()
        {
            var header = new Header();
            var sendgrid = new Mail(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);

            String json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"footer\" : {\"settings\" : {\"enable\" : \"1\",\"text\\/plain\" : \""+text+"\",\"text\\/html\" : \""+escHtml+"\"}}}}", json);
        }
コード例 #10
0
        public void EnableClickTracking()
        {
            var header = new Header();
            var sendgrid = new Mail(header);
            bool includePlainText = true;
            sendgrid.EnableClickTracking(includePlainText);

            String json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"clicktrack\" : {\"settings\" : {\"enable\" : \"1\",\"enable_text\" : \"1\"}}}}", json);
        }
コード例 #11
0
        public void EnableBcc()
        {
            var header = new Header();
            var sendgrid = new Mail(header);

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

            String json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"bcc\" : {\"settings\" : {\"enable\" : \"1\",\"email\" : \"" + email + "\"}}}}", json);
        }
コード例 #12
0
        public void DisableGoogleAnalytics()
        {
            var header = new Header();
            var sendgrid = new Mail(header);

            sendgrid.DisableGoogleAnalytics();

            String json = header.JsonString();
            Assert.AreEqual("{\"filters\" : {\"ganalytics\" : {\"settings\" : {\"enable\" : \"0\"}}}}", json);
        }
コード例 #13
0
        static string XsmtpapiHeaderAsJson()
        {
            var header = new Header();

            var uniqueArgs = new Dictionary<string, string> {
                {
                    "foo",
                    "bar"
                },
                {
                    "chunky",
                    "bacon"
                }
            };
            header.AddUniqueArgs(uniqueArgs);

            return header.JsonString();
        }