public async Task Should_recreate_deleted_content_with_upsert(bool permanent) { // STEP 1: Create a new item. var content_1 = await _.Contents.CreateAsync(new TestEntityData { Number = 2 }, ContentCreateOptions.AsPublish); // STEP 2: Delete the item. var deleteOptions = new ContentDeleteOptions { Permanent = permanent }; await _.Contents.DeleteAsync(content_1.Id, deleteOptions); // STEP 3: Recreate the item with the same id. var content_2 = await _.Contents.UpsertAsync(content_1.Id, new TestEntityData { Number = 2 }, ContentUpsertOptions.AsPublish); Assert.Equal(Status.Published, content_2.Status); // STEP 4: Check if we can find it again with a query. var contents_4 = await _.Contents.GetAsync(new ContentQuery { Filter = $"id eq '{content_1.Id}'" }); Assert.NotNull(contents_4.Items.Find(x => x.Id == content_1.Id)); }
public async Task Should_not_delete_when_referenced() { // STEP 1: Create a referenced content. var dataA = new TestEntityWithReferencesData(); var contentA_1 = await _.Contents.CreateAsync(dataA, ContentCreateOptions.AsPublish); // STEP 2: Create a content with a reference. var dataB = new TestEntityWithReferencesData { References = new[] { contentA_1.Id } }; await _.Contents.CreateAsync(dataB, ContentCreateOptions.AsPublish); // STEP 3: Try to delete with referrer check. var options = new ContentDeleteOptions { CheckReferrers = true }; await Assert.ThrowsAnyAsync <SquidexException>(() => { return(_.Contents.DeleteAsync(contentA_1.Id, options)); }); // STEP 4: Delete without referrer check await _.Contents.DeleteAsync(contentA_1.Id); }