예제 #1
0
        public void TestParseGitShellResultWithPullRequests()
        {
            var input = new[] {
                @"216c583cf726064b28e18a1c3b183ab9dc6f8e1e;Bryan P. Arant;[email protected];Tue Jan 31 15:40:43 2017 -0800;GitHub;[email protected];Tue Jan 31 15:40:43 2017 -0800;",
                @"5dc153c2f2a7cfeb4fe310fa30d4096a34b6354c;Bryan Arant;[email protected];Mon Jan 30 17:44:57 2017 -0800;Bryan Arant;[email protected];Tue Jan 31 15:38:05 2017 -0800;",
                @" 2 files changed, 20 insertions(+)",
                @"08044f93c71a050c32b00b97877ee1e647001987;Wes Haggard;[email protected];Mon Jan 30 13:52:45 2017 -0800;Wes Haggard;[email protected];Mon Jan 30 13:52:45 2017 -0800;",
                @" 1 file changed, 3 insertions(+), 3 deletions(-)",
                @"4d5ee1df5de2fbd408209dfcedbf08e95d6987b9;Dan Moseley;[email protected];Mon Jan 30 12:39:37 2017 -0700;GitHub;[email protected];Mon Jan 30 12:39:37 2017 -0700;",
                @"45a8355090db5ae65c1b07516005ddb1a662366f;Chandan Rai;[email protected];Mon Jan 30 14:48:47 2017 +0530;GitHub;[email protected];Mon Jan 30 14:48:47 2017 +0530;",
                @" 1 file changed, 4 insertions(+), 4 deletions(-)",
                @"68323fff89222bcc4bbd930ae0165b2bfd4838ab;Vicey Wang;[email protected];Sun Jan 29 21:51:33 2017 +0800;Vicey Wang;[email protected];Sun Jan 29 21:51:33 2017 +0800;",
                @" 1 file changed, 2 deletions(-)",
            };
            var expected = new List <CommitInfo> {
                new CommitInfo("216c583cf726064b28e18a1c3b183ab9dc6f8e1e", "Bryan P. Arant", "*****@*****.**", CommitInfo.GitDefaultTime("Tue Jan 31 15:40:43 2017 -0800"), "GitHub", "*****@*****.**", CommitInfo.GitDefaultTime("Tue Jan 31 15:40:43 2017 -0800"), 0, 0, 0),
                new CommitInfo("5dc153c2f2a7cfeb4fe310fa30d4096a34b6354c", "Bryan Arant", "*****@*****.**", CommitInfo.GitDefaultTime("Mon Jan 30 17:44:57 2017 -0800"), "Bryan Arant", "*****@*****.**", CommitInfo.GitDefaultTime("Tue Jan 31 15:38:05 2017 -0800"), 2, 20, 0),
                new CommitInfo("08044f93c71a050c32b00b97877ee1e647001987", "Wes Haggard", "*****@*****.**", CommitInfo.GitDefaultTime("Mon Jan 30 13:52:45 2017 -0800"), "Wes Haggard", "*****@*****.**", CommitInfo.GitDefaultTime("Mon Jan 30 13:52:45 2017 -0800"), 1, 3, 3),
                new CommitInfo("4d5ee1df5de2fbd408209dfcedbf08e95d6987b9", "Dan Moseley", "*****@*****.**", CommitInfo.GitDefaultTime("Mon Jan 30 12:39:37 2017 -0700"), "GitHub", "*****@*****.**", CommitInfo.GitDefaultTime("Mon Jan 30 12:39:37 2017 -0700"), 0, 0, 0),
                new CommitInfo("45a8355090db5ae65c1b07516005ddb1a662366f", "Chandan Rai", "*****@*****.**", CommitInfo.GitDefaultTime("Mon Jan 30 14:48:47 2017 +0530"), "GitHub", "*****@*****.**", CommitInfo.GitDefaultTime("Mon Jan 30 14:48:47 2017 +0530"), 1, 4, 4),
                new CommitInfo("68323fff89222bcc4bbd930ae0165b2bfd4838ab", "Vicey Wang", "*****@*****.**", CommitInfo.GitDefaultTime("Sun Jan 29 21:51:33 2017 +0800"), "Vicey Wang", "*****@*****.**", CommitInfo.GitDefaultTime("Sun Jan 29 21:51:33 2017 +0800"), 1, 0, 2),
            };
            var mergedPullRequest = new Dictionary <string, (Octokit.PullRequest PullRequest, IReadOnlyList <Octokit.PullRequestReview> Reviews)>();

            mergedPullRequest.Add("216c583cf726064b28e18a1c3b183ab9dc6f8e1e", (new Octokit.PullRequest(5), new[] { new Octokit.PullRequestReview() }));
            mergedPullRequest.Add("08044f93c71a050c32b00b97877ee1e647001987", (new Octokit.PullRequest(3), new List <Octokit.PullRequestReview>()));

            var result = CommitInfo.ParseGitShellResult(new List <string>(input), mergedPullRequest);

            Assert.AreEqual(6, result.Count);
            CollectionAssert.AreEqual(expected, result);
            Assert.AreEqual(5, result[0].PullRequest);
            Assert.AreEqual(3, result[2].PullRequest);
        }