示例#1
0
        public async Task PartitionKeyRangeServerBatchRequestSizeTests()
        {
            const int docSizeInBytes = 250;
            const int operationCount = 10;

            foreach (int expectedOperationCount in new int[] { 1, 2, 5, 10 })
            {
                await PartitionKeyRangeServerBatchRequestTests.VerifyServerRequestCreationsBySizeAsync(expectedOperationCount, operationCount, docSizeInBytes);

                await PartitionKeyRangeServerBatchRequestTests.VerifyServerRequestCreationsByCountAsync(expectedOperationCount, operationCount, docSizeInBytes);
            }
        }
示例#2
0
        private static async Task VerifyServerRequestCreationsByCountAsync(
            int expectedOperationCount,
            int operationCount,
            int docSizeInBytes)
        {
            int maxServerRequestBodyLength     = int.MaxValue;
            int maxServerRequestOperationCount = expectedOperationCount;

            (PartitionKeyRangeServerBatchRequest request, ArraySegment <ItemBatchOperation> overflow) = await PartitionKeyRangeServerBatchRequestTests.GetBatchWithCreateOperationsAsync(operationCount, maxServerRequestBodyLength, maxServerRequestOperationCount, docSizeInBytes);

            Assert.AreEqual(expectedOperationCount, request.Operations.Count);
            Assert.AreEqual(overflow.Count, operationCount - request.Operations.Count);
        }
示例#3
0
        private static async Task VerifyServerRequestCreationsBySizeAsync(
            int expectedOperationCount,
            int operationCount,
            int docSizeInBytes)
        {
            const int perRequestOverheadEstimateInBytes = 30;
            const int perDocOverheadEstimateInBytes     = 50;
            int       maxServerRequestBodyLength        = ((docSizeInBytes + perDocOverheadEstimateInBytes) * expectedOperationCount) + perRequestOverheadEstimateInBytes;
            int       maxServerRequestOperationCount    = int.MaxValue;

            (PartitionKeyRangeServerBatchRequest request, ArraySegment <ItemBatchOperation> overflow) = await PartitionKeyRangeServerBatchRequestTests.GetBatchWithCreateOperationsAsync(operationCount, maxServerRequestBodyLength, maxServerRequestOperationCount, docSizeInBytes);

            Assert.AreEqual(expectedOperationCount, request.Operations.Count);
            Assert.AreEqual(overflow.Count, operationCount - request.Operations.Count);
        }