コード例 #1
0
        public void SplitToChunks(BatchTestCase batchCase)
        {
            //------------ Arrange
            var someList = new List <int>();

            for (var i = 0; i < batchCase.ListLength; i++)
            {
                someList.Add(i);
            }

            //------------ Act
            var batchedList = someList.SplitToChunks(batchCase.BatchSize).ToList();

            //------------ Assert
            batchedList.Count().Should().Be(batchCase.ExpectedBatches);
            batchedList.Sum(x => x.Count()).Should().Be(batchCase.ListLength);
        }
コード例 #2
0
        public void Batch(BatchTestCase batchCase)
        {
            //------------ Arrange
            var someList = new List <int>();

            for (var i = 0; i < batchCase.ListLength; i++)
            {
                someList.Add(i);
            }

            //------------ Act
            var batchedList = someList.Batch(batchCase.BatchSize).ToList();

            //------------ Assert
            var expected = batchCase.ListLength / batchCase.BatchSize + (batchCase.ListLength % batchCase.BatchSize == 0 ? 0 : 1);

            batchedList.Count().Should().Be(expected);
            batchedList.Sum(x => x.Count()).Should().Be(batchCase.ListLength);
        }