public void can_tell_timespan()
        {
            var timeSpan = new ScheduleTimeSpan(8M, 9M);
            var subject = new ProviderLocationSchedule(timeSpan);

            Assert.IsTrue(subject.TimeSpan.Equals(timeSpan));
        }
        public void adds_new_schedule()
        {
            //setup
            var timeSpan = new ScheduleTimeSpan(8M, 9M);

            var timeSpanDto = new ScheduleTimeSpanDto();
            timeSpanDto.OpenTime = timeSpan.OpenTime;
            timeSpanDto.OpenHours = timeSpan.OpenHours;

            var request = new AddProviderOrgUnitScheduleRequest();
            request.ProviderOrgUnitId = _ProviderOrgUnitId_NoExistingSchedules;
            request.TimeSpan = timeSpanDto;

            //act
            var response = HandleRequest<AddProviderOrgUnitScheduleResponse>(CreateHandler(), request);

            //assert
            using (var context = _objectContextFactory.CreateObjectContext())
            {
                context.ContextOptions.LazyLoadingEnabled = true;
                context.ContextOptions.ProxyCreationEnabled = true;
                var ProviderOrgUnit = context.CreateObjectSet<ProviderOrgUnit>().Single(pl => pl.Id == _ProviderOrgUnitId_NoExistingSchedules);

                Assert.IsTrue(ProviderOrgUnit.Schedules.Count() == 1);

                var schedule = ProviderOrgUnit.Schedules.ElementAt(0);

                Assert.IsTrue(schedule.TimeSpan.Equals(timeSpan));
            }
        }
Exemplo n.º 3
0
        public void can_tell_timespan()
        {
            var timeSpan = new ScheduleTimeSpan(8M, 9M);
            var subject = new OrgUnitSchedule(timeSpan);

            Assert.IsTrue(subject.TimeSpan.Equals(timeSpan));
        }
        public void can_construct_from_timespan()
        {
            var timeSpan = new ScheduleTimeSpan(8M, 9M);
            var subject = new ProviderLocationSchedule(timeSpan);

            Assert.IsTrue(subject.OpenHours == timeSpan.OpenHours);
            Assert.IsTrue(subject.OpenTime == timeSpan.OpenTime);
        }
Exemplo n.º 5
0
 public void can_construct_valid_instance()
 {
     var openTime = 1M;
     var openHours = 3M;
     var subject = new ScheduleTimeSpan(openTime, openHours);
     Assert.IsTrue(openTime == subject.OpenTime);
     Assert.IsTrue(openHours == subject.OpenHours);
 }
Exemplo n.º 6
0
        public void can_determine_equality()
        {
            decimal openTime = 1M;
            decimal openHours = 10.5M;

            var subjectA = new ScheduleTimeSpan(openTime, openHours);
            var subjectB = new ScheduleTimeSpan(openTime, openHours);

            Assert.IsTrue(subjectA.Equals(subjectB));
        }
Exemplo n.º 7
0
        public void can_add_schedule()
        {
            var subject = CreateOrgUnit();

            var timeSpan = new ScheduleTimeSpan(8M, 9M);

            subject.AddSchedule(timeSpan);

            Assert.IsTrue(subject.Schedules.Count() == 1);
            Assert.IsTrue(subject.Schedules.ElementAt(0).TimeSpan.Equals(timeSpan));
        }
Exemplo n.º 8
0
        public void can_determine_inequality()
        {
            decimal openTimeA = 1M;
            decimal openHoursA = 2M;

            decimal openTimeB = 3M;
            decimal openHoursB = 4M;

            var subjectA = new ScheduleTimeSpan(openTimeA, openHoursA);
            var subjectB = new ScheduleTimeSpan(openTimeB, openHoursB);

            Assert.IsFalse(subjectA.Equals(subjectB));
        }
Exemplo n.º 9
0
        public void can_determine_inequality_same_end()
        {
            decimal openTimeA = 0M;
            decimal openHoursA = 10.5M;

            decimal openTimeB = 6M;
            decimal openHoursB = 10.5M;

            var subjectA = new ScheduleTimeSpan(openTimeA, openHoursA);
            var subjectB = new ScheduleTimeSpan(openTimeB, openHoursB);

            Assert.IsFalse(subjectA.Equals(subjectB));
        }
