Ejemplo n.º 1
0
 public void DividingEndOfTime()
 {
     var now = DateTimeOffset.MaxValue - TimeSpan.FromHours(1);
     var availableTime = new TimeRange(now, now.AddHours(1));
     var freeSlots = availableTime
         .Divide(TimeSpan.FromMinutes(15))
         .ToArray();
     Assert.AreEqual(4, freeSlots.Length);
     Assert.IsTrue(freeSlots.All(s => s.Duration == TimeSpan.FromMinutes(15)));
 }
Ejemplo n.º 2
0
        void Snippets()
        {
            #region Dividing
            var now = new DateTimeOffset(2013, 8, 13, 13, 0, 0, TimeSpan.FromHours(12));
            var availableTime = new TimeRange(now, now.AddHours(1));
            var freeSlots = availableTime.Divide(TimeSpan.FromMinutes(15));
            foreach (var freeSlot in freeSlots)
            {
                Console.WriteLine(freeSlot);
            }

            // Produces 4 15 minute time ranges.
            //
            // 13 Aug 2013 1:00:00 p.m. +12:00 for 00:15:00
            // 13 Aug 2013 1:15:00 p.m. +12:00 for 00:15:00
            // 13 Aug 2013 1:30:00 p.m. +12:00 for 00:15:00
            // 13 Aug 2013 1:45:00 p.m. +12:00 for 00:15:00
            #endregion
        }
Ejemplo n.º 3
0
 public void DividingNone()
 {
     var now = new DateTimeOffset(2013, 8, 13, 13, 0, 0, TimeSpan.FromHours(12));
     var availableTime = new TimeRange(now, now.AddMinutes(14));
     var freeSlots = availableTime
         .Divide(TimeSpan.FromMinutes(15))
         .ToArray();
     Assert.AreEqual(0, freeSlots.Length);
 }
Ejemplo n.º 4
0
 public void DividingUneven()
 {
     var now = new DateTimeOffset(2013, 8, 13, 13, 0, 0, TimeSpan.FromHours(12));
     var availableTime = new TimeRange(now, now.AddMinutes(59));
     var freeSlots = availableTime
         .Divide(TimeSpan.FromMinutes(15))
         .ToArray();
     Assert.AreEqual(3, freeSlots.Length);
     Assert.IsTrue(freeSlots.All(s => s.Duration == TimeSpan.FromMinutes(15)));
 }