public void ExecuteBatchesAsyncWithNullEntities()
        {
            // Arrange
            Mock <ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            Mock <ITableEntityConverter <Country> > entityConverterMock  = MocksFactory.GetTableEntityConverterMock <Country>();
            Mock <ITableBatchPartitioner>           batchPartitionerMock = MocksFactory.GetTableBatchPartitionerMock();
            var executor = new TableRequestSequentialExecutor <Country>(cloudTableMock.Object, entityConverterMock.Object, batchPartitionerMock.Object);

            // Act && Assert
            Assert.Throws <ArgumentNullException>(() => executor.ExecuteBatchesAsync(null, null, CancellationToken.None));
        }
        public async Task ExecuteBatchesAsync()
        {
            // Arrange
            Mock <ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            Mock <ITableEntityConverter <Country> > entityConverterMock  = MocksFactory.GetTableEntityConverterMock <Country>();
            Mock <ITableBatchPartitioner>           batchPartitionerMock = MocksFactory.GetTableBatchPartitionerMock();
            var executor = new TableRequestSequentialExecutor <Country>(cloudTableMock.Object, entityConverterMock.Object, batchPartitionerMock.Object);
            var entities = ObjectsFactory.GetCountries();

            // Act
            var result = await executor.ExecuteBatchesAsync(entities, TableOperation.Insert, CancellationToken.None);

            // Assert
            Assert.IsAssignableFrom <IEnumerable <Country> >(result);
            entityConverterMock.Verify(p => p.GetEntity(It.IsAny <Country>()), Times.Exactly(2));
            batchPartitionerMock.Verify(p => p.GetBatches(It.IsAny <IEnumerable <ITableEntity> >(), It.IsAny <Func <ITableEntity, TableOperation> >()), Times.Once());
        }
        public async Task ExecuteBatchesAsync()
        {
            // Arrange
            Mock<ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            Mock<ITableEntityConverter<Country>> entityConverterMock = MocksFactory.GetTableEntityConverterMock<Country>();
            Mock<ITableBatchPartitioner> batchPartitionerMock = MocksFactory.GetTableBatchPartitionerMock();
            var executor = new TableRequestSequentialExecutor<Country>(cloudTableMock.Object, entityConverterMock.Object, batchPartitionerMock.Object);
            var entities = ObjectsFactory.GetCountries();

            // Act
            var result = await executor.ExecuteBatchesAsync(entities, TableOperation.Insert, CancellationToken.None);

            // Assert
            Assert.IsAssignableFrom<IEnumerable<Country>>(result);
            entityConverterMock.Verify(p => p.GetEntity(It.IsAny<Country>()), Times.Exactly(2));
            batchPartitionerMock.Verify(p => p.GetBatches(It.IsAny<IEnumerable<ITableEntity>>(), It.IsAny<Func<ITableEntity, TableOperation>>()), Times.Once());
        }
        public Task ExecuteBatchesAsyncWithNullOperation()
        {
            // Arrange
            Mock<ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            Mock<ITableEntityConverter<Country>> entityConverterMock = MocksFactory.GetTableEntityConverterMock<Country>();
            Mock<ITableBatchPartitioner> batchPartitionerMock = MocksFactory.GetTableBatchPartitionerMock();
            var executor = new TableRequestSequentialExecutor<Country>(cloudTableMock.Object, entityConverterMock.Object, batchPartitionerMock.Object);
            var entities = ObjectsFactory.GetCountries();

            // Act && Assert
            return Assert.ThrowsAsync<ArgumentNullException>(() => executor.ExecuteBatchesAsync(entities, null, CancellationToken.None));
        }