diff options
author | Tyler Bischel <tyler.bischel@sendgrid.com> | 2012-01-16 23:06:25 -0800 |
---|---|---|
committer | Tyler Bischel <tyler.bischel@sendgrid.com> | 2012-01-16 23:06:25 -0800 |
commit | 32bae16f1cdfd3ef1a2768b9a9a425aacdcbe186 (patch) | |
tree | 2c99849d5068709e5d2b05dfd5e6bd4c6d13ebaa /SendGrid/Tests/TestSendgrid.cs | |
parent | 9f24ab50b3e2658128d98bd006e1a65b305179a2 (diff) | |
parent | f5fd9054b23d5f8c4c915da36ad2eaa59f302918 (diff) | |
download | sendgrid-csharp-32bae16f1cdfd3ef1a2768b9a9a425aacdcbe186.zip sendgrid-csharp-32bae16f1cdfd3ef1a2768b9a9a425aacdcbe186.tar.gz sendgrid-csharp-32bae16f1cdfd3ef1a2768b9a9a425aacdcbe186.tar.bz2 |
merged and added some new tests
Diffstat (limited to 'SendGrid/Tests/TestSendgrid.cs')
-rwxr-xr-x | SendGrid/Tests/TestSendgrid.cs | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/SendGrid/Tests/TestSendgrid.cs b/SendGrid/Tests/TestSendgrid.cs index 71160dc..95604d3 100755 --- a/SendGrid/Tests/TestSendgrid.cs +++ b/SendGrid/Tests/TestSendgrid.cs @@ -191,20 +191,34 @@ namespace Tests var text = "<% %>";
var html = "<% name %>";
- var replace = "John";
- var url = "http://www.example.com";
- var landing = "this_landing";
- sendgrid.EnableUnsubscribe(text, html, replace, url, landing);
- var jsonText = "\"text\\/plain\" : \""+text+"\"";
- var jsonHtml = "\"text\\/html\" : \""+html+"\"";
- var jsonReplace = "\"replace\" : \""+replace+"\"";
- var jsonUrl = "\"url\" : \"http:\\/\\/www.example.com\"";
- var jsonLanding = "\"landing\" : \""+landing+"\"";
+ 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+","+jsonUrl+","+jsonLanding+"}}}}", 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); });
}
@@ -261,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]
@@ -291,7 +308,7 @@ namespace Tests [Test]
public void CreateMimeMessage()
{
- var message = SendGrid.GenerateInstance();
+ var message = SendGrid.GetInstance();
var attachment = System.IO.Path.GetTempFileName();
var text = "this is a test";
var html = "<b>This<\b> is a better test";
|