diff options
author | Elmer Thomas <elmer@thinkingserious.com> | 2015-12-14 09:08:38 -0800 |
---|---|---|
committer | Elmer Thomas <elmer@thinkingserious.com> | 2015-12-14 09:08:38 -0800 |
commit | 3439c44f35cef9bf6f66ae236627ed9777b428eb (patch) | |
tree | 2a8d25efcba8a795c84d3338e9ff0af0c000655d /SendGrid/UnitTest/UnitTest.cs | |
parent | 1fef90ac423a2e9c8623060b9ae0c511c4cacce0 (diff) | |
download | sendgrid-csharp-3439c44f35cef9bf6f66ae236627ed9777b428eb.zip sendgrid-csharp-3439c44f35cef9bf6f66ae236627ed9777b428eb.tar.gz sendgrid-csharp-3439c44f35cef9bf6f66ae236627ed9777b428eb.tar.bz2 |
Added Global Suppressions GET, POST, DELETE
Diffstat (limited to 'SendGrid/UnitTest/UnitTest.cs')
-rw-r--r-- | SendGrid/UnitTest/UnitTest.cs | 120 |
1 files changed, 83 insertions, 37 deletions
diff --git a/SendGrid/UnitTest/UnitTest.cs b/SendGrid/UnitTest/UnitTest.cs index eab3481..4575e3e 100644 --- a/SendGrid/UnitTest/UnitTest.cs +++ b/SendGrid/UnitTest/UnitTest.cs @@ -155,50 +155,96 @@ namespace UnitTest Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); } - [TestFixture] - public class Suppressions + } + + [TestFixture] + public class Suppressions + { + static string _baseUri = "https://api.sendgrid.com/"; + static string _apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY"); + public Client client = new Client(_apiKey, _baseUri); + + [Test] + public void SuppressionsIntegrationTest() { - static string _baseUri = "https://api.sendgrid.com/"; - static string _apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY"); - public Client client = new Client(_apiKey, _baseUri); + int unsubscribeGroupId = 69; - [Test] - public void SuppressionsIntegrationTest() - { - int unsubscribeGroupId = 69; + TestGet(unsubscribeGroupId); + string[] emails = { "example@example.com", "example2@example.com" }; + TestPost(unsubscribeGroupId, emails); + TestDelete(unsubscribeGroupId, "example@example.com"); + TestDelete(unsubscribeGroupId, "example2@example.com"); + } - TestGet(unsubscribeGroupId); - string[] emails = { "example@example.com", "example2@example.com" }; - TestPost(unsubscribeGroupId, emails); - TestDelete(unsubscribeGroupId, "example@example.com"); - TestDelete(unsubscribeGroupId, "example2@example.com"); - } + private void TestGet(int unsubscribeGroupId) + { + HttpResponseMessage response = client.Suppressions.Get(unsubscribeGroupId).Result; + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + string rawString = response.Content.ReadAsStringAsync().Result; + dynamic jsonObject = JsonConvert.DeserializeObject(rawString); + Assert.IsNotNull(jsonObject); + } - private void TestGet(int unsubscribeGroupId) - { - HttpResponseMessage response = client.Suppressions.Get(unsubscribeGroupId).Result; - Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); - string rawString = response.Content.ReadAsStringAsync().Result; - dynamic jsonObject = JsonConvert.DeserializeObject(rawString); - Assert.IsNotNull(jsonObject); - } + private void TestPost(int unsubscribeGroupId, string[] emails) + { + HttpResponseMessage response = client.Suppressions.Post(unsubscribeGroupId, emails).Result; + Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); + string rawString = response.Content.ReadAsStringAsync().Result; + dynamic jsonObject = JObject.Parse(rawString); + string recipient_emails = jsonObject.recipient_emails.ToString(); + Assert.IsNotNull(recipient_emails); + } - private void TestPost(int unsubscribeGroupId, string[] emails) - { - HttpResponseMessage response = client.Suppressions.Post(unsubscribeGroupId, emails).Result; - Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); - string rawString = response.Content.ReadAsStringAsync().Result; - dynamic jsonObject = JObject.Parse(rawString); - string recipient_emails = jsonObject.recipient_emails.ToString(); - Assert.IsNotNull(recipient_emails); - } + private void TestDelete(int unsubscribeGroupId, string email) + { + HttpResponseMessage response = client.Suppressions.Delete(unsubscribeGroupId, email).Result; + Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); + } - private void TestDelete(int unsubscribeGroupId, string email) - { - HttpResponseMessage response = client.Suppressions.Delete(unsubscribeGroupId, email).Result; - Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); - } + } + + [TestFixture] + public class GlobalSuppressions + { + static string _baseUri = "https://api.sendgrid.com/"; + static string _apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY"); + public Client client = new Client(_apiKey, _baseUri); + + [Test] + public void SuppressionsIntegrationTest() + { + string email = "example3@example.com"; + + TestGet(email); + string[] emails = { "example1@example.com", "example2@example.com" }; + TestPost(emails); + TestDelete("example1@example.com"); + TestDelete("example2@example.com"); + } + private void TestGet(string email) + { + HttpResponseMessage response = client.GlobalSuppressions.Get(email).Result; + Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); + string rawString = response.Content.ReadAsStringAsync().Result; + dynamic jsonObject = JsonConvert.DeserializeObject(rawString); + Assert.IsNotNull(jsonObject); + } + + private void TestPost(string[] emails) + { + HttpResponseMessage response = client.GlobalSuppressions.Post(emails).Result; + Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); + string rawString = response.Content.ReadAsStringAsync().Result; + dynamic jsonObject = JObject.Parse(rawString); + string recipient_emails = jsonObject.recipient_emails.ToString(); + Assert.IsNotNull(recipient_emails); + } + + private void TestDelete(string email) + { + HttpResponseMessage response = client.GlobalSuppressions.Delete(email).Result; + Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); } } |