コード例 #1
0
        public void WeeklyRule_OnlyEndTime_MustHaveSpecifiedStatusFromMidnightToEndTime()
        {
            var rule = new WeeklyRule(DayOfWeek.Tuesday, AvailabilityStatus.Booked, endTime: new TimeSpan(10, 30, 00));

            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14, 00, 00, 00), null) == AvailabilityStatus.Booked);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14, 08, 00, 00), null) == AvailabilityStatus.Booked);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14, 10, 30, 00), null) == AvailabilityStatus.Undefined);
        }
コード例 #2
0
        public void WeeklyRule_OnlyTime_MustHaveSpecifiedStatusOnlyAtThisTime()
        {
            var rule = new WeeklyRule(DayOfWeek.Tuesday, AvailabilityStatus.Booked, time: new TimeSpan(10, 30, 00));

            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14, 10, 30, 00), null) == AvailabilityStatus.Booked);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14, 09, 00, 00), null) == AvailabilityStatus.Undefined);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14, 10, 31, 00), null) == AvailabilityStatus.Undefined);
        }
コード例 #3
0
        public void WeeklyRuleStartDateTest()
        {
            var rule = new WeeklyRule(DayOfWeek.Tuesday, AvailabilityStatus.NotBookable, startDate: new DateTime(2017, 3, 14));

            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 3, 7), null) == AvailabilityStatus.Undefined);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 3, 14), null) == AvailabilityStatus.NotBookable);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 3, 21), null) == AvailabilityStatus.NotBookable);
            Assert.IsTrue(rule.GetStatus(new DateTime(2018, 3, 20), null) == AvailabilityStatus.NotBookable);
            Assert.IsTrue(rule.GetStatus(new DateTime(2018, 3, 21), null) == AvailabilityStatus.Undefined);
        }
コード例 #4
0
        public void WeeklyRule_TimeAndEndTime_MustHaveSpecifiedStatusBetweenThisTimes()
        {
            var startTime = new TimeSpan(08, 30, 00);
            var endTime   = new TimeSpan(10, 45, 00);

            var rule = new WeeklyRule(DayOfWeek.Tuesday, AvailabilityStatus.Free, time: startTime, endTime: endTime);

            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14, 08, 30, 00), null) == AvailabilityStatus.Free);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14, 09, 45, 00), null) == AvailabilityStatus.Free);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14, 10, 45, 00), null) == AvailabilityStatus.Undefined);
        }
コード例 #5
0
        public void WeeklyRule_NoEventIdsSpecified_MustHaveSpecifiedStatusAtAllEvents()
        {
            var rule = new WeeklyRule(DayOfWeek.Tuesday, AvailabilityStatus.Free, eventIds: null);

            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14), new Event {
                Id = 3
            }) == AvailabilityStatus.Free);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14), new Event {
                Id = 4
            }) == AvailabilityStatus.Free);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14), new Event {
                Id = 5
            }) == AvailabilityStatus.Free);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14), new Event {
                Id = 2
            }) == AvailabilityStatus.Free);
        }
コード例 #6
0
        public void WeeklyRule_EmptyEventIdList_MustHaveSpecifiedStatusAtAllEvents()
        {
            var eventIds = new List <int> {
            };

            var rule = new WeeklyRule(DayOfWeek.Tuesday, AvailabilityStatus.Free, eventIds: eventIds);

            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14), new Event {
                Id = 3
            }) == AvailabilityStatus.Free);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14), new Event {
                Id = 4
            }) == AvailabilityStatus.Free);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14), new Event {
                Id = 5
            }) == AvailabilityStatus.Free);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14), new Event {
                Id = 2
            }) == AvailabilityStatus.Free);
        }
コード例 #7
0
        public void WeeklyRule_2EventIds_MustHaveSpecifiedStatusOnlyAtTheseEvents()
        {
            var eventIds = new List <int> {
                3, 4
            };

            var rule = new WeeklyRule(DayOfWeek.Tuesday, AvailabilityStatus.Free, eventIds: eventIds);

            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14), new Event {
                Id = 3
            }) == AvailabilityStatus.Free);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14), new Event {
                Id = 4
            }) == AvailabilityStatus.Free);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14), new Event {
                Id = 5
            }) == AvailabilityStatus.Undefined);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 11, 14), new Event {
                Id = 2
            }) == AvailabilityStatus.Undefined);
        }
コード例 #8
0
        public void WeeklyRuleTimeTest()
        {
            var rule = new WeeklyRule(DayOfWeek.Thursday, AvailabilityStatus.Free, new TimeSpan(10, 30, 0));

            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 2, 2, 10, 0, 0), null) == AvailabilityStatus.Undefined);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 2, 2, 10, 29, 0), null) == AvailabilityStatus.Undefined);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 2, 2, 10, 30, 0), null) == AvailabilityStatus.Free);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 2, 2, 10, 31, 0), null) == AvailabilityStatus.Undefined);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 2, 2, 20, 30, 0), null) == AvailabilityStatus.Undefined);
            Assert.IsTrue(rule.GetStatus(new DateTime(2017, 3, 2, 10, 30, 0), null) == AvailabilityStatus.Free);
        }
コード例 #9
0
        public void WeeklyRuleWholeDayTest()
        {
            var rule = new WeeklyRule(DayOfWeek.Wednesday, AvailabilityStatus.Booked);

            Assert.IsTrue(rule.GetStatus(new DateTime(2016, 10, 31), null) == AvailabilityStatus.Undefined);
            Assert.IsTrue(rule.GetStatus(new DateTime(2016, 11, 2), null) == AvailabilityStatus.Booked);
            Assert.IsTrue(rule.GetStatus(new DateTime(2016, 11, 3), null) == AvailabilityStatus.Undefined);
            Assert.IsTrue(rule.GetStatus(new DateTime(2016, 11, 4), null) == AvailabilityStatus.Undefined);
            Assert.IsTrue(rule.GetStatus(new DateTime(2016, 11, 5), null) == AvailabilityStatus.Undefined);
            Assert.IsTrue(rule.GetStatus(new DateTime(2016, 11, 6), null) == AvailabilityStatus.Undefined);
        }