summaryrefslogtreecommitdiffstats
path: root/SendGrid
diff options
context:
space:
mode:
authorElmer Thomas <elmer@thinkingserious.com>2015-11-11 16:23:35 -0800
committerElmer Thomas <elmer@thinkingserious.com>2015-11-11 16:23:35 -0800
commit8486c9329b51b65cff43a77103731b938e1a159e (patch)
tree3044813eeca9a61020a0a8f633810fd44adb0ac0 /SendGrid
parentfc7440ca079c6601bc340ee45c7876c7d2f66643 (diff)
downloadsendgrid-csharp-8486c9329b51b65cff43a77103731b938e1a159e.zip
sendgrid-csharp-8486c9329b51b65cff43a77103731b938e1a159e.tar.gz
sendgrid-csharp-8486c9329b51b65cff43a77103731b938e1a159e.tar.bz2
Updating tests
Diffstat (limited to 'SendGrid')
-rw-r--r--SendGrid/SendGrid.sln20
-rw-r--r--SendGrid/Tests/Resources/TestApiKeys.cs73
-rw-r--r--SendGrid/Tests/Tests.csproj2
3 files changed, 75 insertions, 20 deletions
diff --git a/SendGrid/SendGrid.sln b/SendGrid/SendGrid.sln
index 6ca7af6..8c275f8 100644
--- a/SendGrid/SendGrid.sln
+++ b/SendGrid/SendGrid.sln
@@ -20,8 +20,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mail", "SendGridMail\Mail.c
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SendGrid", "SendGrid\SendGrid.csproj", "{1C318867-440B-4EB9-99E3-C0CC2C556962}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SendGridTests", "UnitTests\SendGridTests.csproj", "{2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
BuildNet45|Any CPU = BuildNet45|Any CPU
@@ -97,24 +95,6 @@ Global
{1C318867-440B-4EB9-99E3-C0CC2C556962}.Release|Mixed Platforms.Build.0 = Debug|Any CPU
{1C318867-440B-4EB9-99E3-C0CC2C556962}.Release|x86.ActiveCfg = Release|Any CPU
{1C318867-440B-4EB9-99E3-C0CC2C556962}.Release|x86.Build.0 = Release|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.BuildNet45|Any CPU.ActiveCfg = Release|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.BuildNet45|Any CPU.Build.0 = Release|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.BuildNet45|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.BuildNet45|Mixed Platforms.Build.0 = Debug|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.BuildNet45|x86.ActiveCfg = Release|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.BuildNet45|x86.Build.0 = Release|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.Debug|x86.ActiveCfg = Debug|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.Debug|x86.Build.0 = Debug|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.Release|Any CPU.Build.0 = Release|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.Release|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.Release|Mixed Platforms.Build.0 = Debug|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.Release|x86.ActiveCfg = Release|Any CPU
- {2BE80F7D-EBB3-47F5-8CCB-B0F634D51849}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/SendGrid/Tests/Resources/TestApiKeys.cs b/SendGrid/Tests/Resources/TestApiKeys.cs
new file mode 100644
index 0000000..ee30507
--- /dev/null
+++ b/SendGrid/Tests/Resources/TestApiKeys.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Mail;
+using Moq;
+using Newtonsoft.Json.Linq;
+using NUnit.Framework;
+using SendGrid;
+
+namespace Tests.Transport
+{
+ [TestFixture]
+ internal class TestApiKeys
+ {
+ static string _baseUri = "https://api.sendgrid.com/";
+ static string _apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY", EnvironmentVariableTarget.User);
+ public Client client = new Client(_apiKey, _baseUri);
+ private static string _api_key_id = "";
+
+ [Test]
+ public void ApiKeysIntegrationTest()
+ {
+ TestGet();
+ TestPost();
+ TestPatch();
+ TestDelete();
+ }
+
+ private void TestGet()
+ {
+ HttpResponseMessage response = client.ApiKeys.Get();
+ Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
+ string rawString = response.Content.ReadAsStringAsync().Result;
+ dynamic jsonObject = JObject.Parse(rawString);
+ string jsonString = jsonObject.result.ToString();
+ Assert.IsNotNull(jsonString);
+ }
+
+ private void TestPost()
+ {
+ HttpResponseMessage response = client.ApiKeys.Post("CSharpTestKey");
+ Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
+ string rawString = response.Content.ReadAsStringAsync().Result;
+ dynamic jsonObject = JObject.Parse(rawString);
+ string api_key = jsonObject.api_key.ToString();
+ _api_key_id = jsonObject.api_key_id.ToString();
+ string name = jsonObject.name.ToString();
+ Assert.IsNotNull(api_key);
+ Assert.IsNotNull(_api_key_id);
+ Assert.IsNotNull(name);
+ }
+
+ private void TestPatch()
+ {
+ HttpResponseMessage response = client.ApiKeys.Patch(_api_key_id, "CSharpTestKeyPatched");
+ Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
+ string rawString = response.Content.ReadAsStringAsync().Result;
+ dynamic jsonObject = JObject.Parse(rawString);
+ _api_key_id = jsonObject.api_key_id.ToString();
+ string name = jsonObject.name.ToString();
+ Assert.IsNotNull(_api_key_id);
+ Assert.IsNotNull(name);
+ }
+
+ private void TestDelete()
+ {
+ HttpResponseMessage response = client.ApiKeys.Delete(_api_key_id);
+ Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode);
+ }
+ }
+} \ No newline at end of file
diff --git a/SendGrid/Tests/Tests.csproj b/SendGrid/Tests/Tests.csproj
index 37bacce..cc57b80 100644
--- a/SendGrid/Tests/Tests.csproj
+++ b/SendGrid/Tests/Tests.csproj
@@ -49,6 +49,7 @@
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="Microsoft.CSharp" />
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.2.1402.2112\lib\net40\Moq.dll</HintPath>
</Reference>
@@ -68,6 +69,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Resources\TestApiKeys.cs" />
<Compile Include="TestSendgrid.cs" />
<Compile Include="Transport\TestErrorChecker.cs" />
<Compile Include="Transport\TestWebApi.cs" />