public async Task CanListLabelsForAnMilestoneWithRepositoryId()
    {
        var newIssue = new NewIssue("A test issue")
        {
            Body = "A new unassigned issue"
        };
        var newLabel     = new NewLabel("test label", "FFFFFF");
        var newMilestone = new NewMilestone("New Milestone");

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

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

        var milestone = await _issuesClient.Milestone.Create(_context.RepositoryOwner, _context.RepositoryName, newMilestone);

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

        Assert.Empty(issueLabelsInfo);

        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);

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

        Assert.Equal(1, issueLabelsInfo.Count);
        Assert.Equal(label.Color, issueLabelsInfo[0].Color);
    }
    public async Task CanListClosedMilestones()
    {
        var milestone1 = new NewMilestone("milestone 1")
        {
            DueOn = DateTime.Now
        };
        var milestone2 = new NewMilestone("milestone 2")
        {
            DueOn = DateTime.Now.AddDays(1)
        };
        var milestone3 = new NewMilestone("milestone 3")
        {
            DueOn = DateTime.Now.AddDays(3), State = ItemState.Closed
        };
        await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, milestone1);

        await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, milestone2);

        await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, milestone3);

        var milestones = await _milestonesClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName,
                                                                     new MilestoneRequest { State = ItemStateFilter.Closed });

        Assert.Equal(1, milestones.Count);
        Assert.Equal("milestone 3", milestones[0].Title);
    }
예제 #3
0
        public async Task ReturnsCorrectCountOfMilestonesWithStartWithRepositoryId()
        {
            var milestone1 = new NewMilestone("milestone 1")
            {
                DueOn = DateTime.Now
            };
            var milestone2 = new NewMilestone("milestone 2")
            {
                DueOn = DateTime.Now.AddDays(1)
            };
            var milestone3 = new NewMilestone("milestone 3")
            {
                DueOn = DateTime.Now.AddDays(3)
            };
            await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, milestone1);

            await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, milestone2);

            await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, milestone3);

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

            var milestones = await _milestonesClient.GetAllForRepository(_context.Repository.Id, options);

            Assert.Equal(1, milestones.Count);
        }
    public async Task CanListMilestonesWithSortByDueDateDesc()
    {
        var milestone1 = new NewMilestone("milestone 1")
        {
            DueOn = DateTime.Now
        };
        var milestone2 = new NewMilestone("milestone 2")
        {
            DueOn = DateTime.Now.AddDays(1)
        };
        var milestone3 = new NewMilestone("milestone 3")
        {
            DueOn = DateTime.Now.AddDays(3), State = ItemState.Closed
        };
        await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, milestone1);

        await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, milestone2);

        await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, milestone3);

        var milestones = await _milestonesClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName,
                                                                     new MilestoneRequest { SortDirection = SortDirection.Descending });

        Assert.Equal(2, milestones.Count);
        Assert.Equal("milestone 2", milestones[0].Title);
        Assert.Equal("milestone 1", milestones[1].Title);
    }
예제 #5
0
        public async Task CanListMilestonesWithDefaultSortByDueDateAscWithRepositoryId()
        {
            var milestone1 = new NewMilestone("milestone 1")
            {
                DueOn = DateTime.Now
            };
            var milestone2 = new NewMilestone("milestone 2")
            {
                DueOn = DateTime.Now.AddDays(1)
            };
            var milestone3 = new NewMilestone("milestone 3")
            {
                DueOn = DateTime.Now.AddDays(3), State = ItemState.Closed
            };
            await _milestonesClient.Create(_context.Repository.Id, milestone1);

            await _milestonesClient.Create(_context.Repository.Id, milestone2);

            await _milestonesClient.Create(_context.Repository.Id, milestone3);

            var milestones = await _milestonesClient.GetAllForRepository(_context.Repository.Id);

            Assert.Equal(2, milestones.Count);
            Assert.Equal("milestone 1", milestones[0].Title);
            Assert.Equal("milestone 2", milestones[1].Title);
        }
        /// <summary>
        /// Creates a milestone for the specified repository. Any user with pull access to a repository can create a
        /// Milestone.
        /// </summary>
        /// <remarks>http://developer.github.com/v3/issues/milestones/#create-a-milestone</remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="newMilestone">A <see cref="NewMilestone"/> instance describing the new Milestone to create</param>
        /// <returns></returns>
        public IObservable <Milestone> Create(string owner, string name, NewMilestone newMilestone)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(newMilestone, "newMilestone");

            return(_client.Create(owner, name, newMilestone).ToObservable());
        }
