summaryrefslogtreecommitdiffstats
path: root/SendGrid/Tests/TestSendgrid.cs
diff options
context:
space:
mode:
Diffstat (limited to 'SendGrid/Tests/TestSendgrid.cs')
-rwxr-xr-xSendGrid/Tests/TestSendgrid.cs33
1 files changed, 27 insertions, 6 deletions
diff --git a/SendGrid/Tests/TestSendgrid.cs b/SendGrid/Tests/TestSendgrid.cs
index 3631dc1..95604d3 100755
--- a/SendGrid/Tests/TestSendgrid.cs
+++ b/SendGrid/Tests/TestSendgrid.cs
@@ -191,16 +191,34 @@ namespace Tests
var text = "<% %>";
var html = "<% name %>";
- var replace = "John";
- sendgrid.EnableUnsubscribe(text, html);
- var jsonText = "\"text\\/plain\" : \""+text+"\"";
- var jsonHtml = "\"text\\/html\" : \""+html+"\"";
- var jsonReplace = "\"replace\" : \""+replace+"\"";
+ var jsonText = "\"text\\/plain\" : \"" + text + "\"";
+ var jsonHtml = "\"text\\/html\" : \"" + html + "\"";
+
+ sendgrid.EnableUnsubscribe(text, html);
String json = header.AsJson();
Assert.AreEqual("{\"filters\" : {\"subscriptiontrack\" : {\"settings\" : {\"enable\" : \"1\","+
- jsonText+","+jsonHtml+","+jsonReplace+","+"}}}}", json);
+ jsonText+","+jsonHtml+"}}}}", json);
+
+ header = new Header();
+ sendgrid = new SendGrid(header);
+
+ var replace = "John";
+ var jsonReplace = "\"replace\" : \"" + replace + "\"";
+
+ sendgrid.EnableUnsubscribe(replace);
+
+ json = header.AsJson();
+ Assert.AreEqual("{\"filters\" : {\"subscriptiontrack\" : {\"settings\" : {\"enable\" : \"1\"," + jsonReplace + "}}}}", json);
+
+ text = "bad";
+ html = "<% name %>";
+ Assert.Throws<Exception>(delegate { sendgrid.EnableUnsubscribe(text, html); });
+
+ text = "<% %>";
+ html = "bad";
+ Assert.Throws<Exception>(delegate { sendgrid.EnableUnsubscribe(text, html); });
}
@@ -257,6 +275,9 @@ namespace Tests
String json = header.AsJson();
Assert.AreEqual("{\"filters\" : {\"template\" : {\"settings\" : {\"enable\" : \"1\",\"text\\/html\" : \""+escHtml+"\"}}}}", json);
+
+ escHtml = "bad";
+ Assert.Throws<Exception>(delegate { sendgrid.EnableTemplate(escHtml); });
}
[Test]