コード例 #1
0
        public void find_commits_calls_githubclient_with_multiple_pages_multiple_times()
        {
            var firstCommitsLink = string.Format("repos/{0}/{1}/commits?sha={2}&page={3}&per_page=100", ownerName, repositoryName, branchName, 1);
            var secondCommitsLink = string.Format("repos/{0}/{1}/commits?sha={2}&page={3}&per_page=100", ownerName, repositoryName, branchName, 2);

            var firstResponse = new LinkedResponsePayload<List<CommitDataModel>>()
            {
                Data = Enumerable.Repeat(new CommitDataModel { Message = "1", SHA = "1" }, 100).ToList(),
                NextPageAvailable = true
            };
            var secondResponse = new LinkedResponsePayload<List<CommitDataModel>>()
            {
                Data = Enumerable.Repeat(new CommitDataModel { Message = "1", SHA = "1" }, 1).ToList(),
                NextPageAvailable = false
            };

            githubRestClient.Setup(x => x.GetResponse<List<CommitDataModel>>(firstCommitsLink))
                .Returns(firstResponse)
                .Verifiable();

            githubRestClient.Setup(x => x.GetResponse<List<CommitDataModel>>(secondCommitsLink))
                .Returns(secondResponse)
                .Verifiable();

            var provider = new GitHubDataProvider(githubRestClient.Object);
            provider.FindCommits(repositoryName, branchName, tagName);

            githubRestClient.VerifyAll();
        }
コード例 #2
0
 public void WhenCalled_GetDetails()
 {
     //TODO - this is calling service. Use DI to avoid that.
     IProjectDataProvider provider = new GitHubDataProvider();
     List<Project> projects= provider.GetProjects().ToList();
     Assert.IsTrue(projects.Count() == 3, "Expected {0}.But actual was {1}", 1, projects.Count());
 }
コード例 #3
0
        public void WhenCalled_GetDetails()
        {
            //TODO - this is calling service. Use DI to avoid that.
            IProjectDataProvider provider = new GitHubDataProvider();
            List <Project>       projects = provider.GetProjects().ToList();

            Assert.IsTrue(projects.Count() == 3, "Expected {0}.But actual was {1}", 1, projects.Count());
        }
コード例 #4
0
        public List<string> Build(string repositoryName, string branchName, string tagName, string[] taskPrefixes)
        {
            var gitHubClient = new GitHubRestClient(notesBuilderConfiguration.GithubOwnerName, notesBuilderConfiguration.GithubAccessToken);
            var gitHubPovider = new GitHubDataProvider(gitHubClient);

            var jiraClient = new JiraRestClient(notesBuilderConfiguration.JiraUsername, notesBuilderConfiguration.JiraPassword);
            var jiraProvider = new JiraDataProvider(jiraClient);

            var taskCriteria = taskPrefixes
                .Select(x => new Regex(x + "-(\\d){1,}", RegexOptions.Multiline | RegexOptions.IgnoreCase))
                .ToArray();

            var taskNames = gitHubPovider.GetTaskNamesByCommitDescription(repositoryName, branchName, tagName, taskCriteria);

            return taskNames.Select(taskName => string.Format("{0} {1}", taskName, jiraProvider.GetTask(taskName).Summary)).ToList();
        }
コード例 #5
0
        public List <string> Build(string repositoryName, string branchName, string tagName, string[] taskPrefixes)
        {
            var gitHubClient  = new GitHubRestClient(notesBuilderConfiguration.GithubOwnerName, notesBuilderConfiguration.GithubAccessToken);
            var gitHubPovider = new GitHubDataProvider(gitHubClient);

            var jiraClient   = new JiraRestClient(notesBuilderConfiguration.JiraUsername, notesBuilderConfiguration.JiraPassword);
            var jiraProvider = new JiraDataProvider(jiraClient);

            var taskCriteria = taskPrefixes
                               .Select(x => new Regex(x + "-(\\d){1,}", RegexOptions.Multiline | RegexOptions.IgnoreCase))
                               .ToArray();

            var taskNames = gitHubPovider.GetTaskNamesByCommitDescription(repositoryName, branchName, tagName, taskCriteria);

            return(taskNames.Select(taskName => string.Format("{0} {1}", taskName, jiraProvider.GetTask(taskName).Summary)).ToList());
        }
