diff options
author | Elmer Thomas <elmer@thinkingserious.com> | 2015-11-16 21:16:10 -0800 |
---|---|---|
committer | Elmer Thomas <elmer@thinkingserious.com> | 2015-11-16 21:16:10 -0800 |
commit | 0cfa8dee814a031b51b4b02e7d9389a17956f85b (patch) | |
tree | 3bc78aa90cc565619d7630f69a5837fa6f3b7671 /SendGrid/UnitTest/UnitTest.cs | |
parent | 5f02e69ac1bb329ccbc0014446d90d4a07a699fe (diff) | |
download | sendgrid-csharp-0cfa8dee814a031b51b4b02e7d9389a17956f85b.zip sendgrid-csharp-0cfa8dee814a031b51b4b02e7d9389a17956f85b.tar.gz sendgrid-csharp-0cfa8dee814a031b51b4b02e7d9389a17956f85b.tar.bz2 |
Async all the way through + testing
via deckarep
Diffstat (limited to 'SendGrid/UnitTest/UnitTest.cs')
-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); + } } } |