public async Task CanReplaceAllForIssue()
    {
        var newIssue1 = new NewIssue("A test issue")
        {
            Body = "A new unassigned issue"
        };
        var newLabel1 = new NewLabel("test label 1b", "FFFFFF");
        var newLabel2 = new NewLabel("test label 1a", "FFFFFF");

        var label1 = await _issuesLabelsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newLabel1);

        Assert.NotNull(label1);
        var label2 = await _issuesLabelsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newLabel2);

        Assert.NotNull(label2);

        var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue1);

        Assert.NotNull(issue);

        await _issuesLabelsClient.AddToIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new [] { label1.Name });

        await _issuesLabelsClient.ReplaceAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new[] { label2.Name });

        var labels = await _issuesLabelsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number);

        Assert.NotEmpty(labels);
        Assert.Equal(label2.Name, labels[0].Name);
        Assert.Equal(label2.Color, labels[0].Color);
    }
예제 #2
0
        /// <summary>
        /// Replaces all labels on the specified issues with the provided labels
        /// </summary>
        /// <remarks>
        /// See the <a href="http://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue">API documentation</a> for more information.
        /// </remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="number">The number of the issue</param>
        /// <param name="labels">The names of the labels to set</param>
        public IObservable <Label> ReplaceAllForIssue(string owner, string name, int number, string[] labels)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
            Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
            Ensure.ArgumentNotNull(labels, nameof(labels));

            return(_client.ReplaceAllForIssue(owner, name, number, labels)
                   .ToObservable()
                   .SelectMany(x => x)); // HACK: PUT is not compatible with GetAndFlattenPages
        }
예제 #3
0
 /// <summary>
 /// Replaces all labels on the specified issues with the provided labels
 /// </summary>
 /// <remarks>
 /// See the <a href="http://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue">API documentation</a> for more information.
 /// </remarks>
 /// <param name="owner">The owner of the repository</param>
 /// <param name="repo">The name of the repository</param>
 /// <param name="number">The number of the issue</param>
 /// <param name="labels">The names of the labels to set</param>
 /// <returns></returns>
 public IObservable <Label> ReplaceAllForIssue(string owner, string repo, int number, string[] labels)
 {
     return(_client.ReplaceAllForIssue(owner, repo, number, labels)
            .ToObservable()
            .SelectMany(x => x)); // HACK: PUT is not compatible with GetAndFlattenPages
 }