Пример #1
0
        public void HourlyWithNoStartEndTime()
        {
            var template = new HourlyScheduleTemplate(1);

            var actual = template.GetTimes();

            actual.Should().Equal(new Time[] {
                new Time(00, 00, 00),
                new Time(01, 00, 00),
                new Time(02, 00, 00),
                new Time(03, 00, 00),
                new Time(04, 00, 00),
                new Time(05, 00, 00),
                new Time(06, 00, 00),
                new Time(07, 00, 00),
                new Time(08, 00, 00),
                new Time(09, 00, 00),
                new Time(10, 00, 00),
                new Time(11, 00, 00),
                new Time(12, 00, 00),
                new Time(13, 00, 00),
                new Time(14, 00, 00),
                new Time(15, 00, 00),
                new Time(16, 00, 00),
                new Time(17, 00, 00),
                new Time(18, 00, 00),
                new Time(19, 00, 00),
                new Time(20, 00, 00),
                new Time(21, 00, 00),
                new Time(22, 00, 00),
                new Time(23, 00, 00)
            });
        }
Пример #2
0
        public void ValidateEveryHourNotLessThanZero()
        {
            var template = new HourlyScheduleTemplate(-1);

            var errors = template.Validate();

            errors.Should().BeEquivalentTo(new string[] { "Time must be less than 1 day" });
        }
Пример #3
0
        public void Every15Hours()
        {
            var template = new HourlyScheduleTemplate(15);

            var actual = template.GetTimes();

            actual.Should().Equal(new Time[] {
                new Time(00, 00, 00),
                new Time(15, 00, 00)
            });
        }
Пример #4
0
        public void ValidateFromTimeLessThanToTime()
        {
            var template = new HourlyScheduleTemplate(1);

            template.From(17, 00);
            template.To(9, 00);

            var errors = template.Validate();

            errors.Should().BeEquivalentTo(new string[] { "From time must be earlier than To Time" });
        }
Пример #5
0
        public void RecurranceGreaterThanOneDay()
        {
            var template = new HourlyScheduleTemplate(25);

            template.From(11, 00);
            template.To(14, 00);

            var actual = template.GetTimes();

            actual.Should().Equal(new Time[] {
                new Time(11, 00, 00)
            });
        }
Пример #6
0
        public void TwiceHourlyWithDifferentStartAndEndTimes()
        {
            var template = new HourlyScheduleTemplate(2);

            template.From(9, 05);
            template.To(17, 30);

            var actual = template.GetTimes();

            actual.Should().Equal(new Time[] {
                new Time(09, 05, 00),
                new Time(11, 05, 00),
                new Time(13, 05, 00),
                new Time(15, 05, 00),
                new Time(17, 05, 00)
            });
        }
Пример #7
0
        public void HourlyWithExactStartAndEndTimes()
        {
            var template = new HourlyScheduleTemplate();

            template.From(9, 00);
            template.To(17, 00);

            var actual = template.GetTimes();

            actual.Should().Equal(new Time[] {
                new Time(09, 00, 00),
                new Time(10, 00, 00),
                new Time(11, 00, 00),
                new Time(12, 00, 00),
                new Time(13, 00, 00),
                new Time(14, 00, 00),
                new Time(15, 00, 00),
                new Time(16, 00, 00),
                new Time(17, 00, 00)
            });
        }
Пример #8
0
        public void DailyEvery3HoursFrom9To19()
        {
            var dateTemplate = new DailyScheduleTemplate();
            var timeTemplate = new HourlyScheduleTemplate(3);

            timeTemplate.From(9, 00);
            timeTemplate.To(19, 00);
            var template = new ScheduleTemplate(dateTemplate, timeTemplate);

            var startDate = new DateTime(2019, 10, 23, 04, 34, 56);

            var schedule = new ScheduleInstance(template, startDate);

            schedule.Take(8).Should().Equal(new DateTime[] {
                new DateTime(2019, 10, 23, 09, 00, 00),
                new DateTime(2019, 10, 23, 12, 00, 00),
                new DateTime(2019, 10, 23, 15, 00, 00),
                new DateTime(2019, 10, 23, 18, 00, 00),
                new DateTime(2019, 10, 24, 09, 00, 00),
                new DateTime(2019, 10, 24, 12, 00, 00),
                new DateTime(2019, 10, 24, 15, 00, 00),
                new DateTime(2019, 10, 24, 18, 00, 00)
            });
        }