private static int Display_Full_History(FullHistory opts) { var presenter = Create_Presenter(opts.Mode); var builder = new SourceControlAnalysisBuilder(); var statsUseCase = new FullStatsUseCase(builder); var inputTo = new FullStatsInput { Path = opts.Path, IgnorePatterns = opts.IgnorePatterns, Branch = opts.Branch, WeekDays = opts.WeekendDays, DaysPerWeek = opts.WorkingDaysPerWeek, HoursPerWeek = opts.WorkingHoursPerWeek, IgnoreComments = opts.IgnoreComments, AliasFile = opts.AliasFile, WeekendDays = opts.WeekendDays }; statsUseCase.Execute(inputTo, presenter); presenter.Render(); return(1); }
public void Execute_WhenRepoDetailsValid_ShouldReturnStats() { //---------------Arrange------------------ var inputTo = new FullStatsInput(); var author = new Author { Name = "test author", Emails = new List <string> { "*****@*****.**" } }; var developerStats = new List <TeamStats> { new TeamStats { ActiveDevelopers = 2, DateOf = DateTime.Parse("2018-10-10"), TotalCommits = 5 } }; var weekends = new List <DayOfWeek> { DayOfWeek.Saturday, DayOfWeek.Sunday }; var reportingRange = new ReportingPeriod { Start = DateTime.Parse("2018-10-05"), End = DateTime.Parse("2018-10-15") }; var presenter = new PropertyPresenter <CodeAnalysis, ErrorOutputMessage>(); var repo = Create_Valid_Repository_Mocks(author, reportingRange); var builder = Substitute.For <SourceControlAnalysisBuilder>(); builder .WithPath(Arg.Any <string>()) .WithEntireHistory() .WithIgnorePatterns(Arg.Any <IEnumerable <string> >()) .WithBranch(Arg.Any <string>()) .WithWorkingDaysPerWeek(Arg.Any <double>()) .WithWorkingWeekHours(Arg.Any <int>()) .WithIgnoreComments(Arg.Any <bool>()) .WithAliasMapping(Arg.Any <string>()) .WithWeekends(Arg.Any <IEnumerable <DayOfWeek> >()) .Build() .Returns(repo); var sut = new FullStatsUseCase(builder); //---------------Act---------------------- sut.Execute(inputTo, presenter); //---------------Assert------------------- var expected = new StatsOutput { Authors = new List <Author> { author }, DeveloperStats = new List <DeveloperStats> { new DeveloperStats { ActiveDaysPerWeek = 1.5, Author = author, Churn = 0.9, CommitsPerDay = 1.2, Impact = 9.9, LinesAdded = 10, LinesRemoved = 5, LinesOfChangePerHour = 2.2, PeriodActiveDays = 1, Ptt100 = 4.5, Rtt100 = 6.2 } }, DailyDeveloperStats = new List <DailyDeveloperStats> { new DailyDeveloperStats { Date = DateTime.Parse("2018-10-05"), Stats = new List <DeveloperStats> { } } }, TeamStats = new TeamStatsCollection(developerStats, weekends), ReportingRange = reportingRange }; presenter.SuccessContent.Should().BeEquivalentTo(expected); }