rewrite the setup of responses to use a standard helper function (#2177)

This commit is contained in:
Brendan Forster
2020-04-14 11:30:15 -03:00
committed by GitHub
parent 69d118230d
commit 287861e4a7
41 changed files with 390 additions and 448 deletions
@@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Net;
using Octokit.Internal;
using System.Net;
using Xunit;
using static Octokit.Internal.TestSetup;
namespace Octokit.Tests.Exceptions
{
public class ForbiddenExceptionTests
@@ -12,13 +12,9 @@ namespace Octokit.Tests.Exceptions
[Fact]
public void IdentifiesMaxLoginAttemptsExceededReason()
{
const string responseBody = "{\"message\":\"YOU SHALL NOT PASS!\"," +
"\"documentation_url\":\"http://developer.github.com/v3\"}";
var response = new Response(
HttpStatusCode.Forbidden,
responseBody,
new Dictionary<string, string>(),
"application/json");
var responseBody = "{\"message\":\"YOU SHALL NOT PASS!\", \"documentation_url\":\"http://developer.github.com/v3\"}";
var response = CreateResponse(HttpStatusCode.Forbidden, responseBody);
var forbiddenException = new ForbiddenException(response);
Assert.Equal("YOU SHALL NOT PASS!", forbiddenException.ApiError.Message);
@@ -27,7 +23,8 @@ namespace Octokit.Tests.Exceptions
[Fact]
public void HasDefaultMessage()
{
var response = new Response(HttpStatusCode.Forbidden, null, new Dictionary<string, string>(), "application/json");
var response = CreateResponse(HttpStatusCode.Forbidden);
var forbiddenException = new ForbiddenException(response);
Assert.Equal("Request Forbidden", forbiddenException.Message);