public static async Task CreateLabelAsync(this GitHubClient client, RepositoryInfo repository, Models.Objects.Label label) { IssuesLabelsClient ilc = new IssuesLabelsClient(new ApiConnection(client.Connection)); Colorizer.WriteLine("Creating label [Cyan!{0}] in repo [Yellow!{1}]", $"Title: {label.Title}, Description: {label.Description}, Color: {label.Color}", repository); await ilc.Create(repository.Owner, repository.Name, label.ConvertTo()); Colorizer.WriteLine("[Green!Success]"); }
public void CreatesCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new IssuesLabelsClient(connection); var newLabel = new NewLabel("labelName", "FF0000"); client.Create(1, newLabel); connection.Received().Post <Label>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/labels"), newLabel); }
public void CreatesCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new IssuesLabelsClient(connection); var newLabel = new NewLabel("labelName", "FF0000"); client.Create("fake", "repo", newLabel); connection.Received().Post <Label>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/labels"), newLabel, "application/vnd.github.symmetra-preview+json"); }
public async Task EnsuresNonNullArguments() { var client = new IssuesLabelsClient(Substitute.For <IApiConnection>()); var newLabel = new NewLabel("labelName", "FF0000"); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(null, "name", newLabel)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("owner", null, newLabel)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("owner", "name", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(1, null)); await Assert.ThrowsAsync <ArgumentException>(() => client.Create("", "name", newLabel)); await Assert.ThrowsAsync <ArgumentException>(() => client.Create("owner", "", newLabel)); }
public async Task EnsuresNonNullArguments() { var client = new IssuesLabelsClient(Substitute.For<IApiConnection>()); var newLabel = new NewLabel("labelName", "FF0000"); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", newLabel)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, newLabel)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(1, null)); await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", newLabel)); await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", newLabel)); }
public void CreatesCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new IssuesLabelsClient(connection); var newLabel = new NewLabel("labelName", "FF0000"); client.Create(1, newLabel); connection.Received().Post<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/labels"), newLabel); }