コード例 #1
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" });
        }
コード例 #2
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)
            });
        }
コード例 #3
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)
            });
        }
コード例 #4
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)
            });
        }
コード例 #5
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)
            });
        }