Exemplo n.º 10
0
 /// <summary>
 /// Adds the schedule.
 /// </summary>
 /// <param name="scheduleTimeSpan">The schedule time span.</param>
 public void AddSchedule(ScheduleTimeSpan scheduleTimeSpan)
 {
     if (scheduleTimeSpan == null)
     {
         throw new ArgumentNullException("scheduleTimeSpan");
     }
     if (Schedules.Count(pls => pls.TimeSpan.Equals(scheduleTimeSpan)) > 0)
     {
         throw new BusinessException("Cannot add duplicate schedule Time Spans.");
     }
     if (Schedules.Count(pls => pls.TimeSpan.Overlaps(scheduleTimeSpan)) > 0)
     {
         throw new BusinessException("Schedule Time Spans cannot overlap.");
     }
     Schedules.Add(new OrgUnitSchedule(scheduleTimeSpan));
 }
 public ProviderOrgUnitSchedule(ScheduleTimeSpan timeSpan)
     : this()
 {
     OpenTime = timeSpan.OpenTime;
     OpenHours = timeSpan.OpenHours;
 }
Exemplo n.º 12
0
 public void cannot_construct_with_negative_open_hours()
 {
     var openTime = 1M;
     var openHours = -1M;
     var subject = new ScheduleTimeSpan(openTime, openHours);
 }
Exemplo n.º 13
0
        /// <summary>
        /// Adds the schedule.
        /// </summary>
        /// <param name="scheduleTimeSpan">The schedule time span.</param>
        public ProviderOrgUnitSchedule AddSchedule(ScheduleTimeSpan scheduleTimeSpan)
        {
            if (scheduleTimeSpan == null)
            {
                throw new ArgumentNullException("scheduleTimeSpan");
            }
            if (Schedules.Count(pls => pls.TimeSpan.Equals(scheduleTimeSpan)) > 0)
            {
                throw new BusinessException("Cannot add duplicate schedule Time Spans.");
            }
            if (Schedules.Count(pls => pls.TimeSpan.Overlaps(scheduleTimeSpan)) > 0)
            {
                throw new BusinessException("Schedule Time Spans cannot overlap.");
            }

            var schedule = new ProviderOrgUnitSchedule(scheduleTimeSpan);
            Schedules.Add(schedule);

            return schedule;
        }
Exemplo n.º 14
0
        public void effective_schedule_when_custom_is_own_schedule()
        {
            var subject = CreateProviderOrgUnit();
            subject.OrgUnit.Schedules.Add(new OrgUnitSchedule(new ScheduleTimeSpan(8M, 9M)));

            var customTimeSpan1 = new ScheduleTimeSpan(24M, 8M);
            var customTimeSpan2 = new ScheduleTimeSpan(48M, 8M);
            subject.AddSchedule(customTimeSpan1);
            subject.AddSchedule(customTimeSpan2);

            var effectiveSchedule = subject.EffectiveSchedule;

            Assert.IsTrue(effectiveSchedule.Count() == 2);
            Assert.IsTrue(effectiveSchedule.ElementAt(0).Equals(customTimeSpan1));
        }
Exemplo n.º 15
0
        public void does_not_overlap()
        {
            var subject = new ScheduleTimeSpan(1M, 3M);

            var other = new ScheduleTimeSpan(4.1M, 6M);

            bool overlaps = subject.Overlaps(other);

            Assert.IsFalse(overlaps);
        }
Exemplo n.º 16
0
        public void does_not_overlap_adjacent_beginning()
        {
            var subject = new ScheduleTimeSpan(2M, 3M);

            var other = new ScheduleTimeSpan(1M, 1M);

            bool overlaps = subject.Overlaps(other);

            Assert.IsFalse(overlaps);
        }
Exemplo n.º 17
0
        public void overlaps_end()
        {
            var subject = new ScheduleTimeSpan(1M, 3M);

            var other = new ScheduleTimeSpan(3M, 2M);

            bool overlaps = subject.Overlaps(other);

            Assert.IsTrue(overlaps);
        }
Exemplo n.º 18
0
        public void overlaps_when_beginning_same()
        {
            var subject = new ScheduleTimeSpan(8M, 5M);

            var other = new ScheduleTimeSpan(8M, 10M);

            bool overlaps = subject.Overlaps(other);

            Assert.IsTrue(overlaps);
        }
Exemplo n.º 19
0
        public static void SetOrgUnitSchedules(ObjectContext context, OrgUnitV2 source, OrgUnit orgUnit)
        {
            //ignore null values
            if (source.OrgUnitHours == null)
                return;

            //remove all schedules, will re-add below
            orgUnit.Schedules.ToList().ForEach(context.DeleteObject);

            foreach (var item in source.OrgUnitHours)
            {
                var timeSpan = new ScheduleTimeSpan(ResolveOpenTime(item), ResolveOpenHours(item));
                orgUnit.AddSchedule(timeSpan);
            }
        }