예제 #7
0
        public async Task CreateMileStone(long repoId, string Title, string Description = null)
        {
            var          client = this.GetClient();
            NewMilestone model  = new NewMilestone(Title);

            model.Description = Description == null ? "Automatically Generated Please Fill" : Description;
            CreatedMilestone  = await client.Issue.Milestone.Create(repoId, model);
        }
        /// <summary>
        /// Creates a milestone for the specified repository. Any user with pull access to a repository can create a
        /// Milestone.
        /// </summary>
        /// <remarks>http://developer.github.com/v3/issues/milestones/#create-a-milestone</remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="newMilestone">A <see cref="NewMilestone"/> instance describing the new Milestone to create</param>
        /// <returns></returns>
        public IObservable<Milestone> Create(string owner, string name, NewMilestone newMilestone)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(newMilestone, "newMilestone");

            return _client.Create(owner, name, newMilestone).ToObservable();
        }
 public async Task <Milestone> CreateMilestone(long repoId, NewMilestone newMilestone, GitHubClient authorizedGitHubClient)
 {
     if (_issuesClient == null)
     {
         _issuesClient = new IssuesClient(new ApiConnection(authorizedGitHubClient.Connection));
     }
     return(await _issuesClient.Milestone.Create(repoId, newMilestone));
 }
예제 #10
0
        public void ConvertMilestone()
        {
            Creator.Models.Objects.Milestone m = new Creator.Models.Objects.Milestone("Title", "Description", "1/2/2020");
            NewMilestone octokitMilestone      = m.ConvertTo();

            Assert.AreEqual(m.Title, octokitMilestone.Title);
            Assert.AreEqual(m.Description, octokitMilestone.Description);
            Assert.AreEqual(m.DueOn, octokitMilestone.DueOn);
        }
예제 #11
0
        private static async Task <Milestone> CreateNextMilestone(this IGitHubClient gitHubClient, string nextReleaseName)
        {
            var newMilestone = new NewMilestone(nextReleaseName);

            Console.WriteLine($"Creating new milestone '{newMilestone.Title}'...");
            var nextMilestone = await gitHubClient.Issue.Milestone.Create(RepoOwner, repoName, newMilestone);

            Console.WriteLine($"Created new milestone '{nextMilestone.Title}'");
            return(nextMilestone);
        }
            public void CreatesFromClientIssueMilestoneWithRepositoryId()
            {
                var newMilestone = new NewMilestone("some title");
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableMilestonesClient(gitHubClient);

                client.Create(1, newMilestone);

                gitHubClient.Issue.Milestone.Received().Create(1, newMilestone);
            }
예제 #13
0
            public void PostsToCorrectUrl()
            {
                var newMilestone = new NewMilestone("some title");
                var connection   = Substitute.For <IApiConnection>();
                var client       = new MilestonesClient(connection);

                client.Create("fake", "repo", newMilestone);

                connection.Received().Post <Milestone>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/milestones"),
                                                       newMilestone);
            }
예제 #14
0
            public void PostsToCorrectUrl()
            {
                var newMilestone = new NewMilestone("some title");
                var connection = Substitute.For<IApiConnection>();
                var client = new MilestonesClient(connection);

                client.Create("fake", "repo", newMilestone);

                connection.Received().Post<Milestone>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/milestones"),
                    newMilestone);
            }
예제 #15
0
        public async Task CreateMilestone(Model.Milestone milestone, Octokit.Repository githubRepo)
        {
            var newMilestone = new NewMilestone(milestone.Title)
            {
                Description = milestone.Description
            };

            var createdMilestone = await GitHubClient.Issue.Milestone.Create(githubRepo.Id, newMilestone);

            Log($"Milestone '{createdMilestone.Title}' created (Number: {createdMilestone.Number})");
        }
    public async Task CanRetrieveOneMilestone()
    {
        var newMilestone = new NewMilestone("a milestone")
        {
            DueOn = DateTime.Now
        };
        var created = await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newMilestone);

        var result = await _milestonesClient.Get(_context.RepositoryOwner, _context.RepositoryName, created.Number);

        Assert.Equal("a milestone", result.Title);
    }
    public async Task ReturnsDistinctIssueLabelsBasedOnStartPageForAMilestoneWithRepositoryId()
    {
        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 startOptions = new ApiOptions
        {
            PageCount = 1,
            PageSize  = 1,
            StartPage = 1
        };

        var firstPage = await _issuesLabelsClient.GetAllForMilestone(_context.Repository.Id, milestone.Number, startOptions);

        var skipStartOptions = new ApiOptions
        {
            PageSize  = 1,
            PageCount = 1,
            StartPage = 2
        };

        var secondPage = await _issuesLabelsClient.GetAllForMilestone(_context.Repository.Id, milestone.Number, skipStartOptions);

        Assert.Equal(1, firstPage.Count);
        Assert.Equal(1, secondPage.Count);
        Assert.NotEqual(firstPage.First().Color, secondPage.First().Color);
    }
