public void CreateExecutorWithNullCloudTableParameter() { // Arrange Mock <ITableEntityConverter <Country> > entityConverterMock = MocksFactory.GetTableEntityConverterMock <Country>(); // Act && Assert Assert.Throws <ArgumentNullException>(() => new TableRequestExecutorFactory <Country>(null, entityConverterMock.Object)); }
public void CreateExecutorWithNullBatchPartitioner() { // Arrange Mock <ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock(); Mock <ITableEntityConverter <Country> > entityConverterMock = MocksFactory.GetTableEntityConverterMock <Country>(); // Act && Assert Assert.Throws <ArgumentNullException>(() => new TableRequestSequentialExecutor <Country>(cloudTableMock.Object, entityConverterMock.Object, 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 TableRequestSequentialExecutor <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 TableRequestSequentialExecutor <Country>(cloudTableMock.Object, entityConverterMock.Object, batchPartitionerMock.Object); // Act && Assert return(Assert.ThrowsAsync <ArgumentNullException>(() => executor.ExecuteBatchesWithoutResultAsync(null, null, CancellationToken.None))); }
public void 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 Assert.Throws <ArgumentNullException>(() => executor.ExecuteBatchesWithoutResultAsync(entities, 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 TableRequestSequentialExecutor <Country>(cloudTableMock.Object, entityConverterMock.Object, batchPartitionerMock.Object); // Assert Assert.NotNull(result); }
public void CreateExecutorWithInvalidMode() { // Arrange Mock <ITableEntityConverter <Country> > entityConverterMock = MocksFactory.GetTableEntityConverterMock <Country>(); Mock <ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock(); var executorFactory = new TableRequestExecutorFactory <Country>(cloudTableMock.Object, entityConverterMock.Object); ITableRequestExecutor <Country> executor = null; // Act Assert.Throws <ArgumentOutOfRangeException>(() => executor = executorFactory.Create((ExecutionMode)2)); // Assert Assert.Null(executor); }
public void CreateSequentialExecutor() { // Arrange Mock <ITableEntityConverter <Country> > entityConverterMock = MocksFactory.GetTableEntityConverterMock <Country>(); Mock <ICloudTable> cloudTableMock = MocksFactory.GetCloudTableMock(); var executorFactory = new TableRequestExecutorFactory <Country>(cloudTableMock.Object, entityConverterMock.Object); // Act ITableRequestExecutor <Country> executor = executorFactory.Create(ExecutionMode.Sequential); // Assert Assert.NotNull(executor); Assert.IsType <TableRequestSequentialExecutor <Country> >(executor); Assert.Equal(cloudTableMock.Object, executorFactory.CloudTable); }
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 TableRequestSequentialExecutor <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 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>())); }
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()); }