mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-09 13:01:36 +00:00
aaaand format the code
This commit is contained in:
@@ -103,10 +103,10 @@ namespace Octokit.Tests.Http
|
||||
public async Task EnsuresArgumentNotNull()
|
||||
{
|
||||
var client = new ApiConnection(Substitute.For<IConnection>());
|
||||
|
||||
|
||||
// One argument
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll<object>(null));
|
||||
|
||||
|
||||
// Two argument
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(async () =>
|
||||
await client.GetAll<object>(null, new Dictionary<string, string>()));
|
||||
@@ -351,7 +351,7 @@ namespace Octokit.Tests.Http
|
||||
{
|
||||
var queuedOperationUrl = new Uri("anything", UriKind.Relative);
|
||||
|
||||
var result = new [] { new object() };
|
||||
var result = new[] { new object() };
|
||||
const HttpStatusCode statusCode = HttpStatusCode.NoContent;
|
||||
var httpResponse = new Response(statusCode, null, new Dictionary<string, string>(), "application/json");
|
||||
IApiResponse<IReadOnlyList<object>> response = new ApiResponse<IReadOnlyList<object>>(
|
||||
@@ -370,7 +370,7 @@ namespace Octokit.Tests.Http
|
||||
{
|
||||
var queuedOperationUrl = new Uri("anything", UriKind.Relative);
|
||||
|
||||
var result = new [] { new object() };
|
||||
var result = new[] { new object() };
|
||||
IApiResponse<IReadOnlyList<object>> firstResponse = new ApiResponse<IReadOnlyList<object>>(
|
||||
new Response(HttpStatusCode.Accepted, null, new Dictionary<string, string>(), "application/json"), result);
|
||||
IApiResponse<IReadOnlyList<object>> completedResponse = new ApiResponse<IReadOnlyList<object>>(
|
||||
@@ -378,7 +378,7 @@ namespace Octokit.Tests.Http
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetResponse<IReadOnlyList<object>>(queuedOperationUrl, Args.CancellationToken)
|
||||
.Returns(x => Task.FromResult(firstResponse),
|
||||
x => Task.FromResult(firstResponse),
|
||||
x => Task.FromResult(firstResponse),
|
||||
x => Task.FromResult(completedResponse));
|
||||
|
||||
var apiConnection = new ApiConnection(connection);
|
||||
@@ -392,7 +392,7 @@ namespace Octokit.Tests.Http
|
||||
{
|
||||
var queuedOperationUrl = new Uri("anything", UriKind.Relative);
|
||||
|
||||
var result = new [] { new object() };
|
||||
var result = new[] { new object() };
|
||||
IApiResponse<IReadOnlyList<object>> accepted = new ApiResponse<IReadOnlyList<object>>(
|
||||
new Response(HttpStatusCode.Accepted, null, new Dictionary<string, string>(), "application/json"), result);
|
||||
var connection = Substitute.For<IConnection>();
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Octokit.Tests.Http
|
||||
},
|
||||
new List<string>
|
||||
{
|
||||
"user",
|
||||
"user",
|
||||
"public_repo",
|
||||
"repo",
|
||||
"gist"
|
||||
@@ -95,6 +95,5 @@ namespace Octokit.Tests.Http
|
||||
Assert.NotSame(original.RateLimit.Reset, clone.RateLimit.Reset);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Octokit.Tests.Http
|
||||
{ "X-Accepted-OAuth-Scopes", "user" },
|
||||
};
|
||||
IResponse response = new Response(headers);
|
||||
|
||||
|
||||
httpClient.Send(Args.Request, Args.CancellationToken).Returns(Task.FromResult(response));
|
||||
var connection = new Connection(new ProductHeaderValue("OctokitTests"),
|
||||
_exampleUri,
|
||||
@@ -93,7 +93,7 @@ namespace Octokit.Tests.Http
|
||||
var httpClient = Substitute.For<IHttpClient>();
|
||||
IResponse response = new Response(HttpStatusCode.Unauthorized, null, new Dictionary<string, string>(), "application/json");
|
||||
httpClient.Send(Args.Request, Args.CancellationToken).Returns(Task.FromResult(response));
|
||||
var connection = new Connection(new ProductHeaderValue("OctokitTests"),
|
||||
var connection = new Connection(new ProductHeaderValue("OctokitTests"),
|
||||
_exampleUri,
|
||||
Substitute.For<ICredentialStore>(),
|
||||
httpClient,
|
||||
@@ -155,7 +155,7 @@ namespace Octokit.Tests.Http
|
||||
|
||||
Assert.Equal(expectedFactorType, exception.TwoFactorType);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task ThrowsApiValidationExceptionFor422Response()
|
||||
{
|
||||
@@ -564,9 +564,9 @@ namespace Octokit.Tests.Http
|
||||
{
|
||||
// 1 arg
|
||||
Assert.Throws<ArgumentNullException>(() => new Connection(null));
|
||||
|
||||
|
||||
// 2 args
|
||||
Assert.Throws<ArgumentNullException>(() => new Connection(null, new Uri("https://example.com")));
|
||||
Assert.Throws<ArgumentNullException>(() => new Connection(null, new Uri("https://example.com")));
|
||||
Assert.Throws<ArgumentNullException>(() => new Connection(new ProductHeaderValue("test"), (Uri)null));
|
||||
|
||||
// 3 args
|
||||
@@ -634,7 +634,7 @@ namespace Octokit.Tests.Http
|
||||
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task ReturnsObjectIfNotNew()
|
||||
{
|
||||
@@ -664,7 +664,7 @@ namespace Octokit.Tests.Http
|
||||
},
|
||||
new List<string>
|
||||
{
|
||||
"user",
|
||||
"user",
|
||||
"public_repo",
|
||||
"repo",
|
||||
"gist"
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Octokit.Tests.Http
|
||||
}
|
||||
};
|
||||
var tester = new HttpClientAdapterTester();
|
||||
|
||||
|
||||
var requestMessage = tester.BuildRequestMessageTester(request);
|
||||
|
||||
Assert.Equal(2, requestMessage.Headers.Count());
|
||||
@@ -93,7 +93,7 @@ namespace Octokit.Tests.Http
|
||||
BaseAddress = GitHubClient.GitHubApiUrl,
|
||||
Endpoint = _endpoint,
|
||||
Method = HttpMethod.Post,
|
||||
Body = new FormUrlEncodedContent(new Dictionary<string, string> {{"foo", "bar"}})
|
||||
Body = new FormUrlEncodedContent(new Dictionary<string, string> { { "foo", "bar" } })
|
||||
};
|
||||
var tester = new HttpClientAdapterTester();
|
||||
|
||||
@@ -119,7 +119,8 @@ namespace Octokit.Tests.Http
|
||||
[InlineData(HttpStatusCode.NotFound)]
|
||||
public async Task BuildsResponseFromResponseMessage(HttpStatusCode httpStatusCode)
|
||||
{
|
||||
var responseMessage = new HttpResponseMessage {
|
||||
var responseMessage = new HttpResponseMessage
|
||||
{
|
||||
StatusCode = httpStatusCode,
|
||||
Content = new ByteArrayContent(Encoding.UTF8.GetBytes("{}")),
|
||||
Headers =
|
||||
@@ -131,7 +132,7 @@ namespace Octokit.Tests.Http
|
||||
var tester = new HttpClientAdapterTester();
|
||||
|
||||
var response = await tester.BuildResponseTester(responseMessage);
|
||||
|
||||
|
||||
var firstHeader = response.Headers.First();
|
||||
Assert.Equal("peanut", firstHeader.Key);
|
||||
Assert.Equal("butter", firstHeader.Value);
|
||||
@@ -149,7 +150,7 @@ namespace Octokit.Tests.Http
|
||||
var responseMessage = new HttpResponseMessage
|
||||
{
|
||||
StatusCode = HttpStatusCode.OK,
|
||||
Content = new ByteArrayContent(new byte[] { 0, 1, 1, 0, 1}),
|
||||
Content = new ByteArrayContent(new byte[] { 0, 1, 1, 0, 1 }),
|
||||
};
|
||||
responseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png");
|
||||
var tester = new HttpClientAdapterTester();
|
||||
|
||||
@@ -142,9 +142,9 @@ namespace Octokit.Tests.Http
|
||||
const string data = "{\"name\":\"Haack\"}";
|
||||
var jsonPipeline = new JsonHttpPipeline();
|
||||
var httpResponse = new Response(
|
||||
HttpStatusCode.OK,
|
||||
HttpStatusCode.OK,
|
||||
data,
|
||||
new Dictionary<string, string>(),
|
||||
new Dictionary<string, string>(),
|
||||
"application/json");
|
||||
|
||||
var response = jsonPipeline.DeserializeResponse<List<SomeObject>>(httpResponse);
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Octokit.Tests.Http
|
||||
[Fact]
|
||||
public void ParsesRateLimitsFromHeaders()
|
||||
{
|
||||
var headers = new Dictionary<string, string>
|
||||
var headers = new Dictionary<string, string>
|
||||
{
|
||||
{ "X-RateLimit-Limit", "100" },
|
||||
{ "X-RateLimit-Remaining", "42" },
|
||||
@@ -40,7 +40,7 @@ namespace Octokit.Tests.Http
|
||||
[Fact]
|
||||
public void HandlesInvalidHeaderValues()
|
||||
{
|
||||
var headers = new Dictionary<string, string>
|
||||
var headers = new Dictionary<string, string>
|
||||
{
|
||||
{ "X-RateLimit-Limit", "1234scoobysnacks1234" },
|
||||
{ "X-RateLimit-Remaining", "xanadu" },
|
||||
@@ -78,7 +78,7 @@ namespace Octokit.Tests.Http
|
||||
[Fact]
|
||||
public void CanPopulateObjectFromSerializedData()
|
||||
{
|
||||
var headers = new Dictionary<string, string>
|
||||
var headers = new Dictionary<string, string>
|
||||
{
|
||||
{ "X-RateLimit-Limit", "100" },
|
||||
{ "X-RateLimit-Remaining", "42" },
|
||||
@@ -92,7 +92,7 @@ namespace Octokit.Tests.Http
|
||||
var formatter = new BinaryFormatter();
|
||||
formatter.Serialize(stream, rateLimit);
|
||||
stream.Position = 0;
|
||||
var deserialized = (RateLimit) formatter.Deserialize(stream);
|
||||
var deserialized = (RateLimit)formatter.Deserialize(stream);
|
||||
|
||||
Assert.Equal(100, deserialized.Limit);
|
||||
Assert.Equal(42, deserialized.Remaining);
|
||||
@@ -109,7 +109,6 @@ namespace Octokit.Tests.Http
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new RateLimit(null));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TheMethods
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Octokit.Tests.Http
|
||||
[InlineData(HttpStatusCode.MovedPermanently)] // 301
|
||||
[InlineData(HttpStatusCode.Found)] // 302
|
||||
[InlineData(HttpStatusCode.TemporaryRedirect)] // 307
|
||||
public async Task Status301ShouldRedirectPOSTWithBody(HttpStatusCode statusCode)
|
||||
public async Task Status301ShouldRedirectPOSTWithBody(HttpStatusCode statusCode)
|
||||
{
|
||||
var redirectResponse = new HttpResponseMessage(statusCode);
|
||||
redirectResponse.Headers.Location = new Uri("http://example.org/bar");
|
||||
|
||||
Reference in New Issue
Block a user