本文整理汇总了C#中Octokit.GistsClient类的典型用法代码示例。如果您正苦于以下问题:C# GistsClient类的具体用法?C# GistsClient怎么用?C# GistsClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GistsClient类属于Octokit命名空间,在下文中一共展示了GistsClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostsToTheCorrectUrl
public void PostsToTheCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new GistsClient(connection);
var updateGist = new GistUpdate();
updateGist.Description = "my newly updated gist";
var gistFileUpdate = new GistFileUpdate
{
NewFileName = "myNewGistTestFile.cs",
Content = "new GistsClient(connection).Edit();"
};
updateGist.Files.Add("myGistTestFile.cs", gistFileUpdate);
client.Edit("1", updateGist);
connection.Received().Patch<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/1"), Arg.Any<object>());
}
示例2: RequestsCorrectGetAllUrl
public void RequestsCorrectGetAllUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new GistsClient(connection);
client.GetAll();
connection.Received().GetAll<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists"), Args.ApiOptions);
}
示例3: RequestsCorrectUrl
public void RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new GistsClient(connection);
client.Get("1");
connection.Received().Get<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/1"), null);
}
示例4: RequestsCorrectGetAllWithSinceUrl
public void RequestsCorrectGetAllWithSinceUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new GistsClient(connection);
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")));
}
示例5: RequestsCorrectGetAllWithSinceUrl
public void RequestsCorrectGetAllWithSinceUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new GistsClient(connection);
DateTimeOffset since = DateTimeOffset.Now;
client.GetAll(since);
connection.Received().GetAll<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists"),
DictionaryWithSince, Args.ApiOptions);
}
示例6: RequestsCorrectGetAllUrlWithApiOptions
public void RequestsCorrectGetAllUrlWithApiOptions()
{
var connection = Substitute.For<IApiConnection>();
var client = new GistsClient(connection);
var options = new ApiOptions
{
PageSize = 1,
PageCount = 1,
StartPage = 1
};
client.GetAll(options);
connection.Received().GetAll<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists"), options);
}
示例7: GitHubClient
/// <summary>
/// Create a new instance of the GitHub API v3 client using the specified connection.
/// </summary>
/// <param name="connection">The underlying <seealso cref="IConnection"/> used to make requests</param>
public GitHubClient(IConnection connection)
{
Ensure.ArgumentNotNull(connection, "connection");
Connection = connection;
var apiConnection = new ApiConnection(connection);
Authorization = new AuthorizationsClient(apiConnection);
Activity = new ActivitiesClient(apiConnection);
Blob = new BlobsClient(apiConnection);
Issue = new IssuesClient(apiConnection);
Miscellaneous = new MiscellaneousClient(connection);
Notification = new NotificationsClient(apiConnection);
Organization = new OrganizationsClient(apiConnection);
Repository = new RepositoriesClient(apiConnection);
Gist = new GistsClient(apiConnection);
Release = new ReleasesClient(apiConnection);
User = new UsersClient(apiConnection);
SshKey = new SshKeysClient(apiConnection);
GitDatabase = new GitDatabaseClient(apiConnection);
Tree = new TreesClient(apiConnection);
}
示例8: ThrowsExceptionForInvalidStatusCode
public async Task ThrowsExceptionForInvalidStatusCode()
{
var response = Task.Factory.StartNew<IResponse<object>>(() =>
new ApiResponse<object> { StatusCode = HttpStatusCode.Conflict });
var connection = Substitute.For<IConnection>();
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "gists/1/star"),
null, null).Returns(response);
var apiConnection = Substitute.For<IApiConnection>();
apiConnection.Connection.Returns(connection);
var client = new GistsClient(apiConnection);
await AssertEx.Throws<ApiException>(async () => await client.IsStarred("1"));
}
示例9: RequestsCorrectUnstarUrl
public void RequestsCorrectUnstarUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new GistsClient(connection);
client.Unstar("1");
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "gists/1/star"));
}
示例10: RequestsCorrectGetCommitsUrl
public void RequestsCorrectGetCommitsUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new GistsClient(connection);
client.GetAllCommits("9257657");
connection.Received().GetAll<GistHistory>(Arg.Is<Uri>(u => u.ToString() == "gists/9257657/commits"), Args.ApiOptions);
}
示例11: EnsureNonNullArguments
public async Task EnsureNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new GistsClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUser(null));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForUser(""));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForUser("", DateTimeOffset.Now));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForUser("", DateTimeOffset.Now, ApiOptions.None));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUser("user", DateTimeOffset.Now, null));
}
示例12: EnsuresArgumentsNotNull
public async Task EnsuresArgumentsNotNull()
{
var connection = Substitute.For<IApiConnection>();
var client = new GistsClient(connection);
Assert.Throws<ArgumentNullException>(() => client.Delete(null));
}
示例13: RequestsCorrectGetAllWithSinceUrlAndApiOptions
public void RequestsCorrectGetAllWithSinceUrlAndApiOptions()
{
var connection = Substitute.For<IApiConnection>();
var client = new GistsClient(connection);
var options = new ApiOptions
{
PageSize = 1,
PageCount = 1,
StartPage = 1
};
DateTimeOffset since = DateTimeOffset.Now;
client.GetAll(since, options);
connection.Received().GetAll<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists"),
DictionaryWithSince, options);
}
示例14: EnsureNonNullArguments
public async Task EnsureNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new GistsClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllCommits(null));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllCommits(""));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForks(null));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForks(""));
}
示例15: RequestsCorrectValueForStatusCode
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
{
var response = Task.Factory.StartNew<IResponse<object>>(() =>
new ApiResponse<object> { StatusCode = status });
var connection = Substitute.For<IConnection>();
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "gists/1/star"),
null, null).Returns(response);
var apiConnection = Substitute.For<IApiConnection>();
apiConnection.Connection.Returns(connection);
var client = new GistsClient(apiConnection);
var result = await client.IsStarred("1");
Assert.Equal(expected, result);
}