public async Task AllowBatchingRequestsSendsToExecutor_Delete()
        {
            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.DeleteItemAsync <dynamic>(
                partitionKey : partitionKey,
                id : testItem.id);

            container.MockedExecutor.Verify(c => c.AddAsync(It.IsAny <ItemBatchOperation>(), It.IsAny <ItemRequestOptions>(), It.IsAny <CancellationToken>()), Times.Once);
        }
Example #2
0
        public async Task AllowBatchingRequestsSendsToExecutor_ReadStream()
        {
            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",
            };

            using (Stream itemStream = MockCosmosUtil.Serializer.ToStream <dynamic>(testItem))
            {
                ItemRequestOptions  itemRequestOptions = new ItemRequestOptions();
                Cosmos.PartitionKey partitionKey       = new Cosmos.PartitionKey(testItem.pk);
                using (ResponseMessage streamResponse = await container.ReadItemStreamAsync(
                           partitionKey: partitionKey,
                           id: testItem.id))
                {
                    container.MockedExecutor.Verify(c => c.AddAsync(It.IsAny <ItemBatchOperation>(), It.IsAny <ItemRequestOptions>(), It.IsAny <CancellationToken>()), Times.Once);
                }
            }
        }
Example #3
0
        public async Task AllowBatchingRequestsSendsToExecutor_Delete()
        {
            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.DeleteItemAsync <dynamic>(
                partitionKey : partitionKey,
                id : testItem.id);

            container.MockedExecutor.Verify(c => c.AddAsync(It.IsAny <ItemBatchOperation>(), It.IsAny <ItemRequestOptions>(), It.IsAny <CancellationToken>()), Times.Once);
        }
        public async Task AllowBatchingRequestsSendsToExecutor_UpsertStream()
        {
            ClientContextCore clientContextCore = new ClientContextCore(
                MockCosmosUtil.CreateMockCosmosClient(),
                new CosmosClientOptions()
            {
                AllowBulkExecution = true
            },
                new CosmosJsonDotNetSerializer(),
                new CosmosJsonDotNetSerializer(),
                new CosmosJsonDotNetSerializer(),
                null,
                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",
            };

            using (Stream itemStream = MockCosmosUtil.Serializer.ToStream <dynamic>(testItem))
            {
                ItemRequestOptions  itemRequestOptions = new ItemRequestOptions();
                Cosmos.PartitionKey partitionKey       = new Cosmos.PartitionKey(testItem.pk);
                using (ResponseMessage streamResponse = await container.UpsertItemStreamAsync(
                           partitionKey: partitionKey,
                           streamPayload: itemStream))
                {
                    container.MockedExecutor.Verify(c => c.AddAsync(It.IsAny <ItemBatchOperation>(), It.IsAny <ItemRequestOptions>(), It.IsAny <CancellationToken>()), Times.Once);
                }
            }
        }