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

            // Act && Assert
            Assert.Throws <ArgumentNullException>(() => executor.ExecuteBatches(null, null));
        }
        public void ExecuteBatchesWithNullEntities()
        {
            // Arrange
            Mock<ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            Mock<ITableEntityConverter<Country>> entityConverterMock = MocksFactory.GetTableEntityConverterMock<Country>();
            Mock<ITableBatchPartitioner> batchPartitionerMock = MocksFactory.GetTableBatchPartitionerMock();
            var executor = new TableRequestParallelExecutor<Country>(cloudTableMock.Object, entityConverterMock.Object, batchPartitionerMock.Object);

            // Act && Assert
            Assert.Throws<ArgumentNullException>(() => executor.ExecuteBatches(null, null));
        }
        public Task ExecuteBatchesWithoutResultAsyncWithNullEntities()
        {
            // Arrange
            Mock <ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            Mock <ITableEntityConverter <Country> > entityConverterMock  = MocksFactory.GetTableEntityConverterMock <Country>();
            Mock <ITableBatchPartitioner>           batchPartitionerMock = MocksFactory.GetTableBatchPartitionerMock();
            var executor = new TableRequestParallelExecutor <Country>(cloudTableMock.Object, entityConverterMock.Object, batchPartitionerMock.Object);

            // Act && Assert
            return(Assert.ThrowsAsync <ArgumentNullException>(() => executor.ExecuteBatchesWithoutResultAsync(null, null, CancellationToken.None)));
        }
        public void CreateExecutor()
        {
            // Arrange
            Mock<ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            Mock<ITableEntityConverter<Country>> entityConverterMock = MocksFactory.GetTableEntityConverterMock<Country>();
            Mock<ITableBatchPartitioner> batchPartitionerMock = MocksFactory.GetTableBatchPartitionerMock();

            // Act
            var result = new TableRequestParallelExecutor<Country>(cloudTableMock.Object, entityConverterMock.Object, batchPartitionerMock.Object);

            // Assert
            Assert.NotNull(result);
        }
        public void CreateExecutor()
        {
            // Arrange
            Mock <ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            Mock <ITableEntityConverter <Country> > entityConverterMock  = MocksFactory.GetTableEntityConverterMock <Country>();
            Mock <ITableBatchPartitioner>           batchPartitionerMock = MocksFactory.GetTableBatchPartitionerMock();

            // Act
            var result = new TableRequestParallelExecutor <Country>(cloudTableMock.Object, entityConverterMock.Object, batchPartitionerMock.Object);

            // Assert
            Assert.NotNull(result);
        }
        public async Task ExecuteBatchesWithoutResultAsync()
        {
            // Arrange
            Mock <ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            Mock <ITableEntityConverter <Country> > entityConverterMock  = MocksFactory.GetTableEntityConverterMock <Country>();
            Mock <ITableBatchPartitioner>           batchPartitionerMock = MocksFactory.GetTableBatchPartitionerMock();
            var executor = new TableRequestParallelExecutor <Country>(cloudTableMock.Object, entityConverterMock.Object, batchPartitionerMock.Object);
            var entities = ObjectsFactory.GetCountries();

            // Act
            await executor.ExecuteBatchesWithoutResultAsync(entities, TableOperation.Insert, CancellationToken.None);

            // Assert
            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 TableRequestParallelExecutor <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>()));
        }
        public void ExecuteBatches()
        {
            // Arrange
            Mock <ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            Mock <ITableEntityConverter <Country> > entityConverterMock  = MocksFactory.GetTableEntityConverterMock <Country>();
            Mock <ITableBatchPartitioner>           batchPartitionerMock = MocksFactory.GetTableBatchPartitionerMock();
            var executor = new TableRequestParallelExecutor <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 ExecuteBatches()
        {
            // Arrange
            Mock<ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            Mock<ITableEntityConverter<Country>> entityConverterMock = MocksFactory.GetTableEntityConverterMock<Country>();
            Mock<ITableBatchPartitioner> batchPartitionerMock = MocksFactory.GetTableBatchPartitionerMock();
            var executor = new TableRequestParallelExecutor<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());
        }
Ejemplo n.º 10
0
        public async Task ExecuteBatchesWithoutResultAsync()
        {
            // Arrange
            Mock<ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            Mock<ITableEntityConverter<Country>> entityConverterMock = MocksFactory.GetTableEntityConverterMock<Country>();
            Mock<ITableBatchPartitioner> batchPartitionerMock = MocksFactory.GetTableBatchPartitionerMock();
            var executor = new TableRequestParallelExecutor<Country>(cloudTableMock.Object, entityConverterMock.Object, batchPartitionerMock.Object);
            var entities = ObjectsFactory.GetCountries();

            // Act
            await executor.ExecuteBatchesWithoutResultAsync(entities, TableOperation.Insert, CancellationToken.None);

            // Assert
            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());
        }
Ejemplo n.º 11
0
        public Task ExecuteBatchesWithoutResultAsyncWithNullOperation()
        {
            // Arrange
            Mock<ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            Mock<ITableEntityConverter<Country>> entityConverterMock = MocksFactory.GetTableEntityConverterMock<Country>();
            Mock<ITableBatchPartitioner> batchPartitionerMock = MocksFactory.GetTableBatchPartitionerMock();
            var executor = new TableRequestParallelExecutor<Country>(cloudTableMock.Object, entityConverterMock.Object, batchPartitionerMock.Object);
            var entities = ObjectsFactory.GetCountries();

            // Act && Assert
            return Assert.ThrowsAsync<ArgumentNullException>(() => executor.ExecuteBatchesWithoutResultAsync(entities, null, CancellationToken.None));
        }
Ejemplo n.º 12
0
        public void ExecuteBatchesEvenWhenNotEvaluated()
        {
            // Arrange
            Mock<ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock();
            Mock<ITableEntityConverter<Country>> entityConverterMock = MocksFactory.GetTableEntityConverterMock<Country>();
            Mock<ITableBatchPartitioner> batchPartitionerMock = MocksFactory.GetTableBatchPartitionerMock();
            var executor = new TableRequestParallelExecutor<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>()));
        }