예제 #1
0
        public async Task GetHoursSummary_summarizesHoursCorrectly()
        {
            int    testMonth = Convert.ToInt32(DateTime.UtcNow.Month.ToString());
            string monthName = DateTime.UtcNow.ToString("MMMM");

            var utcNowYear = DateTime.UtcNow.Year;
            var dateBefore = new DateTime(2018, 11, 30);
            var dateAfter  = new DateTime(utcNowYear, testMonth, 2);
            await entryService.CreateBillableTimeEntry(dateBefore, 7, 1);

            await entryService.CreateNonBillableTimeEntry(dateBefore.AddDays(-1), 5, null,
                                                          TimeEntryTypeEnum.Vacation);

            await entryService.CreateBillableTimeEntry(dateAfter, 4, 1);

            await entryService.CreateBillableTimeEntry(dateAfter.AddDays(1), 8, 1);

            await entryService.CreateBillableTimeEntry(dateAfter.AddDays(2), 8, 1);

            await entryService.CreateBillableTimeEntry(dateAfter.AddMonths(-1), 8, 1);

            await entryService.CreateNonBillableTimeEntry(dateAfter.AddDays(15), 5, null,
                                                          TimeEntryTypeEnum.Vacation);

            await entryService.CreateNonBillableTimeEntry(dateAfter.AddDays(16), 6, "dr visit",
                                                          TimeEntryTypeEnum.Sick);

            await entryService.CreateNonBillableTimeEntry(dateAfter.AddDays(17), 7, "PDA",
                                                          TimeEntryTypeEnum.NonBillable);

            var hours = await userReportService.GetHoursSummaryDefaultWeekMonthAndYtd();

            hours.CurrentMonthDisplay.Should().Be($"{monthName} {utcNowYear}");
            hours.BillableHoursMonth.Should().Be(20d);
            hours.BillableHoursYtd.Should().Be(28d);

            hours.SickHoursMonth.Should().Be(6d);
            hours.VacationHoursMonth.Should().Be(5d);
            hours.NonBillableHoursMonth.Should().Be(7d);

            hours.SickHoursYtd.Should().Be(6d);
            hours.VacationHoursYtd.Should().Be(5d);
            hours.NonBillableHoursYtd.Should().Be(7d);
        }
예제 #2
0
        private static async Task <SlackMessageResponse> GenerateDefaultReport(UserReportService userReportSvc)
        {
            TimeEntryReport report = await userReportSvc.GetHoursSummaryDefaultWeekMonthAndYtd();

            return(new SlackMessageResponse(report.ToWeekMonthAndYTDMessage(), true));
        }