public void ExecuteBatchesWithNullEntities()
        {
            // 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.ExecuteBatches(null, null));
        }
        public void ExecuteBatches()
        {
            // 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 = executor.ExecuteBatches(entities, TableOperation.Insert).ToList();

            // 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 void ExecuteBatchesEvenWhenNotEvaluated()
        {
            // 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
            // We don't evaluate the call as we're not interested in the resulting entities. This should still execute the operations.
            executor.ExecuteBatches(entities, TableOperation.Insert);

            // Assert
            cloudTableMock.Verify(t => t.ExecuteBatch(It.IsAny<TableBatchOperation>()));
        }