Inheritance: HourTimeRange
Beispiel #1
0
        public void DefaultCalendarTest() {
            var now = ClockProxy.Clock.Now;
            var todayStart = now.Date;

            Enumerable
                .Range(0, TimeSpec.HoursPerDay)
                .RunEach(dayHour => {
                             var hourRange = new HourRange(todayStart.AddHours(dayHour));

                             hourRange.Year.Should().Be(todayStart.Year);
                             hourRange.Month.Should().Be(todayStart.Month);
                             hourRange.Month.Should().Be(todayStart.Month);
                             hourRange.Day.Should().Be(todayStart.Day);
                             hourRange.Hour.Should().Be(dayHour);
                             hourRange.Start.Should().Be(todayStart.AddHours(dayHour).Add(hourRange.TimeCalendar.StartOffset));
                             hourRange.End.Should().Be(todayStart.AddHours(dayHour + 1).Add(hourRange.TimeCalendar.EndOffset));
                         });
        }
Beispiel #2
0
        public void DefaultCalendarTest()
        {
            var now        = ClockProxy.Clock.Now;
            var todayStart = now.Date;

            Enumerable
            .Range(0, TimeSpec.HoursPerDay)
            .RunEach(dayHour => {
                var hourRange = new HourRange(todayStart.AddHours(dayHour));

                hourRange.Year.Should().Be(todayStart.Year);
                hourRange.Month.Should().Be(todayStart.Month);
                hourRange.Month.Should().Be(todayStart.Month);
                hourRange.Day.Should().Be(todayStart.Day);
                hourRange.Hour.Should().Be(dayHour);
                hourRange.Start.Should().Be(todayStart.AddHours(dayHour).Add(hourRange.TimeCalendar.StartOffset));
                hourRange.End.Should().Be(todayStart.AddHours(dayHour + 1).Add(hourRange.TimeCalendar.EndOffset));
            });
        }
Beispiel #3
0
        public void GetMinutesTest()
        {
            var hourRange = new HourRange();

            var minutes = hourRange.GetMinutes().ToTimePeriodCollection();

            minutes.Should().Not.Be.Null();
            minutes.Count.Should().Be(TimeSpec.MinutesPerHour);

            Enumerable
            .Range(0, minutes.Count)
            .RunEach(index => {
                var minute = (MinuteRange)minutes[index];

                minute.Start.Should().Be(hourRange.Start.AddMinutes(index));
                minute.UnmappedStart.Should().Be(hourRange.Start.AddMinutes(index));

                minute.End.Should().Be(minute.TimeCalendar.MapEnd(minute.Start.AddMinutes(1)));
                minute.UnmappedEnd.Should().Be(minute.Start.AddMinutes(1));
            });
        }
Beispiel #4
0
        public void AddHoursTest() {
            var now = ClockProxy.Clock.Now;
            var nowHour = now.TrimToMinute();
            var hourRange = new HourRange(now, TimeCalendar.NewEmptyOffset());

            hourRange.AddHours(0).Should().Be(hourRange);

            var previousHour = nowHour.AddHours(-1);

            hourRange.AddHours(-1).Year.Should().Be(previousHour.Year);
            hourRange.AddHours(-1).Month.Should().Be(previousHour.Month);
            hourRange.AddHours(-1).Day.Should().Be(previousHour.Day);
            hourRange.AddHours(-1).Hour.Should().Be(previousHour.Hour);

            var nextHour = nowHour.AddHours(1);

            hourRange.AddHours(1).Year.Should().Be(nextHour.Year);
            hourRange.AddHours(1).Month.Should().Be(nextHour.Month);
            hourRange.AddHours(1).Day.Should().Be(nextHour.Day);
            hourRange.AddHours(1).Hour.Should().Be(nextHour.Hour);
        }
Beispiel #5
0
        public void AddHoursTest()
        {
            var now       = ClockProxy.Clock.Now;
            var nowHour   = now.TrimToMinute();
            var hourRange = new HourRange(now, TimeCalendar.NewEmptyOffset());

            hourRange.AddHours(0).Should().Be(hourRange);

            var previousHour = nowHour.AddHours(-1);

            hourRange.AddHours(-1).Year.Should().Be(previousHour.Year);
            hourRange.AddHours(-1).Month.Should().Be(previousHour.Month);
            hourRange.AddHours(-1).Day.Should().Be(previousHour.Day);
            hourRange.AddHours(-1).Hour.Should().Be(previousHour.Hour);

            var nextHour = nowHour.AddHours(1);

            hourRange.AddHours(1).Year.Should().Be(nextHour.Year);
            hourRange.AddHours(1).Month.Should().Be(nextHour.Month);
            hourRange.AddHours(1).Day.Should().Be(nextHour.Day);
            hourRange.AddHours(1).Hour.Should().Be(nextHour.Hour);
        }
