Example #1
0
            public void ReturnsZerosForEmptyListOfProjects()
            {
                var report = new ProjectSummaryReport(new ChartSegment[0]);

                report.TotalSeconds.Should().Be(0);
                report.BillablePercentage.Should().Be(0);
            }
Example #2
0
        private void onReport(ProjectSummaryReport report)
        {
            TotalTime          = TimeSpan.FromSeconds(report.TotalSeconds);
            BillablePercentage = report.TotalSeconds == 0 ? null : (float?)report.BillablePercentage;

            var segments = report.Segments.Select(segment => segment.WithDurationFormat(DurationFormat));

            Segments.AddRange(segments);
            IsLoading = false;

            RaisePropertyChanged(nameof(Segments));
        }
Example #3
0
            public void CalculatesTheTotalAmountOfSeconds(NonEmptyArray <NonNegativeInt> durations)
            {
                var actualDurations = durations.Get.Select(duration => duration.Get);
                var segments        = actualDurations
                                      .Select((index, duration) => getSegmentFromDurationAndIndex(index, duration))
                                      .ToArray();
                var expectedDuration = (float)segments.Select(s => s.TrackedTime.TotalSeconds).Sum();

                var report = new ProjectSummaryReport(segments);

                report.TotalSeconds.Should().Be(expectedDuration);
            }
Example #4
0
            public void CalculatesThePercentageOfBillable(NonEmptyArray <NonNegativeInt> durations)
            {
                var segments = durations.Get.Select(duration => duration.Get)
                               .Select((index, duration) => getSegmentFromDurationAndIndex(index, duration))
                               .ToArray();
                var   totalTrackedSeconds        = segments.Select(s => s.TrackedTime.TotalSeconds).Sum();
                var   billableSeconds            = segments.Select(s => s.BillableSeconds).Sum();
                float expectedBillablePercentage =
                    (float)(totalTrackedSeconds > 0 ? (100.0f / totalTrackedSeconds) * billableSeconds : 0);

                var report = new ProjectSummaryReport(segments);

                report.BillablePercentage.Should().Be(expectedBillablePercentage);
            }
Example #5
0
        private void onReport(ProjectSummaryReport report)
        {
            if (report == null)
            {
                isLoading.OnNext(false);
                trackReportsEvent(false);
                return;
            }

            totalTimeSubject.OnNext(TimeSpan.FromSeconds(report.TotalSeconds));
            billablePercentageSubject.OnNext(report.TotalSeconds is 0 ? null : (float?)report.BillablePercentage);
            segmentsSubject.OnNext(report.Segments);
            isLoading.OnNext(false);

            trackReportsEvent(true);
        }