Ejemplo n.º 1
0
        public void Execute(FullStatsInput inputTo, IRespondWithSuccessOrError <CodeAnalysis, ErrorOutputMessage> presenter)
        {
            using (var repo = _builder
                              .WithPath(inputTo.Path)
                              .WithEntireHistory()
                              .WithIgnorePatterns(inputTo.IgnorePatterns)
                              .WithBranch(inputTo.Branch)
                              .WithWorkingDaysPerWeek(inputTo.DaysPerWeek)
                              .WithWorkingWeekHours(inputTo.HoursPerWeek)
                              .WithIgnoreComments(inputTo.IgnoreComments)
                              .WithAliasMapping(inputTo.AliasFile)
                              .WithWeekends(inputTo.WeekendDays)
                              .Build())
            {
                //var authors = repo.List_Authors();
                //var stats = repo.Build_Individual_Developer_Stats(authors);
                //var dailyDeveloperStats = repo.Build_Daily_Individual_Developer_Stats(authors);
                //var teamStats = repo.Build_Team_Stats();

                var codeAnalysis = repo.Run_Analysis();

                // todo : use presenter to convert for output

                //var result = new StatsOutput
                //{
                //    Authors = authors,
                //    DeveloperStats = stats,
                //    DailyDeveloperStats = dailyDeveloperStats,
                //    TeamStats = teamStats,
                //    ReportingRange = repo.ReportingRange
                //};

                presenter.Respond(codeAnalysis);
            }
        }
Ejemplo n.º 2
0
Archivo: Program.cs Proyecto: T-rav/GD3
        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);
        }
Ejemplo n.º 3
0
        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);
        }