diff --git a/Octokit.Tests/Clients/GistsClientTests.cs b/Octokit.Tests/Clients/GistsClientTests.cs index 2554b95e..2477fe5e 100644 --- a/Octokit.Tests/Clients/GistsClientTests.cs +++ b/Octokit.Tests/Clients/GistsClientTests.cs @@ -4,6 +4,8 @@ using Octokit; using Xunit; using System.Collections.ObjectModel; using System.Collections.Generic; +using System.Threading.Tasks; +using Octokit.Tests.Helpers; public class GistsClientTests { @@ -41,6 +43,30 @@ public class GistsClientTests } } + public class TheDeleteMethod + { + [Fact] + public void PostsToTheCorrectUrl() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + client.Delete("1"); + + connection.Received().Delete(Arg.Is(u => u.ToString() == "gists/1")); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + AssertEx.Throws(async () => await + client.Delete(null)); + } + } + public class TheCtor { [Fact] diff --git a/Octokit/Clients/GistsClient.cs b/Octokit/Clients/GistsClient.cs index 6429417f..7dc92efc 100644 --- a/Octokit/Clients/GistsClient.cs +++ b/Octokit/Clients/GistsClient.cs @@ -63,5 +63,19 @@ namespace Octokit return ApiConnection.Post(ApiUrls.Gist(), gist); } + + /// + /// Deletes a gist + /// + /// + /// http://developer.github.com/v3/gists/#delete-a-gist + /// + /// The id of the gist + public Task Delete(string id) + { + Ensure.ArgumentNotNull(id, "id"); + + return ApiConnection.Delete(ApiUrls.Gist(id)); + } } } \ No newline at end of file diff --git a/Octokit/Clients/IGistsClient.cs b/Octokit/Clients/IGistsClient.cs index 72571f19..587d0b4f 100644 --- a/Octokit/Clients/IGistsClient.cs +++ b/Octokit/Clients/IGistsClient.cs @@ -32,5 +32,14 @@ namespace Octokit /// /// The new gist to create Task Create(NewGist newGist); + + /// + /// Deletes a gist + /// + /// + /// http://developer.github.com/v3/gists/#delete-a-gist + /// + /// The id of the gist + Task Delete(string id); } } \ No newline at end of file