public async Task ShouldReturnEmptyReportForEachMemberIfNoPullRequests() { const int expectedTeamMembersCount = 6; var members = Builder <TeamMemberViewModel> .CreateListOfSize(expectedTeamMembersCount) .Build(); var profile = Builder <ProfileViewModel> .CreateNew() .With(p => p.Members = members.Select(m => m.Id).ToArray()) .With(p => p.Repositories = new Guid[0]) .Build(); SetupGetProfile(profile); SetupGetTeamMember(members); SetupGetPullRequests(Enumerable.Empty <PullRequestViewModel>()); await InvokeAndVerify <PullRequestsReport>(Command, (report, reportId) => { report.Should().NotBeNull(); report.Id.Should().Be(reportId); report.IndividualReports.Should().HaveCount(expectedTeamMembersCount); report.IndividualReports.Should().OnlyContain(r => r.IsEmpty); }); DataSourceMock.VerifyAll(); RepositoryMock.Verify(); }
public async Task ShouldCorrectlyCalculateMetricsForEachMember() { const int expectedTeamMembersCount = 2; var start = DateTime.Now.AddDays(-7); var end = DateTime.Now; var members = Builder <TeamMemberViewModel> .CreateListOfSize(4) .Build(); var memberIds = members.Take(2).Select(m => m.Id).ToArray(); var additionalMemberIds = members.TakeLast(2).Select(m => m.Id).ToArray(); var repositories = new[] { Guid.NewGuid(), Guid.NewGuid() }; var profile = Builder <ProfileViewModel> .CreateNew() .With(p => p.Members = memberIds) .With(p => p.Repositories = repositories) .Build(); var pullRequests = GetPullRequests(start, end, memberIds, repositories) .Union(GetPullRequests(start, end, memberIds, new[] { Guid.NewGuid(), Guid.NewGuid() })) .Union(GetPullRequests(start, end, additionalMemberIds, repositories)) .ToArray(); SetupGetProfile(profile); SetupGetTeamMember(members); SetupGetPullRequests(pullRequests); var command = new GeneratePullRequestsReport { Profile = Guid.NewGuid(), Start = start, End = end }; await InvokeAndVerify <PullRequestsReport>(command, (report, reportId) => { report.Should().NotBeNull(); report.IndividualReports.Should().HaveCount(expectedTeamMembersCount); var firstMemberReport = report.IndividualReports.First(); var secondMemberReport = report.IndividualReports.Last(); firstMemberReport.Created.Should().Be(7); firstMemberReport.Active.Should().Be(4); firstMemberReport.Completed.Should().Be(3); firstMemberReport.Abandoned.Should().Be(2); firstMemberReport.TotalIterations.Should().Be(9); firstMemberReport.TotalComments.Should().Be(18); secondMemberReport.Created.Should().Be(7); secondMemberReport.Active.Should().Be(5); secondMemberReport.Completed.Should().Be(6); secondMemberReport.Abandoned.Should().Be(1); secondMemberReport.TotalIterations.Should().Be(12); secondMemberReport.TotalComments.Should().Be(24); }); DataSourceMock.VerifyAll(); RepositoryMock.Verify(); }
public async Task ShouldHandlePullRequestCompletedInFuture() { var start = DateTime.Now.AddDays(-11); var end = DateTime.Now; var member = Builder <TeamMemberViewModel> .CreateNew() .Build(); var memberIds = new[] { member.Id }; var repositories = new[] { Guid.NewGuid() }; var profile = Builder <ProfileViewModel> .CreateNew() .With(p => p.Members = new[] { member.Id }) .With(p => p.Repositories = repositories) .Build(); var pullRequest = GetCompletedPullRequest(member.Id, repositories[0], end.AddHours(5), end.AddHours(5), createdInThePast: true); SetupGetProfile(profile); SetupGetTeamMember(new[] { member }); SetupGetPullRequests(new[] { pullRequest }); var command = new GeneratePullRequestsReport { Profile = Guid.NewGuid(), Start = start, End = end }; await InvokeAndVerify <PullRequestsReport>(command, (report, reportId) => { report.Should().NotBeNull(); var firstMemberReport = report.IndividualReports.First(); firstMemberReport.Created.Should().Be(1); firstMemberReport.Active.Should().Be(0); firstMemberReport.Completed.Should().Be(0); firstMemberReport.Abandoned.Should().Be(0); firstMemberReport.TotalIterations.Should().Be(1); firstMemberReport.TotalComments.Should().Be(2); firstMemberReport.AveragePRLifespan.Should().Be(TimeSpan.Zero); }); DataSourceMock.VerifyAll(); RepositoryMock.Verify(); }