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); }
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); }
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); }
public void TestEnable() { var test = new Header(); test.Enable("foo"); var result = test.AsJson(); Assert.AreEqual("{\"filters\" : {\"foo\" : {\"settings\" : {\"enable\" : \"1\"}}}}", result); }
public void TestAddSection() { var test = new Header(); test.AddSection("foo", "bar"); var result = test.AsJson(); Assert.AreEqual("{\"section\" : {\"foo\" : \"bar\"}}", result); }
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); }
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); }
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); }
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); }
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); }
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)); }
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)); }
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); }
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); }
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); }
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); }
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); }
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); }
/// <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); }
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); }
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); }
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); }
public void TestSetCategory() { var test = new Header(); test.SetCategory("foo"); var result = test.AsJson(); Assert.AreEqual("{\"category\" : \"foo\"}", result); }
/// <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); }
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); }