Exemple #1
0
        public void UsageStatsTableViewModel_formats_week_interval_string_correctly()
        {
            // Given
            var dailyData = new[]
            {
                new PeriodOfActivity(
                    new DateInformation(DateTime.Parse("2002-02-01"), ReportInterval.Weeks),
                    null
                    ),
                new PeriodOfActivity(
                    new DateInformation(DateTime.Parse("2002-02-08"), ReportInterval.Weeks),
                    null
                    ),
                new PeriodOfActivity(
                    new DateInformation(DateTime.Parse("2002-02-15"), ReportInterval.Weeks),
                    null
                    ),
            };

            // When
            var model = new UsageStatsTableViewModel(
                dailyData,
                DateTime.Parse("2002-02-01"),
                DateTime.Parse("2002-02-15")
                );

            // Then
            model.Rows.ToList()[1].Period.Should().Be("Week commencing 8/02/2002");
        }
Exemple #2
0
        public void UsageStatsTableViewModel_formats_quarter_interval_string_correctly()
        {
            // Given
            var dailyData = new[]
            {
                new PeriodOfActivity(
                    new DateInformation(DateTime.Parse("2002-01-01"), ReportInterval.Quarters),
                    null
                    ),
                new PeriodOfActivity(
                    new DateInformation(DateTime.Parse("2002-04-01"), ReportInterval.Quarters),
                    null
                    ),
                new PeriodOfActivity(
                    new DateInformation(DateTime.Parse("2002-07-01"), ReportInterval.Quarters),
                    null
                    ),
            };

            // When
            var model = new UsageStatsTableViewModel(
                dailyData,
                DateTime.Parse("2002-02-02"),
                DateTime.Parse("2002-08-02")
                );

            // Then
            model.Rows.ToList()[1].Period.Should().Be("Quarter 2, 2002");
        }
Exemple #3
0
        public void UsageStatsTableViewModel_formats_boundary_period_strings_correctly()
        {
            // Given
            var dailyData = new[]
            {
                new PeriodOfActivity(
                    new DateInformation(DateTime.Parse("2002-01-01"), ReportInterval.Years),
                    null
                    ),
                new PeriodOfActivity(
                    new DateInformation(DateTime.Parse("2003-01-01"), ReportInterval.Years),
                    null
                    ),
                new PeriodOfActivity(
                    new DateInformation(DateTime.Parse("2004-01-01"), ReportInterval.Years),
                    null
                    ),
            };

            // When
            var model = new UsageStatsTableViewModel(
                dailyData,
                DateTime.Parse("2002-02-02"),
                DateTime.Parse("2004-02-02")
                );

            // Then
            model.Rows.First().Period.Should().Be("01/01/2004 to 02/02/2004");
            model.Rows.Last().Period.Should().Be("02/02/2002 to 31/12/2002");
        }
Exemple #4
0
        public void UsageStatsTableViewModel_reverses_data_in_time()
        {
            // Given
            var monthlyData = new[]
            {
                new PeriodOfActivity(
                    new DateInformation(DateTime.Parse("2001-01-01"), ReportInterval.Months),
                    1,
                    1,
                    1
                    ),
                new PeriodOfActivity(
                    new DateInformation(DateTime.Parse("2002-02-01"), ReportInterval.Months),
                    0,
                    0,
                    0
                    ),
            };

            // When
            var model = new UsageStatsTableViewModel(
                monthlyData,
                DateTime.Parse("2001-01-01"),
                DateTime.Parse("2002-02-01")
                );

            // Then
            model.Rows.First().Completions.Should().Be(0);
            model.Rows.Last().Completions.Should().Be(1);
        }
Exemple #5
0
        public void UsageStatsTableViewModel_formats_single_period_string_correctly()
        {
            // Given
            var dailyData = new[]
            {
                new PeriodOfActivity(
                    new DateInformation(DateTime.Parse("2002-01-01"), ReportInterval.Years),
                    null
                    ),
            };

            // When
            var model = new UsageStatsTableViewModel(
                dailyData,
                DateTime.Parse("2002-02-02"),
                DateTime.Parse("2002-02-03")
                );

            // Then
            model.Rows.Count().Should().Be(1);
            model.Rows.First().Period.Should().Be("02/02/2002 to 03/02/2002");
        }