예제 #1
0
        public void GetWorklogsTotalTimeSpent_Issue_ReturnsTotalTimeInSeconds()
        {
            // Arrange.
            IssueDto issue = new IssueDto();

            issue.Worklogs.Add(new WorklogDto {
                TimeSpentSeconds = 301
            });
            issue.Worklogs.Add(new WorklogDto {
                TimeSpentSeconds = 4505
            });
            issue.Worklogs.Add(new WorklogDto {
                TimeSpentSeconds = 1999
            });

            int excepted = 0;

            foreach (var worklog in issue.Worklogs)
            {
                excepted += worklog.TimeSpentSeconds;
            }

            // Act.
            int result = WorklogsTimeSpentCounter.GetTotalTime(issue);

            // Assert.
            Assert.Equal(excepted, result);
        }
예제 #2
0
        /// <summary>
        /// Method to build report as string.
        /// </summary>
        /// <returns>Report as string.</returns>
        public static string BuildStringReport(List <IssueDto> issues)
        {
            StringBuilder builder = new StringBuilder();

            string currentProjectKey = string.Empty;
            int    worklogsTotalTime;

            foreach (var issue in issues)
            {
                if (issue.ProjectKey != currentProjectKey)
                {
                    builder.Append($"\n{issue.ProjectKey} {issue.ProjectName}");
                    currentProjectKey = issue.ProjectKey;
                }

                worklogsTotalTime = WorklogsTimeSpentCounter.GetTotalTime(issue);

                if (worklogsTotalTime != 0)
                {
                    builder.AppendFormat($"\n\t{issue.IssueKey,-10} {issue.Summary,-50} \t{JiraTimeBuilder.BuildStringTime(worklogsTotalTime),15}");

                    if (issue.TimeEstimateSeconds != null)
                    {
                        builder.Append($" / {JiraTimeBuilder.BuildStringTime((int)issue.TimeEstimateSeconds),-15}");
                    }
                }
            }

            builder.Append($"\n\nTOTAL: {JiraTimeBuilder.BuildStringTime(IssuesTotalTimeCounter.GetTotalTime(issues))}");

            return(builder.ToString());
        }
        public void GetIssuesTotalTime_Issues_ReturnsTotalTimeInSeconds()
        {
            // Arrange.
            List <IssueDto> issues = new List <IssueDto>();

            IssueDto issueOne = new IssueDto();

            issueOne.Worklogs.Add(new WorklogDto {
                TimeSpentSeconds = 300
            });
            issueOne.Worklogs.Add(new WorklogDto {
                TimeSpentSeconds = 450
            });
            issueOne.Worklogs.Add(new WorklogDto {
                TimeSpentSeconds = 1010
            });

            IssueDto issueTwo = new IssueDto();

            issueTwo.Worklogs.Add(new WorklogDto {
                TimeSpentSeconds = 10
            });
            issueTwo.Worklogs.Add(new WorklogDto {
                TimeSpentSeconds = 399
            });
            issueTwo.Worklogs.Add(new WorklogDto {
                TimeSpentSeconds = 7079
            });

            issues.Add(issueOne);
            issues.Add(issueTwo);

            int excepted = 0;

            foreach (var issue in issues)
            {
                excepted += WorklogsTimeSpentCounter.GetTotalTime(issue);
            }

            // Act.
            int result = IssuesTotalTimeCounter.GetTotalTime(issues);

            // Assert.
            Assert.Equal(excepted, result);
        }