public async Task ShouldBatchUpdateFieldsByIds()
        {
            /// Arrange
            var contentId = await _fixture.GetRandomContentIdAsync(".jpg", 20);

            var content = await _client.Contents.GetAsync(contentId);

            var updateRequest = new ContentFieldsUpdateRequest
            {
                ContentIds = new List <string> {
                    content.Id
                },
                ChangeCommands = new List <MetadataValuesChangeCommandBase>
                {
                    new MetadataValuesSchemaUpsertCommand
                    {
                        SchemaId = "Drive",
                        Value    = new DataDictionary
                        {
                            { "location", "testlocation" }
                        }
                    }
                }
            };

            /// Act
            var businessProcess = await _client.Contents.BatchUpdateFieldsByIdsAsync(updateRequest);

            var waitResult = await _client.BusinessProcesses.WaitForCompletionAsync(businessProcess.Id);

            /// Assert
            Assert.True(waitResult.HasLifeCycleHit);
        }
Ejemplo n.º 2
0
        public async Task ShouldGetDifferenceOfContentChange()
        {
            /// Arrange
            string location  = "testlocation" + new Random().Next(0, 999999);
            string contentId = await _fixture.GetRandomContentIdAsync(".jpg", 20);

            var content = await _client.Contents.GetAsync(contentId);

            var history = await _client.DocumentHistory.GetAsync(contentId);

            var updateRequest = new ContentFieldsUpdateRequest
            {
                ContentIds = new List <string> {
                    content.Id
                },
                ChangeCommands = new List <MetadataValuesChangeCommandBase>
                {
                    new MetadataValuesSchemaUpsertCommand
                    {
                        SchemaId = "Drive",
                        Value    = new DataDictionary
                        {
                            { "Location", location }
                        }
                    }
                }
            };

            // TODO: Create ContentHelper to update and wait with one call => UpdateMetadataManyAndWaitForCompletionAsync?
            var businessProcess = await _client.Contents.BatchUpdateFieldsByIdsAsync(updateRequest);

            var waitResult = await _client.BusinessProcesses.WaitForCompletionAsync(businessProcess.Id);

            // Refetch content and compare versions
            var updatedHistory = await _client.DocumentHistory.GetAsync(contentId);

            /// Act
            var difference = await _client.DocumentHistory.GetDifferenceAsync(contentId, history.DocumentVersion, updatedHistory.DocumentVersion);

            /// Assert
            Assert.True(waitResult.HasLifeCycleHit);
            Assert.NotEqual(updatedHistory.DocumentVersion, 0);
            Assert.True(difference.NewValues.ToString().Contains(@"""location"": """ + location + @""""));
        }