diff options
Diffstat (limited to 'SendGrid/UnitTest/UnitTest.cs')
-rw-r--r-- | SendGrid/UnitTest/UnitTest.cs | 33 |
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); + } } } |