public async Task BatchInvalidOptionsAsync() { Container container = BatchUnitTests.GetContainer(); List <RequestOptions> badBatchOptionsList = new List <RequestOptions>() { new RequestOptions() { IfMatchEtag = "cond", }, new RequestOptions() { IfNoneMatchEtag = "cond2", } }; foreach (RequestOptions batchOptions in badBatchOptionsList) { BatchCore batch = (BatchCore) new BatchCore((ContainerInternal)container, new Cosmos.PartitionKey(BatchUnitTests.PartitionKey1)) .ReadItem("someId"); await BatchUnitTests.VerifyExceptionThrownOnExecuteAsync( batch, typeof(ArgumentException), ClientResources.BatchRequestOptionNotSupported, batchOptions); } }
public async Task BatchNoOperationsAsync() { Container container = BatchUnitTests.GetContainer(); TransactionalBatch batch = new BatchCore((ContainerInternal)container, new Cosmos.PartitionKey(BatchUnitTests.PartitionKey1)); await BatchUnitTests.VerifyExceptionThrownOnExecuteAsync( batch, typeof(ArgumentException), ClientResources.BatchNoOperations); }
public async Task BatchWithTooManyOperationsAsync() { Container container = BatchUnitTests.GetContainer(); const int operationCount = Constants.MaxOperationsInDirectModeBatchRequest + 1; Batch batch = new BatchCore((ContainerCore)container, new Cosmos.PartitionKey(BatchUnitTests.PartitionKey1)); for (int i = 0; i < operationCount; i++) { batch.ReadItem("someId"); } await BatchUnitTests.VerifyExceptionThrownOnExecuteAsync( batch, typeof(ArgumentException), ClientResources.BatchTooLarge); }
public async Task BatchInvalidItemOptionsAsync() { Container container = BatchUnitTests.GetContainer(); List <TransactionalBatchItemRequestOptions> badItemOptionsList = new List <TransactionalBatchItemRequestOptions>() { new TransactionalBatchItemRequestOptions() { Properties = new Dictionary <string, object> { // EPK without string representation { WFConstants.BackendHeaders.EffectivePartitionKey, new byte[1] { 0x41 } } } }, new TransactionalBatchItemRequestOptions() { Properties = new Dictionary <string, object> { // EPK string without corresponding byte representation { WFConstants.BackendHeaders.EffectivePartitionKeyString, "epk" } } }, new TransactionalBatchItemRequestOptions() { Properties = new Dictionary <string, object> { // Partition key without EPK string { HttpConstants.HttpHeaders.PartitionKey, "epk" } } } }; foreach (TransactionalBatchItemRequestOptions itemOptions in badItemOptionsList) { TransactionalBatch batch = new BatchCore((ContainerInternal)container, new Cosmos.PartitionKey(BatchUnitTests.PartitionKey1)) .ReplaceItem("someId", new TestItem("repl"), itemOptions); await BatchUnitTests.VerifyExceptionThrownOnExecuteAsync( batch, typeof(ArgumentException)); } }
public async Task BatchLargerThanServerRequestAsync() { Container container = BatchUnitTests.GetContainer(); const int operationCount = 20; int appxDocSize = Constants.MaxDirectModeBatchRequestBodySizeInBytes / operationCount; // Increase the doc size by a bit so all docs won't fit in one server request. appxDocSize = (int)(appxDocSize * 1.05); Batch batch = new BatchCore((ContainerCore)container, new Cosmos.PartitionKey(BatchUnitTests.PartitionKey1)); for (int i = 0; i < operationCount; i++) { TestItem testItem = new TestItem(new string('x', appxDocSize)); batch.CreateItem(testItem); } await BatchUnitTests.VerifyExceptionThrownOnExecuteAsync( batch, typeof(RequestEntityTooLargeException)); }