コード例 #6
0
        public void FindCommitCallsGitHubRestClientWithCorrectLink()
        {
            var mock = new Mock <IGitHubRestClient>(MockBehavior.Strict);

            mock.Setup(x => x.OwnerName).Returns("Owner");

            var tagLinkForSHA = string.Format("repos/{0}/{1}/git/refs/tags/{2}", "Owner", "Repo", "release-0.1");

            mock.Setup(x => x.GetResponse <TagDataModel>(tagLinkForSHA)).Returns(new LinkedResponsePayload <TagDataModel>()
            {
                Data = new TagDataModel()
                {
                    SHA = "release-0.1"
                }
            }).Verifiable();

            var tagLinkForData = string.Format("repos/{0}/{1}/git/tags/{2}", "Owner", "Repo", "release-0.1");;

            mock.Setup(x => x.GetResponse <TagDataModel>(tagLinkForData)).Returns(new LinkedResponsePayload <TagDataModel>()
            {
                Data = new TagDataModel()
                {
                    SHA = "Some sha"
                }
            }).Verifiable();

            var commitsLink = string.Format("repos/{0}/{1}/commits?sha={2}&page={3}&per_page=100", "Owner", "Repo", "Branch", "1");

            mock.Setup(x => x.GetResponse <List <CommitDataModel> >(commitsLink)).Returns(new LinkedResponsePayload <List <CommitDataModel> >()
            {
                Data = Enumerable.Repeat(new CommitDataModel
                {
                    Message = "1",
                    SHA     = "1"
                }, 100).ToList(),
                NextPageAvailable = false
            }).Verifiable();


            var provider = new GitHubDataProvider(mock.Object);

            provider.FindCommits("Repo", "Branch", "release-0.1");

            mock.VerifyAll();
        }
コード例 #7
0
        public async Task GitHubProvider_AllWorkItemsAsync_PublicGitHubQuery()
        {
            // arrange
            var provider = new GitHubDataProvider("violet-workitems-github-unittest", null);

            // act
            var workItems = await provider.ListWorkItemsAsync("workitems/workitems");

            // assert
            Assert.True(workItems.Count() > 0);
            Assert.True(workItems.All(wi => wi.ProjectCode == "workitems/workitems"));
            Assert.True(workItems.All(wi => wi.WorkItemType == "Issue"));

            var workItem15 = workItems.FirstOrDefault(wi => wi.Id == "15");

            Assert.NotNull(workItem15);
            Assert.Equal("Version 1.0 Package Maintenance", workItem15[GitHubDataProvider.TitleProperty].Value);
            Assert.Equal("closed", workItem15[GitHubDataProvider.StateProperty].Value);
        }
コード例 #8
0
        public async Task GitHubProvider_AllWorkItemsAsync_PublicGitHubQuery()
        {
            // arrange
            var provider = new GitHubDataProvider("violet-workitems-github-unittest", null);

            // act
            var workItems = await provider.ListWorkItemsAsync("violetgrass/projects");

            // assert
            Assert.True(workItems.Count() > 0);
            Assert.True(workItems.All(wi => wi.ProjectCode == "violetgrass/projects"));
            Assert.True(workItems.All(wi => wi.WorkItemType == "Issue"));

            var workItem16 = workItems.FirstOrDefault(wi => wi.Id == "16");

            Assert.NotNull(workItem16);
            Assert.Equal("Migrate to ASP.NET Core 2.0", workItem16[GitHubDataProvider.TitleProperty].Value);
            Assert.Equal("", workItem16[GitHubDataProvider.BodyProperty].Value);
            Assert.Equal("closed", workItem16[GitHubDataProvider.StateProperty].Value);
        }
コード例 #9
0
        public void FindCommitCallsGitHubRestClientWithCorrectLink()
        {
            var mock = new Mock<IGitHubRestClient>(MockBehavior.Strict);
            mock.Setup(x => x.OwnerName).Returns("Owner");

            var tagLinkForSHA = string.Format("repos/{0}/{1}/git/refs/tags/{2}", "Owner", "Repo", "release-0.1");

            mock.Setup(x => x.GetResponse<TagDataModel>(tagLinkForSHA)).Returns(new LinkedResponsePayload<TagDataModel>()
            {
                Data = new TagDataModel() { SHA = "release-0.1" }
            }).Verifiable();

            var tagLinkForData = string.Format("repos/{0}/{1}/git/tags/{2}", "Owner", "Repo", "release-0.1"); ;

            mock.Setup(x => x.GetResponse<TagDataModel>(tagLinkForData)).Returns(new LinkedResponsePayload<TagDataModel>()
            {
                Data = new TagDataModel() { SHA = "Some sha" }
            }).Verifiable();

            var commitsLink = string.Format("repos/{0}/{1}/commits?sha={2}&page={3}&per_page=100", "Owner", "Repo", "Branch", "1");

            mock.Setup(x => x.GetResponse<List<CommitDataModel>>(commitsLink)).Returns(new LinkedResponsePayload<List<CommitDataModel>>()
            {
                Data = Enumerable.Repeat(new CommitDataModel
                {
                    Message = "1",
                    SHA = "1"
                }, 100).ToList(),
                NextPageAvailable = false
            }).Verifiable();

            var provider = new GitHubDataProvider(mock.Object);
            provider.FindCommits("Repo", "Branch", "release-0.1");

            mock.VerifyAll();
        }
コード例 #10
0
        public void WhenGitHubProviderIsAssignedToIProjectDataProvider_ShouldCompile()
        {
            IProjectDataProvider provider = new GitHubDataProvider();

            Assert.IsNotNull(provider);
        }
コード例 #11
0
 public void WhenGitHubProviderIsAssignedToIProjectDataProvider_ShouldCompile()
 {
     IProjectDataProvider provider= new GitHubDataProvider();
     Assert.IsNotNull(provider);
 }