當前位置: 首頁>>代碼示例>>C#>>正文


C# Octokit.GistsClient類代碼示例

本文整理匯總了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>());
        }
開發者ID:harunpehlivan,項目名稱:octokit.net,代碼行數:19,代碼來源:GistsClientTests.cs

示例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);
        }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:8,代碼來源:GistsClientTests.cs

示例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);
        }
開發者ID:harunpehlivan,項目名稱:octokit.net,代碼行數:9,代碼來源:GistsClientTests.cs

示例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")));
        }
開發者ID:harunpehlivan,項目名稱:octokit.net,代碼行數:10,代碼來源:GistsClientTests.cs

示例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);
        }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:11,代碼來源:GistsClientTests.cs

示例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);

        }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:17,代碼來源:GistsClientTests.cs

示例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);
        }
開發者ID:richardkundl,項目名稱:octokit.net,代碼行數:25,代碼來源:GitHubClient.cs

示例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"));
        }
開發者ID:harunpehlivan,項目名稱:octokit.net,代碼行數:14,代碼來源:GistsClientTests.cs

示例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"));
        }
開發者ID:harunpehlivan,項目名稱:octokit.net,代碼行數:9,代碼來源:GistsClientTests.cs

示例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);
        }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:9,代碼來源:GistsClientTests.cs

示例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));
        }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:11,代碼來源:GistsClientTests.cs

示例12: EnsuresArgumentsNotNull

        public async Task EnsuresArgumentsNotNull()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new GistsClient(connection);

            Assert.Throws<ArgumentNullException>(() => client.Delete(null));
        }
開發者ID:harunpehlivan,項目名稱:octokit.net,代碼行數:7,代碼來源:GistsClientTests.cs

示例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);

        }
開發者ID:RadicalLove,項目名稱:octokit.net,代碼行數:18,代碼來源:GistsClientTests.cs

示例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(""));
        }
開發者ID:LiyeXu,項目名稱:octokit.net,代碼行數:11,代碼來源:GistsClientTests.cs

示例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);
        }
開發者ID:harunpehlivan,項目名稱:octokit.net,代碼行數:15,代碼來源:GistsClientTests.cs


注:本文中的Octokit.GistsClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。