diff --git a/.gitignore b/.gitignore
index 52ac3f35b..536bea2ef 100644
--- a/.gitignore
+++ b/.gitignore
@@ -325,4 +325,5 @@ $RECYCLE.BIN/
# Code
/.vscode
-.env
\ No newline at end of file
+.env
+prism
diff --git a/.travis.yml b/.travis.yml
index 52326bc0c..8f88556b3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,21 +4,19 @@ solution: SendGrid.sln
os: linux
dist: bionic
mono: latest
-sudo: required
+
+services:
+ - docker
before_install:
- mkdir -p .nuget
- wget -O .nuget/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
-before_script:
- # https://github.com/dotnet/sdk/issues/335
- - if test "$TRAVIS_OS_NAME" == "osx"; then export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/; else export FrameworkPathOverride=/usr/lib/mono/4.5/; fi
- - mkdir prism/bin
- - export PATH=$PATH:$PWD/prism/bin/
- - ./prism/prism.sh
- - nohup prism run -s https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json &
+env:
+ - FrameworkPathOverride=/usr/lib/mono/4.5/
script:
+ - make test-docker
- make release
after_success:
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 000000000..36afddf8d
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,20 @@
+FROM mono:latest
+
+ENV FrameworkPathOverride /usr/lib/mono/4.5/
+
+RUN apt-get update \
+ && apt-get install -y curl make apt-transport-https
+
+RUN curl -sSL https://packages.microsoft.com/config/ubuntu/19.10/packages-microsoft-prod.deb -o packages-microsoft-prod.deb \
+ && dpkg --install packages-microsoft-prod.deb
+
+RUN apt-get update \
+ && apt-get install -y dotnet-sdk-2.1
+
+COPY prism/prism/nginx/cert.crt /usr/local/share/ca-certificates/cert.crt
+RUN update-ca-certificates
+
+WORKDIR /app
+COPY . .
+
+RUN make install
diff --git a/Makefile b/Makefile
index 6d7291595..943991335 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-.PHONY: clean test install release
+.PHONY: clean install test test-integ test-docker release
clean:
dotnet clean
@@ -8,12 +8,17 @@ install:
dotnet restore
test:
- dotnet restore
dotnet build ./src/SendGrid -c Release
dotnet test ./tests/SendGrid.Tests/SendGrid.Tests.csproj -c Release -f netcoreapp2.1
curl -s https://codecov.io/bash > .codecov
chmod +x .codecov
./.codecov
-release: test
+test-integ: test
+
+test-docker:
+ curl -s https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/prism/prism.sh | bash
+
+release:
+ dotnet build ./src/SendGrid -c Release
dotnet pack ./src/SendGrid -c Release
diff --git a/prism/prism.sh b/prism/prism.sh
deleted file mode 100755
index 5d9d30024..000000000
--- a/prism/prism.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/bash
-
-install () {
-
-set -eu
-
-UNAME=$(uname)
-ARCH=$(uname -m)
-if [ "$UNAME" != "Linux" ] && [ "$UNAME" != "Darwin" ] && [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "i686" ]; then
- echo "Sorry, OS/Architecture not supported: ${UNAME}/${ARCH}. Download binary from https://github.com/stoplightio/prism/releases"
- exit 1
-fi
-
-if [ "$UNAME" = "Darwin" ] ; then
- OSX_ARCH=$(uname -m)
- if [ "${OSX_ARCH}" = "x86_64" ] ; then
- PLATFORM="darwin_amd64"
- fi
-elif [ "$UNAME" = "Linux" ] ; then
- LINUX_ARCH=$(uname -m)
- if [ "${LINUX_ARCH}" = "i686" ] ; then
- PLATFORM="linux_386"
- elif [ "${LINUX_ARCH}" = "x86_64" ] ; then
- PLATFORM="linux_amd64"
- fi
-fi
-
-#LATEST=$(curl -s https://api.github.com/repos/stoplightio/prism/tags | grep -Eo '"name":.*?[^\\]",' | head -n 1 | sed 's/[," ]//g' | cut -d ':' -f 2)
-LATEST="v0.1.5"
-URL="https://github.com/stoplightio/prism/releases/download/$LATEST/prism_$PLATFORM"
-DEST=./prism/bin/prism
-
-if [ -z $LATEST ] ; then
- echo "Error requesting. Download binary from ${URL}"
- exit 1
-else
- curl -L $URL -o $DEST
- chmod +x $DEST
-fi
-}
-
-install
\ No newline at end of file
diff --git a/src/SendGrid/SendGrid.csproj b/src/SendGrid/SendGrid.csproj
index f2234dc07..787380443 100644
--- a/src/SendGrid/SendGrid.csproj
+++ b/src/SendGrid/SendGrid.csproj
@@ -39,12 +39,6 @@
-
-
- All
-
-
-
diff --git a/tests/SendGrid.Tests/Integration.cs b/tests/SendGrid.Tests/Integration.cs
index 898903551..4fe767ae4 100644
--- a/tests/SendGrid.Tests/Integration.cs
+++ b/tests/SendGrid.Tests/Integration.cs
@@ -14,43 +14,9 @@
using Xunit;
using Xunit.Abstractions;
- public class IntegrationFixture : IDisposable
+ public class IntegrationFixture
{
- public IntegrationFixture()
- {
- if (Environment.GetEnvironmentVariable("TRAVIS") != "true")
- {
- Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
- Trace.WriteLine("Starting Prism (~20 seconds)");
- var startInfo = new ProcessStartInfo
- {
- CreateNoWindow = true,
- UseShellExecute = false,
- FileName = "prism.exe",
- Arguments =
- "run -s https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json"
- };
- process.StartInfo = startInfo;
- process.Start();
- System.Threading.Thread.Sleep(15000);
- }
- else
- {
- System.Threading.Thread.Sleep(15000);
- }
- }
-
- public void Dispose()
- {
- if (Environment.GetEnvironmentVariable("TRAVIS") != "true")
- {
- process.Kill();
- Trace.WriteLine("Shutting Down Prism");
- }
- }
-
public string apiKey = "SG.12345678901234567890123456789012";
- public string host = "http://localhost:4010";
public Process process = new Process();
}
@@ -65,6 +31,12 @@ public Integration(IntegrationFixture fixture, ITestOutputHelper output)
this.output = output;
}
+ private SendGridClient GetClient(String mockStatusCode)
+ {
+ var headers = new Dictionary { { "X-Mock", mockStatusCode } };
+ return new SendGridClient(fixture.apiKey, null, headers);
+ }
+
// Base case for sending a single email
[Fact]
public void TestSendSingleEmailWithHelper()
@@ -2722,8 +2694,7 @@ public void TestSetGoogleAnalytics()
[Fact]
public async Task TestAccessSettingsActivityGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var queryParams = @"{
'limit': 1
}";
@@ -2734,8 +2705,7 @@ public async Task TestAccessSettingsActivityGet()
[Fact]
public async Task TestAccessSettingsWhitelistPost()
{
- var headers = new Dictionary { { "X-Mock", "201" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("201");
var data = @"{
'ips': [
{
@@ -2758,8 +2728,7 @@ public async Task TestAccessSettingsWhitelistPost()
[Fact]
public async Task TestAccessSettingsWhitelistGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var response = await sg.RequestAsync(method: SendGridClient.Method.GET, urlPath: "access_settings/whitelist");
Assert.True(HttpStatusCode.OK == response.StatusCode);
}
@@ -2767,8 +2736,7 @@ public async Task TestAccessSettingsWhitelistGet()
[Fact]
public async Task TestAccessSettingsWhitelistDelete()
{
- var headers = new Dictionary { { "X-Mock", "204" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("204");
var data = @"{
'ids': [
1,
@@ -2785,9 +2753,7 @@ public async Task TestAccessSettingsWhitelistDelete()
[Fact]
public async Task TestAccessSettingsWhitelistRuleIdGet()
{
-
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var rule_id = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.GET, urlPath: "access_settings/whitelist/" + rule_id);
Assert.True(HttpStatusCode.OK == response.StatusCode);
@@ -2796,8 +2762,7 @@ public async Task TestAccessSettingsWhitelistRuleIdGet()
[Fact]
public async Task TestAccessSettingsWhitelistRuleIdDelete()
{
- var headers = new Dictionary { { "X-Mock", "204" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("204");
var rule_id = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.DELETE, urlPath: "access_settings/whitelist/" + rule_id);
Assert.True(HttpStatusCode.NoContent == response.StatusCode);
@@ -2806,8 +2771,7 @@ public async Task TestAccessSettingsWhitelistRuleIdDelete()
[Fact]
public async Task TestAlertsPost()
{
- var headers = new Dictionary { { "X-Mock", "201" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("201");
var data = @"{
'email_to': 'example@example.com',
'frequency': 'daily',
@@ -2822,8 +2786,7 @@ public async Task TestAlertsPost()
[Fact]
public async Task TestAlertsGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var response = await sg.RequestAsync(method: SendGridClient.Method.GET, urlPath: "alerts");
Assert.True(HttpStatusCode.OK == response.StatusCode);
}
@@ -2831,8 +2794,7 @@ public async Task TestAlertsGet()
[Fact]
public async Task TestAlertsAlertIdPatch()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var data = @"{
'email_to': 'example@example.com'
}";
@@ -2846,8 +2808,7 @@ public async Task TestAlertsAlertIdPatch()
[Fact]
public async Task TestAlertsAlertIdGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var alert_id = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.GET, urlPath: "alerts/" + alert_id);
Assert.True(HttpStatusCode.OK == response.StatusCode);
@@ -2856,8 +2817,7 @@ public async Task TestAlertsAlertIdGet()
[Fact]
public async Task TestAlertsAlertIdDelete()
{
- var headers = new Dictionary { { "X-Mock", "204" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("204");
var alert_id = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.DELETE, urlPath: "alerts/" + alert_id);
Assert.True(HttpStatusCode.NoContent == response.StatusCode);
@@ -2866,8 +2826,7 @@ public async Task TestAlertsAlertIdDelete()
[Fact]
public async Task TestApiKeysPost()
{
- var headers = new Dictionary { { "X-Mock", "201" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("201");
var data = @"{
'name': 'My API Key',
'sample': 'data',
@@ -2886,8 +2845,7 @@ public async Task TestApiKeysPost()
[Fact]
public async Task TestApiKeysGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var queryParams = @"{
'limit': 1
}";
@@ -2898,8 +2856,7 @@ public async Task TestApiKeysGet()
[Fact]
public async Task TestApiKeysApiKeyIdPut()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var data = @"{
'name': 'A New Hope',
'scopes': [
@@ -2917,8 +2874,7 @@ public async Task TestApiKeysApiKeyIdPut()
[Fact]
public async Task TestApiKeysApiKeyIdPatch()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var data = @"{
'name': 'A New Hope'
}";
@@ -2932,8 +2888,7 @@ public async Task TestApiKeysApiKeyIdPatch()
[Fact]
public async Task TestApiKeysApiKeyIdGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var api_key_id = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.GET, urlPath: "api_keys/" + api_key_id);
Assert.True(HttpStatusCode.OK == response.StatusCode);
@@ -2942,8 +2897,7 @@ public async Task TestApiKeysApiKeyIdGet()
[Fact]
public async Task TestApiKeysApiKeyIdDelete()
{
- var headers = new Dictionary { { "X-Mock", "204" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("204");
var api_key_id = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.DELETE, urlPath: "api_keys/" + api_key_id);
Assert.True(HttpStatusCode.NoContent == response.StatusCode);
@@ -2952,8 +2906,7 @@ public async Task TestApiKeysApiKeyIdDelete()
[Fact]
public async Task TestAsmGroupsPost()
{
- var headers = new Dictionary { { "X-Mock", "201" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("201");
var data = @"{
'description': 'Suggestions for products our users might like.',
'is_default': true,
@@ -2968,8 +2921,7 @@ public async Task TestAsmGroupsPost()
[Fact]
public async Task TestAsmGroupsGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var queryParams = @"{
'id': 1
}";
@@ -2980,8 +2932,7 @@ public async Task TestAsmGroupsGet()
[Fact]
public async Task TestAsmGroupsGroupIdPatch()
{
- var headers = new Dictionary { { "X-Mock", "201" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("201");
var data = @"{
'description': 'Suggestions for items our users might like.',
'id': 103,
@@ -2997,8 +2948,7 @@ public async Task TestAsmGroupsGroupIdPatch()
[Fact]
public async Task TestAsmGroupsGroupIdGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var group_id = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.GET, urlPath: "asm/groups/" + group_id);
Assert.True(HttpStatusCode.OK == response.StatusCode);
@@ -3007,8 +2957,7 @@ public async Task TestAsmGroupsGroupIdGet()
[Fact]
public async Task TestAsmGroupsGroupIdDelete()
{
- var headers = new Dictionary { { "X-Mock", "204" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("204");
var group_id = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.DELETE, urlPath: "asm/groups/" + group_id);
Assert.True(HttpStatusCode.NoContent == response.StatusCode);
@@ -3017,8 +2966,7 @@ public async Task TestAsmGroupsGroupIdDelete()
[Fact]
public async Task TestAsmGroupsGroupIdSuppressionsPost()
{
- var headers = new Dictionary { { "X-Mock", "201" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("201");
var data = @"{
'recipient_emails': [
'test1@example.com',
@@ -3035,8 +2983,7 @@ public async Task TestAsmGroupsGroupIdSuppressionsPost()
[Fact]
public async Task TestAsmGroupsGroupIdSuppressionsGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var group_id = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.GET, urlPath: "asm/groups/" + group_id + "/suppressions");
Assert.True(HttpStatusCode.OK == response.StatusCode);
@@ -3045,8 +2992,7 @@ public async Task TestAsmGroupsGroupIdSuppressionsGet()
[Fact]
public async Task TestAsmGroupsGroupIdSuppressionsSearchPost()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var data = @"{
'recipient_emails': [
'exists1@example.com',
@@ -3064,8 +3010,7 @@ public async Task TestAsmGroupsGroupIdSuppressionsSearchPost()
[Fact]
public async Task TestAsmGroupsGroupIdSuppressionsEmailDelete()
{
- var headers = new Dictionary { { "X-Mock", "204" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("204");
var group_id = "test_url_param";
var email = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.DELETE, urlPath: "asm/groups/" + group_id + "/suppressions/" + email);
@@ -3075,8 +3020,7 @@ public async Task TestAsmGroupsGroupIdSuppressionsEmailDelete()
[Fact]
public async Task TestAsmSuppressionsGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var response = await sg.RequestAsync(method: SendGridClient.Method.GET, urlPath: "asm/suppressions");
Assert.True(HttpStatusCode.OK == response.StatusCode);
}
@@ -3084,8 +3028,7 @@ public async Task TestAsmSuppressionsGet()
[Fact]
public async Task TestAsmSuppressionsGlobalPost()
{
- var headers = new Dictionary { { "X-Mock", "201" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("201");
var data = @"{
'recipient_emails': [
'test1@example.com',
@@ -3101,8 +3044,7 @@ public async Task TestAsmSuppressionsGlobalPost()
[Fact]
public async Task TestAsmSuppressionsGlobalEmailGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var email = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.GET, urlPath: "asm/suppressions/global/" + email);
Assert.True(HttpStatusCode.OK == response.StatusCode);
@@ -3111,8 +3053,7 @@ public async Task TestAsmSuppressionsGlobalEmailGet()
[Fact]
public async Task TestAsmSuppressionsGlobalEmailDelete()
{
- var headers = new Dictionary { { "X-Mock", "204" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("204");
var email = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.DELETE, urlPath: "asm/suppressions/global/" + email);
Assert.True(HttpStatusCode.NoContent == response.StatusCode);
@@ -3121,8 +3062,7 @@ public async Task TestAsmSuppressionsGlobalEmailDelete()
[Fact]
public async Task TestAsmSuppressionsEmailGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var email = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.GET, urlPath: "asm/suppressions/" + email);
Assert.True(HttpStatusCode.OK == response.StatusCode);
@@ -3131,8 +3071,7 @@ public async Task TestAsmSuppressionsEmailGet()
[Fact]
public async Task TestBrowsersStatsGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var queryParams = @"{
'aggregated_by': 'day',
'browsers': 'test_string',
@@ -3148,8 +3087,7 @@ public async Task TestBrowsersStatsGet()
[Fact]
public async Task TestCampaignsPost()
{
- var headers = new Dictionary { { "X-Mock", "201" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("201");
var data = @"{
'categories': [
'spring line'
@@ -3179,8 +3117,7 @@ public async Task TestCampaignsPost()
[Fact]
public async Task TestCampaignsGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var queryParams = @"{
'limit': 1,
'offset': 1
@@ -3192,8 +3129,7 @@ public async Task TestCampaignsGet()
[Fact]
public async Task TestCampaignsCampaignIdPatch()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var data = @"{
'categories': [
'summer line'
@@ -3213,8 +3149,7 @@ public async Task TestCampaignsCampaignIdPatch()
[Fact]
public async Task TestCampaignsCampaignIdGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var campaign_id = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.GET, urlPath: "campaigns/" + campaign_id);
Assert.True(HttpStatusCode.OK == response.StatusCode);
@@ -3223,8 +3158,7 @@ public async Task TestCampaignsCampaignIdGet()
[Fact]
public async Task TestCampaignsCampaignIdDelete()
{
- var headers = new Dictionary { { "X-Mock", "204" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("204");
var campaign_id = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.DELETE, urlPath: "campaigns/" + campaign_id);
Assert.True(HttpStatusCode.NoContent == response.StatusCode);
@@ -3233,8 +3167,7 @@ public async Task TestCampaignsCampaignIdDelete()
[Fact]
public async Task TestCampaignsCampaignIdSchedulesPatch()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var data = @"{
'send_at': 1489451436
}";
@@ -3248,8 +3181,7 @@ public async Task TestCampaignsCampaignIdSchedulesPatch()
[Fact]
public async Task TestCampaignsCampaignIdSchedulesPost()
{
- var headers = new Dictionary { { "X-Mock", "201" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("201");
var data = @"{
'send_at': 1489771528
}";
@@ -3263,8 +3195,7 @@ public async Task TestCampaignsCampaignIdSchedulesPost()
[Fact]
public async Task TestCampaignsCampaignIdSchedulesGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var campaign_id = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.GET, urlPath: "campaigns/" + campaign_id + "/schedules");
Assert.True(HttpStatusCode.OK == response.StatusCode);
@@ -3273,8 +3204,7 @@ public async Task TestCampaignsCampaignIdSchedulesGet()
[Fact]
public async Task TestCampaignsCampaignIdSchedulesDelete()
{
- var headers = new Dictionary { { "X-Mock", "204" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("204");
var campaign_id = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.DELETE, urlPath: "campaigns/" + campaign_id + "/schedules");
Assert.True(HttpStatusCode.NoContent == response.StatusCode);
@@ -3283,8 +3213,7 @@ public async Task TestCampaignsCampaignIdSchedulesDelete()
[Fact]
public async Task TestCampaignsCampaignIdSchedulesNowPost()
{
- var headers = new Dictionary { { "X-Mock", "201" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("201");
var campaign_id = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.POST, urlPath: "campaigns/" + campaign_id + "/schedules/now");
Assert.True(HttpStatusCode.Created == response.StatusCode);
@@ -3293,8 +3222,7 @@ public async Task TestCampaignsCampaignIdSchedulesNowPost()
[Fact]
public async Task TestCampaignsCampaignIdSchedulesTestPost()
{
- var headers = new Dictionary { { "X-Mock", "204" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("204");
var data = @"{
'to': 'your.email@example.com'
}";
@@ -3308,8 +3236,7 @@ public async Task TestCampaignsCampaignIdSchedulesTestPost()
[Fact]
public async Task TestCategoriesGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var queryParams = @"{
'category': 'test_string',
'limit': 1,
@@ -3322,8 +3249,7 @@ public async Task TestCategoriesGet()
[Fact]
public async Task TestCategoriesStatsGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var queryParams = @"{
'aggregated_by': 'day',
'categories': 'test_string',
@@ -3339,8 +3265,7 @@ public async Task TestCategoriesStatsGet()
[Fact]
public async Task TestCategoriesStatsSumsGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var queryParams = @"{
'aggregated_by': 'day',
'end_date': '2016-04-01',
@@ -3357,8 +3282,7 @@ public async Task TestCategoriesStatsSumsGet()
[Fact]
public async Task TestClientsStatsGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var queryParams = @"{
'aggregated_by': 'day',
'end_date': '2016-04-01',
@@ -3371,8 +3295,7 @@ public async Task TestClientsStatsGet()
[Fact]
public async Task TestClientsClientTypeStatsGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var queryParams = @"{
'aggregated_by': 'day',
'end_date': '2016-04-01',
@@ -3386,8 +3309,7 @@ public async Task TestClientsClientTypeStatsGet()
[Fact]
public async Task TestContactdbCustomFieldsPost()
{
- var headers = new Dictionary { { "X-Mock", "201" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("201");
var data = @"{
'name': 'pet',
'type': 'text'
@@ -3401,8 +3323,7 @@ public async Task TestContactdbCustomFieldsPost()
[Fact]
public async Task TestContactdbCustomFieldsGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var response = await sg.RequestAsync(method: SendGridClient.Method.GET, urlPath: "contactdb/custom_fields");
Assert.True(HttpStatusCode.OK == response.StatusCode);
}
@@ -3410,8 +3331,7 @@ public async Task TestContactdbCustomFieldsGet()
[Fact]
public async Task TestContactdbCustomFieldsCustomFieldIdGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var custom_field_id = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.GET, urlPath: "contactdb/custom_fields/" + custom_field_id);
Assert.True(HttpStatusCode.OK == response.StatusCode);
@@ -3420,8 +3340,7 @@ public async Task TestContactdbCustomFieldsCustomFieldIdGet()
[Fact]
public async Task TestContactdbCustomFieldsCustomFieldIdDelete()
{
- var headers = new Dictionary { { "X-Mock", "202" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("202");
var custom_field_id = "test_url_param";
var response = await sg.RequestAsync(method: SendGridClient.Method.DELETE, urlPath: "contactdb/custom_fields/" + custom_field_id);
Assert.True(HttpStatusCode.Accepted == response.StatusCode);
@@ -3431,8 +3350,7 @@ public async Task TestContactdbCustomFieldsCustomFieldIdDelete()
public async Task TestContactdbListsPost()
{
- var headers = new Dictionary { { "X-Mock", "201" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("201");
var data = @"{
'name': 'your list name'
}";
@@ -3445,8 +3363,7 @@ public async Task TestContactdbListsPost()
[Fact]
public async Task TestContactdbListsGet()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("200");
var response = await sg.RequestAsync(method: SendGridClient.Method.GET, urlPath: "contactdb/lists");
Assert.True(HttpStatusCode.OK == response.StatusCode);
}
@@ -3454,8 +3371,7 @@ public async Task TestContactdbListsGet()
[Fact]
public async Task TestContactdbListsDelete()
{
- var headers = new Dictionary { { "X-Mock", "204" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers);
+ var sg = GetClient("204");
var data = @"[
1,
2,
@@ -3471,8 +3387,8 @@ public async Task TestContactdbListsDelete()
[Fact]
public async Task TestContactdbListsListIdPatch()
{
- var headers = new Dictionary { { "X-Mock", "200" } };
- var sg = new SendGridClient(fixture.apiKey, fixture.host, headers); var data = @"{
+ var sg = GetClient("200");
+ var data = @"{
'name': 'newlistname'
}";
var json = JsonConvert.DeserializeObject