public async Task AllowBatchingRequestsSendsToExecutor_Upsert()
        {
            CosmosClient      cosmosClient      = MockCosmosUtil.CreateMockCosmosClient();
            ClientContextCore clientContextCore = new ClientContextCore(
                cosmosClient,
                new CosmosClientOptions()
            {
                AllowBulkExecution = true
            },
                new CosmosJsonDotNetSerializer(),
                new CosmosJsonDotNetSerializer(),
                null,
                cosmosClient.ResponseFactory,
                null,
                new MockDocumentClient()
                );

            DatabaseCore          db        = new DatabaseCore(clientContextCore, "test");
            ExecutorContainerCore container = new ExecutorContainerCore(clientContextCore, db, "test");

            dynamic testItem = new
            {
                id = Guid.NewGuid().ToString(),
                pk = "FF627B77-568E-4541-A47E-041EAC10E46F",
            };

            Cosmos.PartitionKey    partitionKey = new Cosmos.PartitionKey(testItem.pk);
            ItemResponse <dynamic> response     = await container.UpsertItemAsync <dynamic>(
                testItem,
                partitionKey : partitionKey);

            container.MockedExecutor.Verify(c => c.AddAsync(It.IsAny <ItemBatchOperation>(), It.IsAny <ItemRequestOptions>(), It.IsAny <CancellationToken>()), Times.Once);
        }
Пример #2
0
        public async Task AllowBatchingRequestsSendsToExecutor_Upsert()
        {
            ClientContextCore clientContextCore = this.CreateMockBulkClientContextCore();

            DatabaseCore          db        = new DatabaseCore(clientContextCore, "test");
            ExecutorContainerCore container = new ExecutorContainerCore(clientContextCore, db, "test");

            dynamic testItem = new
            {
                id = Guid.NewGuid().ToString(),
                pk = "FF627B77-568E-4541-A47E-041EAC10E46F",
            };

            Cosmos.PartitionKey    partitionKey = new Cosmos.PartitionKey(testItem.pk);
            ItemResponse <dynamic> response     = await container.UpsertItemAsync <dynamic>(
                testItem,
                partitionKey : partitionKey);

            container.MockedExecutor.Verify(c => c.AddAsync(It.IsAny <ItemBatchOperation>(), It.IsAny <ItemRequestOptions>(), It.IsAny <CancellationToken>()), Times.Once);
        }