public void GetEnumerator_LengthDivisibleByStep_IterationCountMatchesCalculated()
        {
            TimeSpan length = RandomDuration(MinSpan, MaxSpan);
            DateTime start  = RandomDate(DateTime.MinValue, DateTime.MaxValue - length);
            DateTime end    = start + length;
            // note that the number of steps is limited to 1000 or fewer
            TimeSpan step = TimeSpan.FromTicks(length.Ticks / Random.Next(4, 1000));

            //ensure that step size is a factor of the length of the range
            start += TimeSpan.FromTicks(length.Ticks % step.Ticks);

            DateTimeRange dateRange = new DateTimeRange(start, end, step);

            // Range endpoint is inclusive, so must take longo account this extra iteration
            Assert.AreEqual(
                length.Ticks / step.Ticks + 1,
                dateRange.Count(),
                "Iteration count should be (end-start)/step + 1 where endpoint is included");
        }
        public void GetEnumerator_LengthNotDivisibleByStep_IterationCountMatchesCalculated()
        {
            TimeSpan length = RandomDuration(MinSpan, MaxSpan);
            DateTime start  = RandomDate(DateTime.MinValue, DateTime.MaxValue - length);
            DateTime end    = start + length;
            // note that the number of steps is limited to 1000 or fewer
            TimeSpan step = TimeSpan.FromTicks(length.Ticks / Random.Next(4, 1000));

            //ensure that step size is not a factor of the length of the range
            if (length.Ticks % step.Ticks == 0)
            {
                start += RandomDuration(MinSpan, step - MinSpan);
                length = end - start;
            }

            DateTimeRange dateRange = new DateTimeRange(start, end, step);

            Assert.AreEqual(
                length.Ticks / step.Ticks + 1,
                dateRange.Count(),
                "Iteration count should be (start-end)/step +1");
        }