Exemplo n.º 1
0
        public void SplitsDateRangeWeekdaysThrowsIfBatchSizeIsGreaterThanFice()
        {
            DateTime start     = new DateTime(2018, 01, 01);
            DateTime end       = new DateTime(2018, 02, 25);
            int      batchSize = 6;

            Assert.Throws <ArgumentOutOfRangeException>(() => DateRangeSplitter.SplitDateRangeWeekDays(start, end, batchSize).ToList());
        }
Exemplo n.º 2
0
        public void SplitsDateRangeThrowsIfBatchSizeIsNegative()
        {
            DateTime start     = new DateTime(2018, 01, 01);
            DateTime end       = new DateTime(2018, 02, 25);
            int      batchSize = -1;

            Assert.Throws <ArgumentOutOfRangeException>(() => DateRangeSplitter.SplitDateRange(start, end, batchSize).ToList());
        }
Exemplo n.º 3
0
        public void SplitsDateRangeThrowIfEndDateIsGreaterThanStartDate()
        {
            DateTime start     = new DateTime(2018, 02, 25);
            DateTime end       = new DateTime(2018, 01, 01);
            int      batchSize = 7;

            Assert.Throws <ArgumentException>(() => DateRangeSplitter.SplitDateRange(start, end, batchSize).ToList());
        }
        public void DateRangeSplitterSplitsFiveHundredYearWeekDayRange()
        {
            DateTime start = new DateTime(2000, 1, 1);
            DateTime end   = start.AddYears(500);

            var range = DateRangeSplitter.SplitDateRangeWeekDays(start, end, 5)
                        .ToList();

            Assert.IsNotEmpty(range);
        }
        public void DateRangeSplitterSplitsTenYearRange()
        {
            DateTime start = new DateTime(2000, 1, 1);
            DateTime end   = start.AddYears(10);

            var range = DateRangeSplitter.SplitDateRange(start, end, 5)
                        .ToList();

            Assert.IsNotEmpty(range);
        }
Exemplo n.º 6
0
        public void SplitDateRangeSplitsDatesIntoBatches()
        {
            DateTime start     = new DateTime(2018, 01, 01);
            DateTime end       = new DateTime(2018, 02, 25);
            int      batchSize = 7;

            var batches = DateRangeSplitter.SplitDateRange(start, end, batchSize).ToList();

            Assert.AreEqual(7, batches.Count);
        }
Exemplo n.º 7
0
        public void SplitsDateRangeWeekdaysSplitsBatchSizeOfFiveIntoExpectedBatches()
        {
            DateTime start     = new DateTime(2018, 10, 29);
            DateTime end       = new DateTime(2018, 11, 27);
            int      batchSize = 5;

            var batches = DateRangeSplitter.SplitDateRangeWeekDays(start, end, batchSize).ToList();

            Assert.AreEqual(5, batches.Count);
        }
Exemplo n.º 8
0
        public void SplitsDateRangeWeekdaysSplitsBatchSizeOfFive()
        {
            DateTime start     = new DateTime(2018, 10, 29);
            DateTime end       = new DateTime(2018, 11, 27);
            int      batchSize = 5;

            var batches = DateRangeSplitter.SplitDateRangeWeekDays(start, end, batchSize).ToList();

            Assert.IsNotNull(batches);
        }
Exemplo n.º 9
0
        public void SplitDateRangeWeekDaysSplitsBatchForBatchSizeOfFourIntoExpectedNumberOfBatches()
        {
            DateTime start     = new DateTime(2018, 10, 29);
            DateTime end       = new DateTime(2018, 11, 27);
            int      batchSize = 4;

            var batches = DateRangeSplitter.SplitDateRangeWeekDays(start, end, batchSize).ToList();

            Assert.IsNotNull(batches);
            Assert.AreEqual(9, batches.Count);
        }
Exemplo n.º 10
0
        public void SplitDateRangeReturnsSingleBatchIfRangeIsLessThanBatchSize()
        {
            DateTime start     = new DateTime(2018, 01, 01);
            DateTime end       = new DateTime(2018, 01, 05);
            int      batchSize = 7;

            var batches = DateRangeSplitter.SplitDateRange(start, end, batchSize).ToList();

            Assert.AreEqual(1, batches.Count);
            Assert.AreEqual(new DateTime(2018, 01, 01), batches[0].Item1);
            Assert.AreEqual(new DateTime(2018, 01, 05), batches[0].Item2);
        }
Exemplo n.º 11
0
        public void SplitDateRangeWeekDaysExcludesEndDateIfEndDateIsWeekend()
        {
            DateTime start     = new DateTime(2018, 01, 06);
            DateTime end       = new DateTime(2018, 02, 25);
            int      batchSize = 5;

            var batches = DateRangeSplitter.SplitDateRangeWeekDays(start, end, batchSize).ToList();

            Assert.IsNotNull(batches);
            Assert.AreEqual(7, batches.Count);
            Assert.AreNotEqual(end, batches[batches.Count - 1].Item2);
        }
Exemplo n.º 12
0
        public void SplitDateRangeSplitsDatesIntoExpectedEndBatchIfBatchIsSmallerThanBatchSize()
        {
            DateTime start     = new DateTime(2018, 01, 01);
            DateTime end       = new DateTime(2018, 02, 26);
            int      batchSize = 7;

            var batches = DateRangeSplitter.SplitDateRange(start, end, batchSize).ToList();

            var lastBatch = batches[batches.Count - 1];

            Assert.AreEqual(new DateTime(2018, 02, 26), lastBatch.Item1);
            Assert.AreEqual(new DateTime(2018, 02, 26), lastBatch.Item2);
        }
Exemplo n.º 13
0
        public void SplitDateRangeSplitsDateIntoExpectedStartBatch()
        {
            DateTime start     = new DateTime(2018, 01, 01);
            DateTime end       = new DateTime(2018, 02, 25);
            int      batchSize = 7;

            var batches = DateRangeSplitter.SplitDateRange(start, end, batchSize).ToList();

            var firstBatch = batches[0];

            Assert.AreEqual(new DateTime(2018, 01, 01), firstBatch.Item1);
            Assert.AreEqual(new DateTime(2018, 01, 08), firstBatch.Item2);
        }
Exemplo n.º 14
0
        public void SplitsDateRangeWeekdaysSplitsBatchSizeOfFiveIntoExpectedFirstBatchIfFirstDayIsSunday()
        {
            DateTime start     = new DateTime(2018, 10, 28);
            DateTime end       = new DateTime(2018, 11, 27);
            int      batchSize = 5;

            var batches = DateRangeSplitter.SplitDateRangeWeekDays(start, end, batchSize).ToList();

            var firstBatch = batches[0];

            Assert.AreEqual(new DateTime(2018, 10, 29), firstBatch.Item1);
            Assert.AreEqual(new DateTime(2018, 11, 02), firstBatch.Item2);
        }
Exemplo n.º 15
0
        public void SplitsDateRangeWeekdaysSplitsBatchSizeOfFiveIntoExpectedLastBatch()
        {
            DateTime start     = new DateTime(2018, 10, 29);
            DateTime end       = new DateTime(2018, 11, 27);
            int      batchSize = 5;

            var batches = DateRangeSplitter.SplitDateRangeWeekDays(start, end, batchSize).ToList();

            var lastBatch = batches[batches.Count - 1];

            Assert.AreEqual(new DateTime(2018, 11, 26), lastBatch.Item1);
            Assert.AreEqual(new DateTime(2018, 11, 27), lastBatch.Item2);
        }