예제 #18
0
        public async Task CanDeleteOneMilestoneWithRepositoryId()
        {
            var newMilestone = new NewMilestone("a milestone")
            {
                DueOn = DateTime.Now
            };
            var created = await _milestonesClient.Create(_context.Repository.Id, newMilestone);

            var milestone = await _milestonesClient.Get(_context.Repository.Id, created.Number);

            Assert.Equal("a milestone", milestone.Title);

            await _milestonesClient.Delete(_context.Repository.Id, created.Number);

            await Assert.ThrowsAsync <NotFoundException>(() => _milestonesClient.Get(_context.Repository.Id, created.Number));
        }
예제 #19
0
        public async Task CanUpdateOneMilestone()
        {
            var newMilestone = new NewMilestone("a milestone")
            {
                DueOn = DateTime.Now
            };
            var created = await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newMilestone);

            var result1 = await _milestonesClient.Get(_context.RepositoryOwner, _context.RepositoryName, created.Number);

            Assert.Equal("a milestone", result1.Title);

            await _milestonesClient.Update(_context.RepositoryOwner, _context.RepositoryName, created.Number, new MilestoneUpdate { Title = "New title" });

            var result2 = await _milestonesClient.Get(_context.RepositoryOwner, _context.RepositoryName, created.Number);

            Assert.Equal("New title", result2.Title);
        }
예제 #20
0
        /// <inheritdoc/>
        protected override async Task <object> CallGitHubApi(DialogContext dc, Octokit.GitHubClient gitHubClient, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (Owner != null && Name != null && NewMilestone != null)
            {
                var ownerValue        = Owner.GetValue(dc.State);
                var nameValue         = Name.GetValue(dc.State);
                var newMilestoneValue = NewMilestone.GetValue(dc.State);
                return(await gitHubClient.Issue.Milestone.Create(ownerValue, nameValue, newMilestoneValue).ConfigureAwait(false));
            }
            if (RepositoryId != null && NewMilestone != null)
            {
                var repositoryIdValue = RepositoryId.GetValue(dc.State);
                var newMilestoneValue = NewMilestone.GetValue(dc.State);
                return(await gitHubClient.Issue.Milestone.Create((Int64)repositoryIdValue, newMilestoneValue).ConfigureAwait(false));
            }

            throw new ArgumentNullException("Required [newMilestone] arguments missing for GitHubClient.Issue.Milestone.Create");
        }
예제 #21
0
        public async Task <ICollection <TransferObjects.Milestone> > CreateMilestones(Repository repository, ICollection <TransferObjects.Milestone> milestones)
        {
            var sortedMilestones = milestones.OrderBy(m => m.SourceId);

            foreach (var milestone in sortedMilestones)
            {
                var newMilestone = new NewMilestone(milestone.Title)
                {
                    Description = milestone.Description,
                    State       = milestone.Closed ? ItemState.Closed : ItemState.Open
                };
                var createdMilestone = await _gitHubClient.Issue.Milestone.Create(repository.Id, newMilestone);

                milestone.TargetId = createdMilestone.Number;
            }

            return(milestones);
        }
        public async Task <Milestone> GetOrCreateMilestoneAsync(string name, string description, DateTimeOffset?dueDate = null)
        {
            var allMilestones = await _githubClient.Issue.Milestone.GetAllForRepository(_repoOwner, _repoName);

            var foundMilestone = allMilestones.FirstOrDefault(milestone => milestone.Title.Equals(name, StringComparison.InvariantCultureIgnoreCase));

            if (foundMilestone == null)
            {
                var newMilestone = new NewMilestone(name)
                {
                    Description = description,
                    DueOn       = dueDate
                };
                foundMilestone = await _githubClient.Issue.Milestone.Create(_repoOwner, _repoName, newMilestone);
            }

            return(foundMilestone);
        }
