//[Ignore("Need to find if this tested else where")] public void WhenNegativePtt100_ShouldReturnAbsOfValue() { // arrange var author = new Author { Name = "T-rav", Emails = new List <string> { "*****@*****.**" } }; var repoPath = TestRepoPath("git-test-operations"); var sut = new SourceControlAnalysisBuilder() .WithPath(repoPath) .WithRange(DateTime.Parse("2018-09-13"), DateTime.Parse("2018-09-13")) .WithBranch("origin/negative-commits") .WithWorkingDaysPerWeek(4) .WithWorkingWeekHours(32) .Build(); // act var actual = sut.Build_Individual_Developer_Stats(new List <Author> { author }); // assert var expected = 81.97; actual.FirstOrDefault().Ptt100.Should().Be(expected); }
public void WhenTrue_ShouldReturnStatsIgnoringCommentedOutLines() { // arrange var repoPath = TestRepoPath("git-test-operations"); var author = new Author { Name = "T-rav", Emails = new List <string> { "*****@*****.**", "*****@*****.**" } }; var sut = new SourceControlAnalysisBuilder() .WithPath(repoPath) .WithRange(DateTime.Parse("2018-09-25"), DateTime.Parse("2018-09-25")) .WithWorkingDaysPerWeek(4) .WithWorkingWeekHours(32) .WithIgnoreComments(true) .Build(); // act var actual = sut.Build_Individual_Developer_Stats(new List <Author> { author }); // assert var expected = new List <DeveloperStats> { new DeveloperStats { Author = author, PeriodActiveDays = 1, Impact = 0.01, Churn = 1.0, LinesAdded = 6, LinesRemoved = 6, ActiveDaysPerWeek = 1, CommitsPerDay = 2, Rtt100 = 263.16, Ptt100 = Double.PositiveInfinity, LinesOfChangePerHour = 0.38 } }; actual.Should().BeEquivalentTo(expected); }
public void WhenUsingAliasMapping_ShouldReturnOneDeveloperStats() { // arrange var author = new Author { Name = "T-rav", Emails = new List <string> { "*****@*****.**", "*****@*****.**" } }; var repoPath = TestRepoPath("git-test-operations"); var sut = new SourceControlAnalysisBuilder() .WithPath(repoPath) .WithBranch("origin/my-branch") .WithEntireHistory() .Build(); // act var actual = sut.Build_Individual_Developer_Stats(new List <Author> { author }); // assert var expected = new List <DeveloperStats> { new DeveloperStats { Author = author, ActiveDaysPerWeek = 0.25, PeriodActiveDays = 2, CommitsPerDay = 3.0, Impact = 0.04, LinesOfChangePerHour = 0.36, LinesAdded = 24, LinesRemoved = 5, Churn = 0.21, Rtt100 = 277.78, Ptt100 = 416.67 } }; actual.Should().BeEquivalentTo(expected); }
public void WhenDeveloperMadeFirstCommit_ShouldReturnStats() { // arrange var author = new Author { Name = "T-rav", Emails = new List <string> { "*****@*****.**" } }; var repoPath = TestRepoPath("git-test-operations"); var sut = new SourceControlAnalysisBuilder() .WithPath(repoPath) .WithRange(DateTime.Parse("2018-07-16"), DateTime.Parse("2018-07-16")) .WithWorkingDaysPerWeek(4) .WithWorkingWeekHours(32) .Build(); // act var actual = sut.Build_Individual_Developer_Stats(new List <Author> { author }); // assert var expected = new List <DeveloperStats> { new DeveloperStats { Author = author, ActiveDaysPerWeek = 1.0, PeriodActiveDays = 1, CommitsPerDay = 3.0, Impact = 0.0, LinesOfChangePerHour = 0.06, LinesAdded = 2, LinesRemoved = 0, Churn = 0.0, Rtt100 = 1666.67, Ptt100 = 1666.67 } }; actual.Should().BeEquivalentTo(expected); }
public void WhenFolderIgnored_ShouldIgnoreFilesInFolderWhenCalculatingDeveloperStats() { // arrange var author = new Author { Name = "T-rav", Emails = new List <string> { "*****@*****.**" } }; var repoPath = TestRepoPath("git-test-operations"); var sut = new SourceControlAnalysisBuilder() .WithPath(repoPath) .WithIgnorePatterns(new[] { "documents", ".orig", "BASE", "LOCAL", "REMOTE" }) .WithRange(DateTime.Parse("2018-09-10"), DateTime.Parse("2018-09-13")) .Build(); // act var actual = sut.Build_Individual_Developer_Stats(new List <Author> { author }); // assert var expected = new List <DeveloperStats> { new DeveloperStats { Author = author, ActiveDaysPerWeek = 3.0, PeriodActiveDays = 3, CommitsPerDay = 1.67, Impact = 0.02, LinesOfChangePerHour = 0.12, LinesAdded = 10, LinesRemoved = 4, Churn = 0.4, Rtt100 = 833.33, Ptt100 = 2000.0 } }; actual.Should().BeEquivalentTo(expected); }
public void WhenBranchSelected_ShouldReturnAllActiveDeveloperForBranch() { // arrange var repoPath = TestRepoPath("git-test-operations"); var author = new Author { Name = "T-rav", Emails = new List <string> { "*****@*****.**" } }; var sut = new SourceControlAnalysisBuilder() .WithPath(repoPath) .WithBranch("origin/my-branch") .WithRange(DateTime.Parse("2018-07-16"), DateTime.Parse("2018-09-10")) .Build(); // act var actual = sut.Build_Individual_Developer_Stats(new List <Author> { author }); // assert var expected = new List <DeveloperStats> { new DeveloperStats { Author = author, ActiveDaysPerWeek = 0.25, PeriodActiveDays = 2, CommitsPerDay = 2.5, Impact = 0.03, LinesOfChangePerHour = 0.31, LinesAdded = 20, LinesRemoved = 5, Churn = 0.25, Rtt100 = 322.58, Ptt100 = 526.32 } }; actual.Should().BeEquivalentTo(expected); }
private static int DisplayRangedHistory(RangedHistory opts) { using (var repo = new SourceControlAnalysisBuilder() .WithPath(opts.Path) .WithRange(opts.StartDate, opts.EndDate) .WithIgnorePatterns(opts.IgnorePatterns) .WithBranch(opts.Branch) .WithWeekends(opts.WeekendDays) .WithWorkingDaysPerWeek(opts.WorkingDaysPerWeek) .WithWorkingWeekHours(opts.WorkingHoursPerWeek) .WithIgnoreComments(opts.IgnoreComments) .Build()) { var dashboard = new CodeStatsDashboard(); var authors = repo.List_Authors(); var stats = repo.Build_Individual_Developer_Stats(authors); var teamStats = repo.Build_Team_Stats(); dashboard.RenderDashboard(stats, teamStats, repo.ReportingRange); return(1); } }
public void WhenEntireHistory_ShouldReturnDeveloperStatsForLifetimeOfBranch() { // arrange var author = new Author { Name = "T-rav", Emails = new List <string> { "*****@*****.**" } }; var repoPath = TestRepoPath("git-test-operations"); var sut = new SourceControlAnalysisBuilder() .WithPath(repoPath) .WithEntireHistory() .Build(); // act var actual = sut.Build_Individual_Developer_Stats(new List <Author> { author }); // assert var expected = new List <DeveloperStats> { new DeveloperStats { Author = author, ActiveDaysPerWeek = 0.6, PeriodActiveDays = 6, CommitsPerDay = 1.83, Impact = 1.63, LinesOfChangePerHour = 0.33, LinesAdded = 69, LinesRemoved = 10, Churn = 0.14, Rtt100 = 303.03, Ptt100 = 400.0 } }; actual.Should().BeEquivalentTo(expected); }
private static int DisplayFullHistory(FullHistory opts) { using (var repo = new SourceControlAnalysisBuilder() .WithPath(opts.Path) .WithEntireHistory() .WithIgnorePatterns(opts.IgnorePatterns) .WithBranch(opts.Branch) .WithWeekends(opts.WeekendDays) .WithWorkingDaysPerWeek(opts.WorkingDaysPerWeek) .WithWorkingWeekHours(opts.WorkingHoursPerWeek) .WithIgnoreComments(opts.IgnoreComments) .Build()) { // todo : make configurable //var aliasMap = new List<Alias> //{ // new Alias{ // Name = "T-rav", // Emails = new List<string>{ // "*****@*****.**", // "*****@*****.**", // "*****@*****.**"} // } //}; // todo : wip, first attempt to make aliases confiurable //var aliasRepository = new AliasRepository(opts.AliasFile); //var aliasMap = aliasRepository.Load(); var dashboard = new CodeStatsDashboard(); var authors = repo.List_Authors(); var stats = repo.Build_Individual_Developer_Stats(authors); var teamStats = repo.Build_Team_Stats(); dashboard.RenderDashboard(stats, teamStats, repo.ReportingRange); } return(1); }