コード例 #1
0
        public string[] ComputeFreeSlots(Doctor doctor, DateTime date)
        {
            WorkingHours[] workingHours = GetWorkingHoursForDay(doctor, date);

            if (workingHours.Length == 0)
            {
                return(new string[0]);
            }

            List <int> freeSlots = GetFreeSlotsForDate(doctor, date);

            if (freeSlots.Count == 0)
            {
                return(new string[0]);
            }

            List <string> freeHours = new List <string>();

            foreach (int Slot in freeSlots)
            {
                freeHours.Add(SlotHelper.SlotToHour(Slot));
            }

            return(freeHours.ToArray());
        }
コード例 #2
0
 public string GetHoursStringForDayOfWeek(Doctor doctor, DayOfWeek dayOfWeek)
 {
     WorkingHours[] hours = GetWorkingHoursForDay(doctor, dayOfWeek);
     if (hours == null || hours.Length == 0)
     {
         return("Unavailable");
     }
     return(string.Join(", ",
                        hours.Select(h => SlotHelper.SlotToHour(h.StartSlot) + " - " + SlotHelper.SlotToHour(h.EndSlot))
                        ));
 }
コード例 #3
0
        public void SlotToHour_Full_Day_Slots_Should_Equal_DateTime_Reference()
        {
            // Arrange
            // 1 int = 15 minute slot; 96 slots = 24h
            const int slotCount = 96;

            string[] fullDayDateTimeReference = new string[slotCount];
            string[] fullDaySlots             = new string[slotCount];
            // Act
            for (int i = 0; i < slotCount; i++)
            {
                fullDaySlots[i]             = SlotHelper.SlotToHour(i);
                fullDayDateTimeReference[i] = DateTime.Now.Date.AddMinutes(i * 15).ToString("HH:mm");
            }
            // Assert
            for (int i = 0; i < slotCount; i++)
            {
                Assert.Equal(fullDaySlots[i], fullDayDateTimeReference[i]);
            }
        }
コード例 #4
0
 public List <string> GetFreeHoursForDate(Doctor doctor, DateTime date)
 {
     return(GetFreeSlotsForDate(doctor, date).Select(x => SlotHelper.SlotToHour(x)).ToList());
 }