예제 #23
0
        public async Task ReturnsDistinctResultsBasedOnStartPageParametrizedWithRepositoryId()
        {
            var milestone1 = new NewMilestone("milestone 1")
            {
                DueOn = DateTime.Now
            };
            var milestone2 = new NewMilestone("milestone 2")
            {
                DueOn = DateTime.Now.AddDays(1), State = ItemState.Closed
            };
            var milestone3 = new NewMilestone("milestone 3")
            {
                DueOn = DateTime.Now.AddDays(3), State = ItemState.Closed
            };
            await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, milestone1);

            await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, milestone2);

            await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, milestone3);

            var milestoneRequest = new MilestoneRequest {
                State = ItemStateFilter.Closed
            };

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

            var firstPage = await _milestonesClient.GetAllForRepository(_context.Repository.Id, milestoneRequest, startOptions);

            var skipStartOptions = new ApiOptions
            {
                PageSize  = 1,
                PageCount = 1,
                StartPage = 2
            };

            var secondPage = await _milestonesClient.GetAllForRepository(_context.Repository.Id, milestoneRequest, skipStartOptions);

            Assert.NotEqual(firstPage[0].Number, secondPage[0].Number);
        }
    public async Task CanAssignAndUnassignMilestone()
    {
        var newMilestone = new NewMilestone("a milestone");
        var milestone    = await _issuesClient.Milestone.Create(_context.RepositoryOwner, _context.RepositoryName, newMilestone);

        var newIssue1 = new NewIssue("A test issue1")
        {
            Body      = "A new unassigned issue",
            Milestone = milestone.Number
        };
        var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue1);

        Assert.NotNull(issue.Milestone);

        var issueUpdate = issue.ToUpdate();

        issueUpdate.Milestone = null;

        var updatedIssue = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, issueUpdate);

        Assert.Null(updatedIssue.Milestone);
    }
    public async Task ReturnsCorrectCountOfIssueLabelsWithStartForAMilestoneWithRepositoryId()
    {
        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,
            StartPage = 2
        };

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

        Assert.Equal(1, issueLabelsInfo.Count);
    }
예제 #26
0
        public async Task ReturnsCorrectCountOfMilestonesWithStartParametrized()
        {
            var milestone1 = new NewMilestone("milestone 1")
            {
                DueOn = DateTime.Now
            };
            var milestone2 = new NewMilestone("milestone 2")
            {
                DueOn = DateTime.Now.AddDays(1), State = ItemState.Closed
            };
            var milestone3 = new NewMilestone("milestone 3")
            {
                DueOn = DateTime.Now.AddDays(3), State = ItemState.Closed
            };
            var milestone4 = new NewMilestone("milestone 4")
            {
                DueOn = DateTime.Now.AddDays(4), State = ItemState.Closed
            };
            await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, milestone1);

            await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, milestone2);

            await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, milestone3);

            await _milestonesClient.Create(_context.RepositoryOwner, _context.RepositoryName, milestone4);

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

            var milestones = await _milestonesClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName, new MilestoneRequest { State = ItemStateFilter.Closed }, options);

            Assert.Equal(1, milestones.Count);
        }
예제 #27
0
 public async Task <Milestone> CreateMilestone(long repoId, NewMilestone newMilestone, GitHubClient authorizedGitHubClient)
 {
     return(await _issueRepository.CreateMilestone(repoId, newMilestone, authorizedGitHubClient));
 }
        /// <summary>
        /// Creates a milestone for the specified repository. Any user with pull access to a repository can create a
        /// Milestone.
        /// </summary>
        /// <remarks>http://developer.github.com/v3/issues/milestones/#create-a-milestone</remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="newMilestone">A <see cref="NewMilestone"/> instance describing the new Milestone to create</param>
        /// <returns></returns>
        public IObservable <Milestone> Create(int repositoryId, NewMilestone newMilestone)
        {
            Ensure.ArgumentNotNull(newMilestone, "newMilestone");

            return(_client.Create(repositoryId, newMilestone).ToObservable());
        }
            public void CreatesFromClientIssueMilestoneWithRepositoryId()
            {
                var newMilestone = new NewMilestone("some title");
                var gitHubClient = Substitute.For<IGitHubClient>();
                var client = new ObservableMilestonesClient(gitHubClient);

                client.Create(1, newMilestone);

                gitHubClient.Issue.Milestone.Received().Create(1, newMilestone);
            }
        /// <summary>
        /// Creates a milestone for the specified repository. Any user with pull access to a repository can create a
        /// Milestone.
        /// </summary>
        /// <remarks>http://developer.github.com/v3/issues/milestones/#create-a-milestone</remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="newMilestone">A <see cref="NewMilestone"/> instance describing the new Milestone to create</param>
        /// <returns></returns>
        public IObservable<Milestone> Create(long repositoryId, NewMilestone newMilestone)
        {
            Ensure.ArgumentNotNull(newMilestone, "newMilestone");

            return _client.Create(repositoryId, newMilestone).ToObservable();
        }