diff options
Diffstat (limited to 'SendGrid/UnitTest')
-rw-r--r-- | SendGrid/UnitTest/UnitTest.cs | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/SendGrid/UnitTest/UnitTest.cs b/SendGrid/UnitTest/UnitTest.cs index 9064d79..5d1b696 100644 --- a/SendGrid/UnitTest/UnitTest.cs +++ b/SendGrid/UnitTest/UnitTest.cs @@ -1,6 +1,7 @@ using System; using System.Net; using System.Net.Http; +using System.Threading.Tasks; using NUnit.Framework; using Newtonsoft.Json.Linq; using SendGrid; @@ -26,7 +27,7 @@ namespace UnitTest private void TestGet() { - HttpResponseMessage response = client.ApiKeys.Get(); + HttpResponseMessage response = client.ApiKeys.Get().Result; Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); string rawString = response.Content.ReadAsStringAsync().Result; dynamic jsonObject = JObject.Parse(rawString); @@ -36,7 +37,7 @@ namespace UnitTest private void TestPost() { - HttpResponseMessage response = client.ApiKeys.Post("CSharpTestKey"); + HttpResponseMessage response = client.ApiKeys.Post("CSharpTestKey").Result; Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); string rawString = response.Content.ReadAsStringAsync().Result; dynamic jsonObject = JObject.Parse(rawString); @@ -50,7 +51,7 @@ namespace UnitTest private void TestPatch() { - HttpResponseMessage response = client.ApiKeys.Patch(_api_key_id, "CSharpTestKeyPatched"); + HttpResponseMessage response = client.ApiKeys.Patch(_api_key_id, "CSharpTestKeyPatched").Result; Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); string rawString = response.Content.ReadAsStringAsync().Result; dynamic jsonObject = JObject.Parse(rawString); @@ -62,8 +63,35 @@ namespace UnitTest private void TestDelete() { - HttpResponseMessage response = client.ApiKeys.Delete(_api_key_id); + HttpResponseMessage response = client.ApiKeys.Delete(_api_key_id).Result; Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); } + + [Test] + public void TestGetOnce() + { + var responseGet = client.ApiKeys.Get().Result; + } + + [Test] + public void TestGetTenTimes() + { + HttpResponseMessage responseGet; + for (int i = 0; i < 10; i++) + { + responseGet = client.ApiKeys.Get().Result; + } + } + + [Test] + public void TestGetTenTimesAsync() + { + Task[] tasks = new Task[10]; + for (int i = 0; i < 10; i++) + { + tasks[i] = client.ApiKeys.Get(); + } + Task.WaitAll(tasks); + } } } |