mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-07 04:16:51 +00:00
aaaand format the code
This commit is contained in:
@@ -36,7 +36,7 @@ namespace Octokit.Tests
|
||||
{
|
||||
var authenticator = new TokenAuthenticator();
|
||||
Assert.Throws<ArgumentNullException>(() => authenticator.Authenticate(null, Credentials.Anonymous));
|
||||
Assert.Throws<ArgumentNullException>(() =>
|
||||
Assert.Throws<ArgumentNullException>(() =>
|
||||
authenticator.Authenticate(Substitute.For<IRequest>(), null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Octokit.Tests.Clients
|
||||
client.Put<ApplicationAuthorization>(Args.Uri, Args.Object, Args.String)
|
||||
.ThrowsAsync<ApplicationAuthorization>(
|
||||
new AuthorizationException(
|
||||
new Response(HttpStatusCode.Unauthorized , null, new Dictionary<string, string>(), "application/json")));
|
||||
new Response(HttpStatusCode.Unauthorized, null, new Dictionary<string, string>(), "application/json")));
|
||||
var authEndpoint = new AuthorizationsClient(client);
|
||||
|
||||
await Assert.ThrowsAsync<TwoFactorChallengeFailedException>(() =>
|
||||
@@ -137,7 +137,7 @@ namespace Octokit.Tests.Clients
|
||||
var data = new NewAuthorization { Note = "note" };
|
||||
var client = Substitute.For<IAuthorizationsClient>();
|
||||
client.GetOrCreateApplicationAuthentication("clientId", "secret", Arg.Any<NewAuthorization>())
|
||||
.Returns(_ => {throw new TwoFactorRequiredException();});
|
||||
.Returns(_ => { throw new TwoFactorRequiredException(); });
|
||||
client.GetOrCreateApplicationAuthentication("clientId",
|
||||
"secret",
|
||||
Arg.Any<NewAuthorization>(),
|
||||
@@ -161,7 +161,7 @@ namespace Octokit.Tests.Clients
|
||||
[Fact]
|
||||
public async Task RetriesWhenResendRequested()
|
||||
{
|
||||
var challengeResults = new Queue<TwoFactorChallengeResult>(new []
|
||||
var challengeResults = new Queue<TwoFactorChallengeResult>(new[]
|
||||
{
|
||||
TwoFactorChallengeResult.RequestResendCode,
|
||||
new TwoFactorChallengeResult("two-factor-code")
|
||||
@@ -197,7 +197,7 @@ namespace Octokit.Tests.Clients
|
||||
var challengeResults = new Queue<TwoFactorChallengeResult>(new[]
|
||||
{
|
||||
TwoFactorChallengeResult.RequestResendCode,
|
||||
new TwoFactorChallengeResult("wrong-code")
|
||||
new TwoFactorChallengeResult("wrong-code")
|
||||
});
|
||||
var data = new NewAuthorization();
|
||||
var client = Substitute.For<IAuthorizationsClient>();
|
||||
@@ -239,7 +239,7 @@ namespace Octokit.Tests.Clients
|
||||
client.Put<ApplicationAuthorization>(Arg.Do<Uri>(u => calledUri = u), Arg.Do<object>(body => calledBody = body));
|
||||
|
||||
authEndpoint.GetOrCreateApplicationAuthentication("clientId", "secret", data);
|
||||
|
||||
|
||||
Assert.NotNull(calledUri);
|
||||
Assert.Equal(calledUri.ToString(), "authorizations/clients/clientId");
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace Octokit.Tests.Clients
|
||||
client.Received().Get<ApplicationAuthorization>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "applications/clientId/tokens/accessToken"),
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresArgumentsNotNull()
|
||||
|
||||
@@ -85,9 +85,9 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new CommitStatusClient(connection);
|
||||
|
||||
client.Create("owner", "repo", "sha", new NewCommitStatus { State = CommitState.Success });
|
||||
client.Create("owner", "repo", "sha", new NewCommitStatus { State = CommitState.Success });
|
||||
|
||||
connection.Received().Post<CommitStatus>(Arg.Is<Uri>(u =>
|
||||
connection.Received().Post<CommitStatus>(Arg.Is<Uri>(u =>
|
||||
u.ToString() == "repos/owner/repo/statuses/sha"),
|
||||
Arg.Is<NewCommitStatus>(s => s.State == CommitState.Success));
|
||||
}
|
||||
|
||||
@@ -59,12 +59,12 @@ public class CommitsClientTests
|
||||
{
|
||||
var client = new CommitsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
var newCommit = new NewCommit("message", "tree", new[]{"parent1", "parent2"});
|
||||
var newCommit = new NewCommit("message", "tree", new[] { "parent1", "parent2" });
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", newCommit));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, newCommit));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", null));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", newCommit));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", newCommit));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", newCommit));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class DeploymentStatusClientTests
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var client = new DeploymentStatusClient(Substitute.For<IApiConnection>());
|
||||
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", 1));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", 1));
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class DeploymentStatusClientTests
|
||||
public async Task EnsureNonWhitespaceArguments(string whitespace)
|
||||
{
|
||||
var client = new DeploymentStatusClient(Substitute.For<IApiConnection>());
|
||||
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create(whitespace, "repo", 1, newDeploymentStatus));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", whitespace, 1, newDeploymentStatus));
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace Octokit.Tests.Clients
|
||||
{"WatchEvent", typeof(StarredEventPayload)},
|
||||
{"unknown", typeof(ActivityPayload)}
|
||||
};
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task DeserializesPayloadToCorrectType()
|
||||
{
|
||||
@@ -252,7 +252,7 @@ namespace Octokit.Tests.Clients
|
||||
},
|
||||
sender = new
|
||||
{
|
||||
id = 1337
|
||||
id = 1337
|
||||
}
|
||||
}}};
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(status , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(status, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "user/following/alfhenrik"),
|
||||
null, null).Returns(response);
|
||||
@@ -129,7 +129,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(HttpStatusCode.Conflict , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(HttpStatusCode.Conflict, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "user/following/alfhenrik"),
|
||||
null, null).Returns(response);
|
||||
@@ -159,7 +159,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(status , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(status, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "users/alfhenrik/following/alfhenrik-test"),
|
||||
null, null).Returns(response);
|
||||
@@ -176,7 +176,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(HttpStatusCode.Conflict , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(HttpStatusCode.Conflict, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "users/alfhenrik/following/alfhenrik-test"),
|
||||
null, null).Returns(response);
|
||||
@@ -198,7 +198,6 @@ namespace Octokit.Tests.Clients
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.IsFollowing("", "alfhenrik-text"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.IsFollowing("alfhenrik", ""));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TheFollowMethod
|
||||
@@ -208,7 +207,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(status , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(status, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Put<object>(Arg.Is<Uri>(u => u.ToString() == "user/following/alfhenrik"),
|
||||
Args.Object).Returns(response);
|
||||
@@ -225,7 +224,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(HttpStatusCode.Conflict , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(HttpStatusCode.Conflict, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Put<object>(Arg.Is<Uri>(u => u.ToString() == "user/following/alfhenrik"),
|
||||
new { }).Returns(response);
|
||||
|
||||
@@ -45,8 +45,8 @@ public class GistsClientTests
|
||||
DateTimeOffset since = DateTimeOffset.Now;
|
||||
client.GetAll(since);
|
||||
|
||||
connection.Received().GetAll<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists"),
|
||||
Arg.Is<IDictionary<string,string>>(x => x.ContainsKey("since")));
|
||||
connection.Received().GetAll<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists"),
|
||||
Arg.Is<IDictionary<string, string>>(x => x.ContainsKey("since")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -54,7 +54,7 @@ public class GistsClientTests
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new GistsClient(connection);
|
||||
|
||||
|
||||
client.GetAllPublic();
|
||||
|
||||
connection.Received().GetAll<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/public"));
|
||||
@@ -65,7 +65,7 @@ public class GistsClientTests
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new GistsClient(connection);
|
||||
|
||||
|
||||
DateTimeOffset since = DateTimeOffset.Now;
|
||||
client.GetAllPublic(since);
|
||||
|
||||
@@ -173,7 +173,7 @@ public class GistsClientTests
|
||||
newGist.Public = true;
|
||||
|
||||
newGist.Files.Add("myGistTestFile.cs", "new GistsClient(connection).Create();");
|
||||
|
||||
|
||||
client.Create(newGist);
|
||||
|
||||
connection.Received().Post<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists"), Arg.Any<object>());
|
||||
@@ -233,7 +233,7 @@ public class GistsClientTests
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(status , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(status, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "gists/1/star"),
|
||||
null, null).Returns(response);
|
||||
@@ -250,7 +250,7 @@ public class GistsClientTests
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(HttpStatusCode.Conflict , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(HttpStatusCode.Conflict, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "gists/1/star"),
|
||||
null, null).Returns(response);
|
||||
@@ -273,7 +273,7 @@ public class GistsClientTests
|
||||
|
||||
client.Fork("1");
|
||||
|
||||
connection.Received().Post<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/1/forks"),
|
||||
connection.Received().Post<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/1/forks"),
|
||||
Arg.Any<object>());
|
||||
}
|
||||
}
|
||||
@@ -288,8 +288,8 @@ public class GistsClientTests
|
||||
|
||||
var updateGist = new GistUpdate();
|
||||
updateGist.Description = "my newly updated gist";
|
||||
var gistFileUpdate = new GistFileUpdate
|
||||
{
|
||||
var gistFileUpdate = new GistFileUpdate
|
||||
{
|
||||
NewFileName = "myNewGistTestFile.cs",
|
||||
Content = "new GistsClient(connection).Edit();"
|
||||
};
|
||||
|
||||
@@ -36,5 +36,5 @@ public class GitDatabaseClientTests
|
||||
var gitDatabaseClient = new GitDatabaseClient(apiConnection);
|
||||
Assert.NotNull(gitDatabaseClient.Reference);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ public class IssueCommentsClientTests
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, 1));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "", 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TheGetForRepositoryMethod
|
||||
@@ -183,7 +182,7 @@ public class IssueCommentsClientTests
|
||||
[Fact]
|
||||
public void CanDeserializeIssueComment()
|
||||
{
|
||||
const string issueResponseJson =
|
||||
const string issueResponseJson =
|
||||
"{\"id\": 1," +
|
||||
"\"url\": \"https://api.github.com/repos/octocat/Hello-World/issues/comments/1\"," +
|
||||
"\"html_url\": \"https://github.com/octocat/Hello-World/issues/1347#issuecomment-1\"," +
|
||||
|
||||
@@ -33,7 +33,6 @@ namespace Octokit.Tests.Clients
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name", 1));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TheGetAllForCurrentMethod
|
||||
|
||||
@@ -76,7 +76,6 @@ namespace Octokit.Tests.Clients
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name", 1));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, 1));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,13 +33,13 @@ namespace Octokit.Tests.Clients
|
||||
{
|
||||
var client = new MergingClient(Substitute.For<IApiConnection>());
|
||||
|
||||
var newMerge = new NewMerge("baseBranch", "shaToMerge") {CommitMessage = "some mergingMessage"};
|
||||
var newMerge = new NewMerge("baseBranch", "shaToMerge") { CommitMessage = "some mergingMessage" };
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", newMerge));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, newMerge));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", null));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", newMerge));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", newMerge));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", null));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", newMerge));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", null));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Octokit.Tests.Clients
|
||||
IApiResponse<string> response = new ApiResponse<string>(new Response(), "<strong>Test</strong>");
|
||||
var connection = Substitute.For<IConnection>();
|
||||
var forTest = new NewArbitraryMarkdown("testMarkdown", "gfm", "testContext");
|
||||
connection.Post<string>(Args.Uri,forTest, "text/html", "text/plain")
|
||||
connection.Post<string>(Args.Uri, forTest, "text/html", "text/plain")
|
||||
.Returns(Task.FromResult(response));
|
||||
var client = new MiscellaneousClient(connection);
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(status , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(status, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/members/username"),
|
||||
null, null).Returns(response);
|
||||
@@ -118,7 +118,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(HttpStatusCode.Conflict , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(HttpStatusCode.Conflict, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/members/username"),
|
||||
null, null).Returns(response);
|
||||
@@ -149,7 +149,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(status , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(status, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/public_members/username"),
|
||||
null, null).Returns(response);
|
||||
@@ -166,7 +166,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(HttpStatusCode.Conflict , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(HttpStatusCode.Conflict, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/public_members/username"),
|
||||
null, null).Returns(response);
|
||||
@@ -221,7 +221,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(status , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(status, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Put<object>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/public_members/username"),
|
||||
Args.Object).Returns(response);
|
||||
@@ -238,7 +238,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(HttpStatusCode.Conflict , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(HttpStatusCode.Conflict, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Put<object>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/public_members/username"),
|
||||
new { }).Returns(response);
|
||||
@@ -271,7 +271,7 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
client.Conceal("org", "username");
|
||||
|
||||
connection.Received().Delete(Arg.Is<Uri>(u=>u.ToString() == "orgs/org/public_members/username"));
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "orgs/org/public_members/username"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new PullRequestsClient(connection);
|
||||
|
||||
client.GetAllForRepository("fake", "repo", new PullRequestRequest { Head = "user:ref-head", Base = "fake_base_branch"});
|
||||
client.GetAllForRepository("fake", "repo", new PullRequestRequest { Head = "user:ref-head", Base = "fake_base_branch" });
|
||||
|
||||
connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d.Count == 5
|
||||
@@ -134,7 +134,7 @@ namespace Octokit.Tests.Clients
|
||||
}
|
||||
}
|
||||
|
||||
public class TheMergeMethod
|
||||
public class TheMergeMethod
|
||||
{
|
||||
[Fact]
|
||||
public void PutsToCorrectUrl()
|
||||
@@ -164,7 +164,7 @@ namespace Octokit.Tests.Clients
|
||||
}
|
||||
}
|
||||
|
||||
public class TheMergedMethod
|
||||
public class TheMergedMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
@@ -193,7 +193,7 @@ namespace Octokit.Tests.Clients
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCommitsMethod
|
||||
public class TheCommitsMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
@@ -202,7 +202,7 @@ namespace Octokit.Tests.Clients
|
||||
var client = new PullRequestsClient(connection);
|
||||
|
||||
await client.Commits("fake", "repo", 42);
|
||||
|
||||
|
||||
connection.Received()
|
||||
.GetAll<PullRequestCommit>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/42/commits"));
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Octokit.Tests.Clients
|
||||
{
|
||||
var client = new RepoCollaboratorsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null,"test"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "test"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "test"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", ""));
|
||||
@@ -56,7 +56,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(status , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(status, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators/user1"),
|
||||
null, null).Returns(response);
|
||||
@@ -73,7 +73,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(HttpStatusCode.Conflict , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(HttpStatusCode.Conflict, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "repos/foo/bar/assignees/cody"),
|
||||
null, null).Returns(response);
|
||||
@@ -115,7 +115,7 @@ namespace Octokit.Tests.Clients
|
||||
{
|
||||
var client = new RepoCollaboratorsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Add(null, "test","user1"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Add(null, "test", "user1"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Add("", "test", "user1"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Add("owner", null, "user1"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Add("owner", "", "user1"));
|
||||
|
||||
@@ -270,7 +270,7 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
connection.Received()
|
||||
.GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "/repositories"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -331,7 +331,7 @@ namespace Octokit.Tests.Clients
|
||||
connection.Received()
|
||||
.GetAll<Repository>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "user/repos"),
|
||||
Arg.Is<Dictionary<string,string>>(d => d["type"] == "all"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["type"] == "all"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -34,7 +34,6 @@ public class RepositoryCommentsClientTests
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, 1));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "", 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TheGetForRepositoryMethod
|
||||
@@ -97,7 +96,7 @@ public class RepositoryCommentsClientTests
|
||||
public void PostsToCorrectUrl()
|
||||
{
|
||||
NewCommitComment newComment = new NewCommitComment("body");
|
||||
|
||||
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new RepositoryCommentsClient(connection);
|
||||
|
||||
@@ -188,7 +187,7 @@ public class RepositoryCommentsClientTests
|
||||
[Fact]
|
||||
public void CanDeserializeCommitComment()
|
||||
{
|
||||
const string commitCommentResponseJson =
|
||||
const string commitCommentResponseJson =
|
||||
"{\"html_url\": \"https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e#commitcomment-1\"," +
|
||||
"\"url\": \"https://api.github.com/repos/octocat/Hello-World/comments/1\"," +
|
||||
"\"id\": 1," +
|
||||
@@ -218,7 +217,7 @@ public class RepositoryCommentsClientTests
|
||||
var response = jsonPipeline.DeserializeResponse<CommitComment>(httpResponse);
|
||||
|
||||
Assert.NotNull(response.Body);
|
||||
Assert.Equal(commitCommentResponseJson, response.HttpResponse.Body);
|
||||
Assert.Equal(commitCommentResponseJson, response.HttpResponse.Body);
|
||||
Assert.Equal(1, response.Body.Id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Octokit.Tests.Clients
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new RepositoriesClient(connection);
|
||||
var hook = new NewRepositoryHook("name", new Dictionary<string, string> { {"config", "" }});
|
||||
var hook = new NewRepositoryHook("name", new Dictionary<string, string> { { "config", "" } });
|
||||
|
||||
client.Hooks.Create("fake", "repo", hook);
|
||||
|
||||
|
||||
@@ -349,7 +349,7 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
client.SearchRepo(new SearchRepositoriesRequest("something"));
|
||||
connection.Received().Get<SearchRepositoryResult>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"),
|
||||
connection.Received().Get<SearchRepositoryResult>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"),
|
||||
Arg.Any<Dictionary<string, string>>());
|
||||
}
|
||||
|
||||
@@ -655,12 +655,12 @@ namespace Octokit.Tests.Clients
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchRepositoriesRequest("github");
|
||||
request.SortField = RepoSearchSort.Stars;
|
||||
|
||||
|
||||
client.SearchRepo(request);
|
||||
|
||||
|
||||
connection.Received().Get<SearchRepositoryResult>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/repositories"),
|
||||
Arg.Is<Dictionary<string, string>>(d =>
|
||||
Arg.Is<Dictionary<string, string>>(d =>
|
||||
d["q"] == "github" &&
|
||||
d["sort"] == "stars"));
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task ReturnsCorrectResultBasedOnStatus(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(status , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(status, null, new Dictionary<string, string>(), "application/json")));
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "user/starred/yes/no"), null, null)
|
||||
.Returns(response);
|
||||
@@ -87,7 +87,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task ReturnsCorrectResultBasedOnStatus(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object>(new Response(status , null, new Dictionary<string, string>(), "application/json")));
|
||||
new ApiResponse<object>(new Response(status, null, new Dictionary<string, string>(), "application/json")));
|
||||
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Put<object>(Arg.Is<Uri>(u => u.ToString() == "user/starred/yes/no"),
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Octokit.Tests.Clients
|
||||
.Returns(Task.FromResult(contributors));
|
||||
var statisticsClient = new StatisticsClient(client);
|
||||
|
||||
var result = await statisticsClient.GetContributors("username","repositoryName");
|
||||
var result = await statisticsClient.GetContributors("username", "repositoryName");
|
||||
|
||||
Assert.Equal(1, result.Count);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ namespace Octokit.Tests.Clients
|
||||
public async Task ThrowsIfGivenNullOwner()
|
||||
{
|
||||
var statisticsClient = new StatisticsClient(Substitute.For<IApiConnection>());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => statisticsClient.GetContributors(null,"repositoryName"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => statisticsClient.GetContributors(null, "repositoryName"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -105,14 +105,14 @@ namespace Octokit.Tests.Clients
|
||||
});
|
||||
var client = Substitute.For<IApiConnection>();
|
||||
client.GetQueuedOperation<long[]>(expectedEndPoint, Args.CancellationToken)
|
||||
.Returns(Task.FromResult(data));
|
||||
.Returns(Task.FromResult(data));
|
||||
var statisticsClient = new StatisticsClient(client);
|
||||
|
||||
var codeFrequency = await statisticsClient.GetCodeFrequency("username", "repositoryName");
|
||||
|
||||
Assert.Equal(2, codeFrequency.AdditionsAndDeletionsByWeek.Count);
|
||||
Assert.Equal(firstTimestamp.FromUnixTime(), codeFrequency.AdditionsAndDeletionsByWeek[0].Timestamp);
|
||||
Assert.Equal(10, codeFrequency.AdditionsAndDeletionsByWeek[0].Additions);
|
||||
Assert.Equal(10, codeFrequency.AdditionsAndDeletionsByWeek[0].Additions);
|
||||
Assert.Equal(52, codeFrequency.AdditionsAndDeletionsByWeek[0].Deletions);
|
||||
Assert.Equal(secondTimestamp.FromUnixTime(), codeFrequency.AdditionsAndDeletionsByWeek[1].Timestamp);
|
||||
Assert.Equal(0, codeFrequency.AdditionsAndDeletionsByWeek[1].Additions);
|
||||
|
||||
@@ -42,9 +42,9 @@ public class TagsClientTests
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new TagsClient(connection);
|
||||
|
||||
client.Create("owner", "repo", new NewTag{Type = TaggedType.Tree});
|
||||
client.Create("owner", "repo", new NewTag { Type = TaggedType.Tree });
|
||||
|
||||
connection.Received().Post<GitTag>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/tags"),
|
||||
connection.Received().Post<GitTag>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/tags"),
|
||||
Arg.Is<NewTag>(nt => nt.Type == TaggedType.Tree));
|
||||
}
|
||||
|
||||
@@ -98,6 +98,6 @@ public class TagsClientTests
|
||||
"}";
|
||||
|
||||
Assert.Equal(expectedResult, json);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +235,6 @@ namespace Octokit.Tests.Clients
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.RemoveMembership(1, null));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.RemoveMembership(1, ""));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TheGetAllRepositoriesMethod
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Octokit.Tests.Clients
|
||||
[Fact]
|
||||
public async Task ReturnsFalseOnNotFoundException()
|
||||
{
|
||||
var endpoint = new Uri("repos/fight/club/subscription", UriKind.Relative);
|
||||
var endpoint = new Uri("repos/fight/club/subscription", UriKind.Relative);
|
||||
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var response = new Response(HttpStatusCode.NotFound, null, new Dictionary<string, string>(), "application/json");
|
||||
|
||||
@@ -26,9 +26,9 @@ namespace Octokit.Tests.Exceptions
|
||||
public void SetsSpecifiedExceptionMessageAndInnerException()
|
||||
{
|
||||
var inner = new InvalidOperationException();
|
||||
|
||||
|
||||
var exception = new ApiException("Shit broke", inner);
|
||||
|
||||
|
||||
Assert.Equal("Shit broke", exception.Message);
|
||||
Assert.Same(inner, exception.InnerException);
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace Octokit.Tests.Exceptions
|
||||
var response = new Response(
|
||||
(HttpStatusCode)422,
|
||||
@"{""errors"":[{""code"":""custom"",""field"":""key"",""message"":""key is " +
|
||||
@"already in use"",""resource"":""PublicKey""}],""message"":""Validation Failed""}",
|
||||
new Dictionary<string, string>(),
|
||||
@"already in use"",""resource"":""PublicKey""}],""message"":""Validation Failed""}",
|
||||
new Dictionary<string, string>(),
|
||||
"application/json"
|
||||
);
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Octokit.Tests.Exceptions
|
||||
@"already in use"",""resource"":""PublicKey""}],""message"":""Validation Failed""}",
|
||||
new Dictionary<string, string>(),
|
||||
"application/json");
|
||||
|
||||
|
||||
var exception = new ApiValidationException(response);
|
||||
|
||||
using (var stream = new MemoryStream())
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Octokit.Tests.Exceptions
|
||||
[Fact]
|
||||
public void HasDefaultMessage()
|
||||
{
|
||||
var response = new Response(HttpStatusCode.Forbidden , null, new Dictionary<string, string>(), "application/json");
|
||||
var response = new Response(HttpStatusCode.Forbidden, null, new Dictionary<string, string>(), "application/json");
|
||||
var forbiddenException = new ForbiddenException(response);
|
||||
|
||||
Assert.Equal("Request Forbidden", forbiddenException.Message);
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Octokit.Tests.Exceptions
|
||||
{"X-RateLimit-Reset", "XXXX"}
|
||||
};
|
||||
var response = new Response(HttpStatusCode.Forbidden, null, headers, "application/json");
|
||||
|
||||
|
||||
var exception = new RateLimitExceededException(response);
|
||||
|
||||
Assert.Equal(HttpStatusCode.Forbidden, exception.StatusCode);
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Octokit.Tests.Exceptions
|
||||
public void WhenOrganizationIsNullShouldThrowArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new RepositoryExistsException(
|
||||
null,
|
||||
null,
|
||||
"some-repo",
|
||||
GitHubClient.GitHubDotComUrl,
|
||||
new ApiValidationException()));
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace Octokit.Tests
|
||||
},
|
||||
new List<string>
|
||||
{
|
||||
"user",
|
||||
"user",
|
||||
"public_repo",
|
||||
"repo",
|
||||
"gist"
|
||||
@@ -170,6 +170,5 @@ namespace Octokit.Tests
|
||||
var temp = connection.Received(1).GetLastApiInfo();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Octokit.Tests
|
||||
{
|
||||
get { return Arg.Any<OrganizationUpdate>(); }
|
||||
}
|
||||
|
||||
|
||||
public static CancellationToken CancellationToken
|
||||
{
|
||||
get { return Arg.Any<CancellationToken>(); }
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Octokit.Tests.Helpers
|
||||
[InlineData("https://host.com/path?name=example name.txt&label=labeltext", "https://host.com/path{?name,label,other}")]
|
||||
public void ExpandsUriTemplates(string expected, string template)
|
||||
{
|
||||
Assert.Equal(expected, template.ExpandUriTemplate(new { name = "example name.txt",label="labeltext" }).ToString());
|
||||
Assert.Equal(expected, template.ExpandUriTemplate(new { name = "example name.txt", label = "labeltext" }).ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class UnixTimestampExtensionsTests
|
||||
public void ReturnsDateFromUnixEpochCorrectly()
|
||||
{
|
||||
var epoch = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero);
|
||||
|
||||
|
||||
var result = ((long)0).FromUnixTime();
|
||||
|
||||
Assert.Equal(epoch, result);
|
||||
@@ -37,9 +37,9 @@ public class UnixTimestampExtensionsTests
|
||||
public void ReturnsDateFromRandomTimeCorrectly()
|
||||
{
|
||||
var expected = new DateTimeOffset(1975, 1, 23, 1, 1, 2, TimeSpan.Zero);
|
||||
|
||||
|
||||
var result = ((long)159670862).FromUnixTime();
|
||||
|
||||
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Octokit.Tests.Helpers
|
||||
{
|
||||
var uri = new Uri("https://api.github.com/repositories/1/milestones?state=closed&sort=due_date&direction=asc&page=2");
|
||||
|
||||
var parameters = new Dictionary<string, string> { { "state", "open" }, { "sort", "other"} };
|
||||
var parameters = new Dictionary<string, string> { { "state", "open" }, { "sort", "other" } };
|
||||
|
||||
var actual = uri.ApplyParameters(parameters);
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Octokit.Tests.Models
|
||||
}";
|
||||
|
||||
var actual = new SimpleJsonSerializer().Deserialize<Deployment>(json);
|
||||
|
||||
|
||||
Assert.Equal(1, actual.Id);
|
||||
Assert.Equal("topic-branch", actual.Sha);
|
||||
Assert.Equal("https://api.github.com/repos/octocat/example/deployments/1", actual.Url);
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace Octokit.Tests.Models
|
||||
{
|
||||
var nextPageUrl = new Uri("https://example.com/page/2");
|
||||
var nextPageResponse = Task.Factory.StartNew<IApiResponse<List<object>>>(() =>
|
||||
new ApiResponse<List<object>>(new Response(), new List<object> {new object(), new object()}));
|
||||
var links = new Dictionary<string, Uri> {{"next", nextPageUrl}};
|
||||
new ApiResponse<List<object>>(new Response(), new List<object> { new object(), new object() }));
|
||||
var links = new Dictionary<string, Uri> { { "next", nextPageUrl } };
|
||||
var scopes = new List<string>();
|
||||
var httpResponse = Substitute.For<IResponse>();
|
||||
httpResponse.ApiInfo.Returns(new ApiInfo(links, scopes, scopes, "etag", new RateLimit(new Dictionary<string, string>())));
|
||||
|
||||
@@ -31,9 +31,9 @@ namespace Octokit.Tests.Models
|
||||
HasWiki = true,
|
||||
HasDownloads = true
|
||||
};
|
||||
|
||||
|
||||
var json = new SimpleJsonSerializer().Serialize(update);
|
||||
|
||||
|
||||
Assert.Equal(expected, json);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public class SearchCodeRequestTests
|
||||
public void ReturnsAReadOnlyDictionary()
|
||||
{
|
||||
var request = new SearchCodeRequest("test");
|
||||
|
||||
|
||||
var result = request.MergedQualifiers();
|
||||
|
||||
// If I can cast this to a writeable collection, then that defeats the purpose of a read only.
|
||||
|
||||
@@ -11,7 +11,7 @@ public class SearchRepositoryRequestTests
|
||||
public void ReturnsAReadOnlyDictionary()
|
||||
{
|
||||
var request = new SearchCodeRequest("test");
|
||||
|
||||
|
||||
var result = request.MergedQualifiers();
|
||||
|
||||
// If I can cast this to a writeable collection, then that defeats the purpose of a read only.
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Octokit.Tests.Reactive
|
||||
var result = await client.GetOrCreateApplicationAuthentication(
|
||||
"clientId",
|
||||
"secret",
|
||||
new NewAuthorization { Note = "Was it this one?"},
|
||||
new NewAuthorization { Note = "Was it this one?" },
|
||||
_ => Observable.Return(twoFactorChallengeResult));
|
||||
|
||||
Assert.Equal("OAUTHSECRET", result.Token);
|
||||
@@ -84,7 +84,7 @@ namespace Octokit.Tests.Reactive
|
||||
var challengeResults = new Queue<TwoFactorChallengeResult>(new[]
|
||||
{
|
||||
TwoFactorChallengeResult.RequestResendCode,
|
||||
new TwoFactorChallengeResult("wrong-code")
|
||||
new TwoFactorChallengeResult("wrong-code")
|
||||
});
|
||||
var twoFactorFailedException = new TwoFactorChallengeFailedException();
|
||||
var data = new NewAuthorization();
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace Octokit.Tests.Reactive
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", "name", null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "name", "reference").ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "", "reference").ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "name", "").ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "name", "").ToTask());
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
@@ -62,7 +62,7 @@ namespace Octokit.Tests.Reactive
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", newCommit).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", newCommit).ToTask());
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
|
||||
@@ -131,5 +131,5 @@ namespace Octokit.Tests.Reactive
|
||||
Assert.Throws<ArgumentNullException>(() => new ObservableDeploymentsClient(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,6 @@ namespace Octokit.Tests.Reactive
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, 1).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "", 1).ToTask());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TheGetForRepositoryMethod
|
||||
@@ -50,7 +49,7 @@ namespace Octokit.Tests.Reactive
|
||||
|
||||
gitHubClient.Connection.Received(1).Get<List<IssueComment>>(
|
||||
new Uri("repos/fake/repo/issues/comments", UriKind.Relative), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresArgumentsNotNull()
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Octokit.Tests.Reactive
|
||||
{
|
||||
var firstPageUrl = new Uri("repos/fake/repo/milestones", UriKind.Relative);
|
||||
var secondPageUrl = new Uri("https://example.com/page/2");
|
||||
var firstPageLinks = new Dictionary<string, Uri> {{"next", secondPageUrl}};
|
||||
var firstPageLinks = new Dictionary<string, Uri> { { "next", secondPageUrl } };
|
||||
var firstPageResponse = new ApiResponse<List<Milestone>>
|
||||
(
|
||||
CreateResponseWithApiInfo(firstPageLinks),
|
||||
@@ -57,7 +57,7 @@ namespace Octokit.Tests.Reactive
|
||||
}
|
||||
);
|
||||
var thirdPageUrl = new Uri("https://example.com/page/3");
|
||||
var secondPageLinks = new Dictionary<string, Uri> {{"next", thirdPageUrl}};
|
||||
var secondPageLinks = new Dictionary<string, Uri> { { "next", thirdPageUrl } };
|
||||
var secondPageResponse = new ApiResponse<List<Milestone>>
|
||||
(
|
||||
CreateResponseWithApiInfo(secondPageLinks),
|
||||
@@ -98,7 +98,7 @@ namespace Octokit.Tests.Reactive
|
||||
{
|
||||
var firstPageUrl = new Uri("repos/fake/repo/milestones", UriKind.Relative);
|
||||
var secondPageUrl = new Uri("https://example.com/page/2");
|
||||
var firstPageLinks = new Dictionary<string, Uri> {{"next", secondPageUrl}};
|
||||
var firstPageLinks = new Dictionary<string, Uri> { { "next", secondPageUrl } };
|
||||
var firstPageResponse = new ApiResponse<List<Milestone>>
|
||||
(
|
||||
CreateResponseWithApiInfo(firstPageLinks),
|
||||
@@ -110,7 +110,7 @@ namespace Octokit.Tests.Reactive
|
||||
}
|
||||
);
|
||||
var thirdPageUrl = new Uri("https://example.com/page/3");
|
||||
var secondPageLinks = new Dictionary<string, Uri> {{"next", thirdPageUrl}};
|
||||
var secondPageLinks = new Dictionary<string, Uri> { { "next", thirdPageUrl } };
|
||||
var secondPageResponse = new ApiResponse<List<Milestone>>
|
||||
(
|
||||
CreateResponseWithApiInfo(secondPageLinks),
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace Octokit.Tests.Reactive
|
||||
});
|
||||
var lastPageResponse = new ApiResponse<List<PullRequestReviewComment>>
|
||||
(
|
||||
new Response(),
|
||||
new Response(),
|
||||
new List<PullRequestReviewComment>
|
||||
{
|
||||
new PullRequestReviewComment(7),
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Octokit.Tests.Reactive
|
||||
var gitHubClient = new GitHubClient(connection);
|
||||
var client = new ObservableRepositoriesClient(gitHubClient);
|
||||
var observable = client.Get("stark", "ned");
|
||||
|
||||
|
||||
connection.Received(1).Get<Repository>(Args.Uri, null, null);
|
||||
|
||||
var result = await observable;
|
||||
@@ -47,7 +47,7 @@ namespace Octokit.Tests.Reactive
|
||||
{
|
||||
var firstPageUrl = new Uri("user/repos", UriKind.Relative);
|
||||
var secondPageUrl = new Uri("https://example.com/page/2");
|
||||
var firstPageLinks = new Dictionary<string, Uri> {{"next", secondPageUrl}};
|
||||
var firstPageLinks = new Dictionary<string, Uri> { { "next", secondPageUrl } };
|
||||
var firstPageResponse = new ApiResponse<List<Repository>>(
|
||||
CreateResponseWithApiInfo(firstPageLinks),
|
||||
new List<Repository>
|
||||
@@ -57,7 +57,7 @@ namespace Octokit.Tests.Reactive
|
||||
new Repository(3)
|
||||
});
|
||||
var thirdPageUrl = new Uri("https://example.com/page/3");
|
||||
var secondPageLinks = new Dictionary<string, Uri> {{"next", thirdPageUrl}};
|
||||
var secondPageLinks = new Dictionary<string, Uri> { { "next", thirdPageUrl } };
|
||||
var secondPageResponse = new ApiResponse<List<Repository>>
|
||||
(
|
||||
CreateResponseWithApiInfo(secondPageLinks),
|
||||
@@ -122,7 +122,7 @@ namespace Octokit.Tests.Reactive
|
||||
var thirdPageLinks = new Dictionary<string, Uri> { { "next", fourthPageUrl } };
|
||||
var thirdPageResponse = new ApiResponse<List<Repository>>
|
||||
(
|
||||
|
||||
|
||||
CreateResponseWithApiInfo(thirdPageLinks),
|
||||
new List<Repository>
|
||||
{
|
||||
@@ -174,7 +174,7 @@ namespace Octokit.Tests.Reactive
|
||||
new Repository(365),
|
||||
new Repository(366)
|
||||
});
|
||||
|
||||
|
||||
var thirdPageUrl = new Uri("https://example.com/page/3");
|
||||
var secondPageLinks = new Dictionary<string, Uri> { { "next", thirdPageUrl } };
|
||||
IApiResponse<List<Repository>> secondPageResponse = new ApiResponse<List<Repository>>
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Octokit.Tests.Reactive
|
||||
|
||||
[Fact]
|
||||
public async Task ThrowsIfGivenNullRepositoryName()
|
||||
{
|
||||
{
|
||||
var statisticsClient = new ObservableStatisticsClient(Substitute.For<IGitHubClient>());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => statisticsClient.GetContributors("owner", null).ToTask());
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Octokit.Tests
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "name", "").ToTask());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class TheGetRecursiveMethod
|
||||
{
|
||||
[Fact]
|
||||
@@ -64,7 +64,7 @@ namespace Octokit.Tests
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetRecursive("owner", "name", "").ToTask());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class TheCreateMethod
|
||||
{
|
||||
[Fact]
|
||||
|
||||
@@ -80,14 +80,14 @@ namespace Octokit.Tests
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class TheDeserializeMethod
|
||||
{
|
||||
[Fact]
|
||||
public void DeserializesEventInfosWithUnderscoresInName()
|
||||
{
|
||||
const string json = "{\"event\":\"head_ref_deleted\"}";
|
||||
new SimpleJsonSerializer().Deserialize<EventInfo>(json);
|
||||
new SimpleJsonSerializer().Deserialize<EventInfo>(json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user