Beispiel #1
0
        public async Task ShouldCompareWithVersion()
        {
            // Arrange
            string location  = "testlocation" + new Random().Next(0, 999999);
            string contentId = await _fixture.GetRandomContentIdAsync(".jpg", 20).ConfigureAwait(false);

            var schema = await CreateTestSchemaAsync().ConfigureAwait(false);

            var content = await _client.Content.GetAsync(contentId).ConfigureAwait(false);

            var history = await _client.DocumentHistory.GetCurrentAsync(typeof(Content).Name, contentId).ConfigureAwait(false);

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

            var result = await _client.Content.BatchUpdateFieldsByIdsAsync(updateRequest).ConfigureAwait(false);

            // Refetch content and compare versions
            var updatedHistory = await _client.DocumentHistory.GetCurrentAsync(typeof(Content).Name, contentId).ConfigureAwait(false);

            // Act
            var difference = await _client.DocumentHistory.CompareWithVersionAsync(typeof(Content).Name, contentId, updatedHistory.DocumentVersion, history.DocumentVersion).ConfigureAwait(false);

            // Assert
            Assert.True(result.LifeCycle == BusinessProcessLifeCycle.Succeeded);
            Assert.NotEqual(0, updatedHistory.DocumentVersion);
            Assert.Contains(@"""name"": """ + location + @"""", difference.Patch.ToString());
        }
        /// <inheritdoc />
        public async Task <ContentBatchOperationResult> BatchUpdateFieldsByIdsAsync(ContentFieldsBatchUpdateRequest updateRequest, TimeSpan?timeout = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var businessProcess = await BatchUpdateFieldsByIdsCoreAsync(updateRequest, cancellationToken).ConfigureAwait(false);

            return(await WaitForBusinessProcessAndReturnResult(businessProcess.Id, timeout, cancellationToken).ConfigureAwait(false));
        }