summaryrefslogtreecommitdiffstats
path: root/SendGrid/UnitTest/UnitTest.cs
diff options
context:
space:
mode:
authorElmer Thomas <elmer@thinkingserious.com>2015-12-15 07:56:03 -0800
committerElmer Thomas <elmer@thinkingserious.com>2015-12-15 07:56:03 -0800
commit88222d0cdcd061c34f72442185a339df3c1f52f7 (patch)
tree77662054ddd81a5dca4085a97e1b6f8c118c6226 /SendGrid/UnitTest/UnitTest.cs
parentd2ca4a5032484335b866b25401f167cdf0bef101 (diff)
downloadsendgrid-csharp-88222d0cdcd061c34f72442185a339df3c1f52f7.zip
sendgrid-csharp-88222d0cdcd061c34f72442185a339df3c1f52f7.tar.gz
sendgrid-csharp-88222d0cdcd061c34f72442185a339df3c1f52f7.tar.bz2
Update tests and example
Diffstat (limited to 'SendGrid/UnitTest/UnitTest.cs')
-rw-r--r--SendGrid/UnitTest/UnitTest.cs33
1 files changed, 32 insertions, 1 deletions
diff --git a/SendGrid/UnitTest/UnitTest.cs b/SendGrid/UnitTest/UnitTest.cs
index 4575e3e..11f55cd 100644
--- a/SendGrid/UnitTest/UnitTest.cs
+++ b/SendGrid/UnitTest/UnitTest.cs
@@ -211,7 +211,7 @@ namespace UnitTest
public Client client = new Client(_apiKey, _baseUri);
[Test]
- public void SuppressionsIntegrationTest()
+ public void GlobalSuppressionsIntegrationTest()
{
string email = "example3@example.com";
@@ -246,6 +246,37 @@ namespace UnitTest
HttpResponseMessage response = client.GlobalSuppressions.Delete(email).Result;
Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode);
}
+ }
+
+ [TestFixture]
+ public class GlobalStats
+ {
+ static string _baseUri = "https://api.sendgrid.com/";
+ static string _apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY");
+ public Client client = new Client(_apiKey, _baseUri);
+
+ [Test]
+ public void GlobalStatsIntegrationTest()
+ {
+ string startDate = "2015-11-01";
+ string endDate = "2015-12-01";
+ string aggregatedBy = "day";
+ TestGet(startDate);
+ TestGet(startDate, endDate);
+ TestGet(startDate, endDate, aggregatedBy);
+ aggregatedBy = "week";
+ TestGet(startDate, endDate, aggregatedBy);
+ aggregatedBy = "month";
+ TestGet(startDate, endDate, aggregatedBy);
+ }
+ private void TestGet(string startDate, string endDate=null, string aggregatedBy=null)
+ {
+ HttpResponseMessage response = client.GlobalStats.Get(startDate, endDate, aggregatedBy).Result;
+ Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
+ string rawString = response.Content.ReadAsStringAsync().Result;
+ dynamic jsonObject = JsonConvert.DeserializeObject(rawString);
+ Assert.IsNotNull(jsonObject);
+ }
}
}