Handles entities batching in insert operations. http://msdn.microsoft.com/en-us/library/windowsazure/dd894038.aspx
Inheritance: ITableBatchPartitioner
        public void CreateBatchesFromShuffledSequenceWith2PartitionKeys()
        {
            // Arrange
            var partitioner = new TableBatchPartitioner();
            const int count = 300;
            IEnumerable<ITableEntity> entities = Enumerable
                .Range(0, count)
                .Select(p => (ITableEntity) new DynamicTableEntity(string.Format("PK{0}", p%2), p.ToString(CultureInfo.InvariantCulture)));

            // Act
            List<TableBatchOperation> batches = partitioner.GetBatches(entities, TableOperation.Insert).ToList();

            // Assert
            Assert.NotNull(batches);
            Assert.Equal(count, batches.Sum(p => p.Count));

            var fieldInfo = typeof(TableBatchOperation).GetField("partitionKey", BindingFlags.NonPublic | BindingFlags.Instance);

            var aggregateResult = batches.Select(p => fieldInfo != null ? new
                {
                    partitonKey = (string)fieldInfo.GetValue(p),
                    count = p.Count
                } : null)
                .OrderBy(p => p.partitonKey)
                .GroupBy(p => p.partitonKey)
                .ToList();

            Assert.Equal("PK0", aggregateResult[0].Key);
            Assert.Equal("PK1", aggregateResult[1].Key);
            Assert.Equal(100, aggregateResult[0].ElementAt(0).count);
            Assert.Equal(50, aggregateResult[0].ElementAt(1).count);
            Assert.Equal(100, aggregateResult[1].ElementAt(0).count);
            Assert.Equal(50, aggregateResult[1].ElementAt(1).count);
        }
        public void CreateBatchesFromSequencWithDifferentPartitionKeys()
        {
            // Arrange
            var partitioner = new TableBatchPartitioner();
            const int count = 200;
            IEnumerable<ITableEntity> entities = Enumerable
                .Range(0, count)
                .Select(p => (ITableEntity)new DynamicTableEntity(string.Format("PK{0}", p), string.Empty));

            // Act
            List<TableBatchOperation> batches = partitioner.GetBatches(entities, TableOperation.Insert).ToList();

            // Assert
            Assert.NotNull(batches);
            Assert.Equal(200, batches.Count);
        }
        /// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="cloudTable">Cloud table.</param>
        /// <param name="entityConverter">Entity converter.</param>
        public TableRequestExecutorFactory(ICloudTable cloudTable, ITableEntityConverter <T> entityConverter)
        {
            if (cloudTable == null)
            {
                throw new ArgumentNullException(nameof(cloudTable));
            }

            if (entityConverter == null)
            {
                throw new ArgumentNullException(nameof(entityConverter));
            }

            CloudTable       = cloudTable;
            _entityConverter = entityConverter;
            _partitioner     = new TableBatchPartitioner();
        }
        public void CreateBatchesWithNullEntitiesParameter()
        {
            // Arrange
            var partitioner = new TableBatchPartitioner();
            List<TableBatchOperation> batches = null;

            // Act
            Assert.Throws<ArgumentNullException>(() =>
                {
                    batches = partitioner.GetBatches(null, TableOperation.Insert).ToList();
                });

            // Assert
            Assert.Null(batches);
        }