예제 #1
0
    public async Task ReturnsCorrectCountOfIssueLabelsWithoutStartForAMilestoneWithRepositoryId()
    {
        var newMilestone = new NewMilestone("New Milestone");
        var milestone    = await _issuesClient.Milestone.Create(_context.RepositoryOwner, _context.RepositoryName, newMilestone);

        for (int i = 0; i < 2; i++)
        {
            int k        = i + 1;
            var newIssue = new NewIssue("A test issue " + k)
            {
                Body = "A new unassigned issue " + k
            };
            var newLabel = new NewLabel("test label " + k, "FFFFF" + k);

            var label = await _issuesLabelsClient.Create(_context.Repository.Id, newLabel);

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

            var issueUpdate = new IssueUpdate {
                Milestone = milestone.Number
            };
            issueUpdate.AddLabel(label.Name);
            var updated = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, issueUpdate);

            Assert.NotNull(updated);
        }

        var options = new ApiOptions
        {
            PageCount = 1,
            PageSize  = 1
        };

        var issueLabelsInfo = await _issuesLabelsClient.GetAllForMilestone(_context.Repository.Id, milestone.Number, options);

        Assert.Equal(1, issueLabelsInfo.Count);
    }
    public async Task CanAddToIssue()
    {
        var newIssue = new NewIssue("A test issue")
        {
            Body = "A new unassigned issue"
        };
        var newLabel = new NewLabel("test label 1b", "FFFFFF");

        var label = await _issuesLabelsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newLabel);

        Assert.NotNull(label);

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

        Assert.NotNull(issue);

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

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

        Assert.NotEmpty(labels);
        Assert.Equal(label.Name, labels[0].Name);
        Assert.Equal(label.Color, labels[0].Color);
    }
예제 #3
0
        public async Task <string> InsertLabelAsync(NewLabel newLabel)
        {
            var label = new Label()
            {
                Name        = newLabel.Name,
                PhoneNumber = newLabel.PhoneNumber,
                Url         = newLabel.Url,
                Email       = newLabel.Email,
                Address     = new Address()
                {
                    AddressLine1 = newLabel.Address.AddressLine1,
                    AddressLine2 = newLabel.Address.AddressLine2,
                    AddressLine3 = newLabel.Address.AddressLine3,
                    City         = newLabel.Address.City,
                    Locality     = newLabel.Address.Locality,
                    PostalCode   = newLabel.Address.PostalCode,
                    Country      = newLabel.Address.Country
                }
            };

            var labelId = await mongoDBPersistance.InsertOneLabelAsync(label);

            return(labelId);
        }
예제 #4
0
        public async Task AddLabel_Given_NewLabel_ModelState_Not_Valid_Return_400_BadRequest()
        {
            var label = new NewLabel()
            {
                Name        = "",
                PhoneNumber = "",
                Email       = "",
                Url         = "",
                Address     = new RequestAddress()
                {
                    AddressLine1 = "",
                    AddressLine2 = "",
                    AddressLine3 = "Address Line 3",
                    City         = "",
                    Locality     = "",
                    PostalCode   = "",
                    Country      = ""
                }
            };

            var retval = await _labelController.AddLabelAsync(label);

            Assert.IsInstanceOfType(retval, typeof(BadRequestResult));
        }
예제 #5
0
 public Task <Label> Add(NewLabel label)
 {
     return(_restClient.RequestAsync <Label>(new LabelsAddRequest(label)));
 }
        /// <summary>
        /// Creates a label.
        /// </summary>
        /// <remarks>
        /// See the <a href="http://developer.github.com/v3/issues/labels/#create-a-label">API documentation</a> for more information.
        /// </remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="newLabel">The data for the label to be created</param>
        public IObservable<Label> Create(long repositoryId, NewLabel newLabel)
        {
            Ensure.ArgumentNotNull(newLabel, "newLabel");

            return _client.Create(repositoryId, newLabel).ToObservable();
        }
        /// <summary>
        /// Creates a label.
        /// </summary>
        /// <remarks>
        /// See the <a href="http://developer.github.com/v3/issues/labels/#create-a-label">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="newLabel">The data for the label to be created</param>
        public IObservable<Label> Create(string owner, string name, NewLabel newLabel)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(newLabel, "newLabel");

            return _client.Create(owner, name, newLabel).ToObservable();
        }
            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);
            }
예제 #10
0
 public Label Add(NewLabel label)
 {
     return(_restClient.Request <Label>(new LabelsAddRequest(label)));
 }
예제 #11
0
 /// <summary>
 /// Creates a label.
 /// </summary>
 /// <remarks>
 /// See the <a href="http://developer.github.com/v3/issues/labels/#create-a-label">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="newLabel">The data for the label to be created</param>
 /// <returns>The created label</returns>
 public IObservable <Label> Create(string owner, string repo, NewLabel newLabel)
 {
     return(_client.Create(owner, repo, newLabel).ToObservable());
 }
예제 #12
0
 /// <inheritdoc />
 public async Task <Label> CreateLabelAsync(
     long repositoryId,
     NewLabel label)
 {
     return(await gitHubClient.Issue.Labels.Create(repositoryId, label));
 }
예제 #13
0
        /// <summary>
        /// Creates a label.
        /// </summary>
        /// <remarks>
        /// See the <a href="http://developer.github.com/v3/issues/labels/#create-a-label">API documentation</a> for more information.
        /// </remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="newLabel">The data for the label to be created</param>
        public IObservable <Label> Create(long repositoryId, NewLabel newLabel)
        {
            Ensure.ArgumentNotNull(newLabel, nameof(newLabel));

            return(_client.Create(repositoryId, newLabel).ToObservable());
        }
            public async Task EnsuresNonNullArguments()
            {
                var client = new ObservableIssuesLabelsClient(Substitute.For<IGitHubClient>());
                var newLabel = new NewLabel("labelName", "FF0000");

                Assert.Throws<ArgumentNullException>(() => client.Create(null, "name", newLabel));
                Assert.Throws<ArgumentNullException>(() => client.Create("owner", null, newLabel));
                Assert.Throws<ArgumentNullException>(() => client.Create("owner", "name", null));
                
                Assert.Throws<ArgumentNullException>(() => client.Create(1, null));
                
                Assert.Throws<ArgumentException>(() => client.Create("", "name", newLabel));
                Assert.Throws<ArgumentException>(() => client.Create("owner", "", newLabel));
            }
            public void CreatesCorrectUrlWithRepositoryId()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var client = new ObservableIssuesLabelsClient(gitHubClient);

                var newLabel = new NewLabel("labelName", "FF0000");

                client.Create(1, newLabel);

                gitHubClient.Received().Issue.Labels.Create(1, newLabel);
            }
 /// <summary>
 /// Creates a label.
 /// </summary>
 /// <remarks>
 /// See the <a href="http://developer.github.com/v3/issues/labels/#create-a-label">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="newLabel">The data for the label to be created</param>
 /// <returns>The created label</returns>
 public IObservable<Label> Create(string owner, string repo, NewLabel newLabel)
 {
     return _client.Create(owner, repo, newLabel).ToObservable();
 }