//[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 WhenRangeOneDay_ShouldReturnStats() { // arrange 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_Team_Stats(); // assert var stats = new List <TeamStats> { new TeamStats { DateOf = DateTime.Parse("2018-07-16"), ActiveDevelopers = 1, TotalCommits = 3 } }; var expected = new TeamStatsCollection(stats, new List <DayOfWeek>()); actual.Should().BeEquivalentTo(expected); }
private static int Display_Ranged_History(RangedHistory opts) { var presenter = Create_Presenter(opts.Mode); var builder = new SourceControlAnalysisBuilder(); var statsUseCase = new RangedStatsUseCase(builder); var inputTo = new RangedStatsInput { Path = opts.Path, IgnorePatterns = opts.IgnorePatterns, Branch = opts.Branch, WeekDays = opts.WeekendDays, DaysPerWeek = opts.WorkingDaysPerWeek, HoursPerWeek = opts.WorkingHoursPerWeek, IgnoreComments = opts.IgnoreComments, AliasFile = opts.AliasFile, RangeState = opts.StartDate, RangeEnd = opts.EndDate, WeekendDays = opts.WeekendDays }; statsUseCase.Execute(inputTo, presenter); presenter.Render(); return(1); }
public void WhenUsingAlias_ShouldReturnSingleDeveloperWithTwoEmails() { // arrange var repoPath = TestRepoPath("git-test-operations"); var aliasMap = new List <Alias> { new Alias { Name = "T-rav", Emails = new List <string> { "*****@*****.**", "*****@*****.**" } } }; using (var aliasFileContext = WriteAliasMapping(aliasMap)) { var sut = new SourceControlAnalysisBuilder() .WithPath(repoPath) .WithEntireHistory() .WithBranch("origin/my-branch") .WithAliasMapping(aliasFileContext.Path) .Build(); // act var actual = sut.List_Authors(); // assert var expected = 1; actual.Count().Should().Be(expected); } }
public void WhenDeveloperBranch_ShouldReturnAllActiveDevelopers() { // arrange var repoPath = TestRepoPath("git-test-operations"); var sut = new SourceControlAnalysisBuilder() .WithPath(repoPath) .WithBranch("origin/my-branch") .WithRange(DateTime.Parse("2018-7-16"), DateTime.Parse("2018-07-17")) .Build(); // act var actual = sut.List_Authors(); // assert var expected = new List <Author> { new Author { Name = "T-rav", Emails = new List <string> { "*****@*****.**" } }, new Author { Name = "Travis", Emails = new List <string> { "*****@*****.**" } } }; actual.Should().BeEquivalentTo(expected); }
public void WhenNullIgnorePatterns_ShouldNotThrowException() { // arrange var repoPath = TestRepoPath("git-test-operations"); var sut = new SourceControlAnalysisBuilder() .WithPath(repoPath) .WithIgnorePatterns(null); // act // assert Assert.DoesNotThrow(() => sut.Build()); }
public void WhenPathNotValidGitRepo_ShouldThrowException() { // arrange var repoPath = "x:\\invalid_repo"; var builder = new SourceControlAnalysisBuilder() .WithPath(repoPath); // act var actual = Assert.Throws <Exception>(() => builder.Build()); // assert var expected = "Invalid path [x:\\invalid_repo]"; actual.Message.Should().Be(expected); }
public void WhenNullIgnorePatterns_ShouldNotThrowException() { // arrange var context = new RepositoryTestDataBuilder() .After_Init_Commit_To_Master() .Build(); var sut = new SourceControlAnalysisBuilder() .WithPath(context.Path) .WithIgnorePatterns(null); // act // assert Assert.DoesNotThrow(() => sut.Build()); }
public void WhenInvalidBranch_ShouldReturnDeveloperList() { // arrange var context = new RepositoryTestDataBuilder() .Build(); var sut = new SourceControlAnalysisBuilder() .WithPath(context.Path) .WithRange(DateTime.Parse("2018-06-25"), DateTime.Parse("2018-07-09")) .WithBranch("--Never-Existed--"); // act var actual = Assert.Throws <Exception>(() => sut.Build()); // assert actual.Message.Should().Be("Invalid branch [--Never-Existed--]"); }
public void WhenNullAliases_ShouldReturnTwoDevelopers() { // arrange var repoPath = TestRepoPath("git-test-operations"); var sut = new SourceControlAnalysisBuilder() .WithPath(repoPath) .WithEntireHistory() .WithBranch("origin/my-branch") .Build(); // act var actual = sut.List_Authors(); // assert var expected = 2; actual.Count().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 WhenNoRangeSpecified_ShouldUseRepositorysFirstAndLastCommitDates() { // arrange var repoPath = TestRepoPath("git-test-operations"); //var context = new RepositoryTestDataBuilder() // .With_Commit(new TestCommit { FileName = "file1.txt", Lines = new List<string> { "1", "2" }, TimeStamp = "2018-07-16" }) // .With_Commit(new TestCommit { FileName = "file2.txt", Lines = new List<string> { "3", "4" }, TimeStamp = "2018-09-13" }) // .Build(); var sut = new SourceControlAnalysisBuilder() .WithPath(repoPath) .WithEntireHistory() .Build(); // act var actual = sut.ReportingRange; // assert actual.Start.Should().Be(DateTime.Parse("2018-07-16")); actual.End.Should().Be(DateTime.Parse("2018-09-25")); }
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 WhenEmailNotForActiveDeveloper_ShouldReturnZero() { // arrange var repoPath = TestRepoPath("git-test-operations"); var author = new Author { Name = "no-one", Emails = new List <string> { "*****@*****.**" } }; var sut = new SourceControlAnalysisBuilder() .WithPath(repoPath) .Build(); // act var actual = sut.Period_Active_Days(author); // assert var expected = 0; actual.Should().Be(expected); }
public void WhenMaster_ShouldReturnActiveDays(DateTime start, DateTime end, int expected) { // arrange var repoPath = TestRepoPath("git-test-operations"); var author = new Author { Name = "T-rav", Emails = new List <string> { "*****@*****.**" } }; var sut = new SourceControlAnalysisBuilder() .WithRange(start, end) .WithPath(repoPath) .Build(); // act var actual = sut.Period_Active_Days(author); // assert actual.Should().Be(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 WhenDeveloperInactive_ShouldReturnZeroCommitsPerDay() { // arrange var author = new Author { Name = "boo", Emails = new List <string> { "*****@*****.**" } }; var repoPath = TestRepoPath("git-test-operations"); var sut = new SourceControlAnalysisBuilder() .WithPath(repoPath) .WithRange(DateTime.Parse("2018-06-25"), DateTime.Parse("2018-07-09")) .Build(); // act var actual = sut.Commits_Per_Day(author); // assert var expectedCommitsPerDay = 0.0; actual.Should().Be(expectedCommitsPerDay); }
public void WhenEmpyAliases_ShouldReturnTwoDevelopers() { // arrange var repoPath = TestRepoPath("git-test-operations"); var aliasMap = new List <Alias>(); using (var aliasFileContext = WriteAliasMapping(aliasMap)) { var sut = new SourceControlAnalysisBuilder() .WithPath(repoPath) .WithEntireHistory() .WithBranch("origin/my-branch") .WithAliasMapping(aliasFileContext.Path) .Build(); // act var actual = sut.List_Authors(); // assert var expected = 2; actual.Count().Should().Be(expected); } }
public void WhenDeveloperNotActiveDuringPeriod_ShouldReturnZero() { // arrange var author = new Author { Name = "Moo", Emails = new List <string> { "*****@*****.**" } }; var repoPath = TestRepoPath("git-test-operations"); var sut = new SourceControlAnalysisBuilder() .WithPath(repoPath) .WithRange(DateTime.Parse("2018-06-25"), DateTime.Parse("2018-07-09")) .Build(); // act var actual = sut.Active_Days_Per_Week(author); // assert var expectedActiveDaysPerWeek = 0.0; actual.Should().Be(expectedActiveDaysPerWeek); }
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); }
public void WhenNoRangeSpecified_ShouldUseRepositorysFirstAndLastCommitDates() { // arrange var commitBuilder = new CommitTestDataBuilder() .With_Author("bob", "*****@*****.**"); var commit1 = commitBuilder .With_File_Name("file1.txt") .With_File_Content("1", "2") .With_Commit_Timestamp("2018-07-16 01:01:01") .With_Commit_Message("it worked!") .Build(); var commit2 = commitBuilder .With_File_Name("file2.txt") .With_File_Content("3", "4") .With_Commit_Timestamp("2018-09-13 12:12:12") .With_Commit_Message("it worked again!") .Build(); var context = new RepositoryTestDataBuilder() .Make_Commit(commit1) .Make_Commit(commit2) .Build(); var sourceControlAnalysis = new SourceControlAnalysisBuilder() .WithPath(context.Path) .WithEntireHistory() .Build(); var sut = sourceControlAnalysis.Run_Analysis(); // act var actual = sut.AnalysisContext.ReportRange; // assert actual.Start.Should().Be(DateTime.Parse("2018-07-16")); actual.End.Should().Be(DateTime.Parse("2018-09-13")); }
public void WhenDeveloperActive_ShouldReturnCommitsPerDay() { // 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-10"), DateTime.Parse("2018-09-14")) .WithWorkingDaysPerWeek(4) .WithWorkingWeekHours(32) .Build(); // act var actual = sut.Commits_Per_Day(author); // assert var expectedCommitsPerDay = 1.67; actual.Should().Be(expectedCommitsPerDay); }
public RangedStatsUseCase(SourceControlAnalysisBuilder builder) { _builder = builder; }