Beispiel #6
0
        public void InitValuesTest() {
            var now = ClockProxy.Clock.Now;
            var firstHour = now.TrimToMinute();
            var secondHour = firstHour.AddHours(1);

            var hour = new HourRange(now, TimeCalendar.NewEmptyOffset());

            hour.Start.Year.Should().Be(firstHour.Year);
            hour.Start.Month.Should().Be(firstHour.Month);
            hour.Start.Day.Should().Be(firstHour.Day);
            hour.Start.Hour.Should().Be(firstHour.Hour);
            hour.Start.Minute.Should().Be(0);
            hour.Start.Second.Should().Be(0);
            hour.Start.Millisecond.Should().Be(0);

            hour.End.Year.Should().Be(secondHour.Year);
            hour.End.Month.Should().Be(secondHour.Month);
            hour.End.Day.Should().Be(secondHour.Day);
            hour.End.Hour.Should().Be(secondHour.Hour);
            hour.End.Minute.Should().Be(0);
            hour.End.Second.Should().Be(0);
            hour.End.Millisecond.Should().Be(0);
        }
Beispiel #7
0
        public void InitValuesTest()
        {
            var now        = ClockProxy.Clock.Now;
            var firstHour  = now.TrimToMinute();
            var secondHour = firstHour.AddHours(1);

            var hour = new HourRange(now, TimeCalendar.NewEmptyOffset());

            hour.Start.Year.Should().Be(firstHour.Year);
            hour.Start.Month.Should().Be(firstHour.Month);
            hour.Start.Day.Should().Be(firstHour.Day);
            hour.Start.Hour.Should().Be(firstHour.Hour);
            hour.Start.Minute.Should().Be(0);
            hour.Start.Second.Should().Be(0);
            hour.Start.Millisecond.Should().Be(0);

            hour.End.Year.Should().Be(secondHour.Year);
            hour.End.Month.Should().Be(secondHour.Month);
            hour.End.Day.Should().Be(secondHour.Day);
            hour.End.Hour.Should().Be(secondHour.Hour);
            hour.End.Minute.Should().Be(0);
            hour.End.Second.Should().Be(0);
            hour.End.Millisecond.Should().Be(0);
        }
Beispiel #8
0
        public void GetNextHourTest()
        {
            var hourRange = new HourRange();

            hourRange.GetNextHour().Should().Be(hourRange.AddHours(1));
        }
Beispiel #9
0
        public void GetPreviousHourTest()
        {
            HourRange hourRange = new HourRange();

            Assert.AreEqual(hourRange.GetPreviousHour(), hourRange.AddHours(-1));
        }
Beispiel #10
0
 public void GetNextHourTest() {
     var hourRange = new HourRange();
     hourRange.GetNextHour().Should().Be(hourRange.AddHours(1));
 }
Beispiel #11
0
 public void GetPreviousHourTest() {
     HourRange hourRange = new HourRange();
     Assert.AreEqual(hourRange.GetPreviousHour(), hourRange.AddHours(-1));
 }
Beispiel #12
0
        public void GetMinutesTest() {
            var hourRange = new HourRange();

            var minutes = hourRange.GetMinutes().ToTimePeriodCollection();

            minutes.Should().Not.Be.Null();
            minutes.Count.Should().Be(TimeSpec.MinutesPerHour);

            Enumerable
                .Range(0, minutes.Count)
                .RunEach(index => {
                             var minute = (MinuteRange)minutes[index];

                             minute.Start.Should().Be(hourRange.Start.AddMinutes(index));
                             minute.UnmappedStart.Should().Be(hourRange.Start.AddMinutes(index));

                             minute.End.Should().Be(minute.TimeCalendar.MapEnd(minute.Start.AddMinutes(1)));
                             minute.UnmappedEnd.Should().Be(minute.Start.AddMinutes(1));
                         });
        }