예제 #1
0
        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]");
        }
예제 #2
0
            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");
            }
예제 #4
0
            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);
            }