|
|
@ -25,14 +25,17 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_return_published_content() |
|
|
public async Task Should_return_published_content() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create the item unpublished.
|
|
|
// STEP 1: Create the item unpublished.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 1 |
|
|
Number = 1 |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Publish the item.
|
|
|
// STEP 2: Publish the item.
|
|
|
await _.Contents.ChangeStatusAsync(content.Id, new ChangeStatus |
|
|
await _.Contents.ChangeStatusAsync( |
|
|
|
|
|
content.Id, |
|
|
|
|
|
new ChangeStatus |
|
|
{ |
|
|
{ |
|
|
Status = "Published" |
|
|
Status = "Published" |
|
|
}); |
|
|
}); |
|
|
@ -46,14 +49,18 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_not_return_archived_content() |
|
|
public async Task Should_not_return_archived_content() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create the item published.
|
|
|
// STEP 1: Create the item published.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 1 |
|
|
Number = 1 |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Archive the item.
|
|
|
// STEP 2: Archive the item.
|
|
|
await _.Contents.ChangeStatusAsync(content.Id, new ChangeStatus |
|
|
await _.Contents.ChangeStatusAsync( |
|
|
|
|
|
content.Id, |
|
|
|
|
|
new ChangeStatus |
|
|
{ |
|
|
{ |
|
|
Status = "Archived" |
|
|
Status = "Archived" |
|
|
}); |
|
|
}); |
|
|
@ -70,18 +77,24 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_not_return_unpublished_content() |
|
|
public async Task Should_not_return_unpublished_content() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create the item unpublished.
|
|
|
// STEP 1: Create the item unpublished.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 1 |
|
|
Number = 1 |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Change the status to publiushed and then to draft.
|
|
|
// STEP 2: Change the status to publiushed and then to draft.
|
|
|
await _.Contents.ChangeStatusAsync(content.Id, new ChangeStatus |
|
|
await _.Contents.ChangeStatusAsync( |
|
|
|
|
|
content.Id, |
|
|
|
|
|
new ChangeStatus |
|
|
{ |
|
|
{ |
|
|
Status = "Published" |
|
|
Status = "Published" |
|
|
}); |
|
|
}); |
|
|
await _.Contents.ChangeStatusAsync(content.Id, new ChangeStatus |
|
|
|
|
|
|
|
|
await _.Contents.ChangeStatusAsync( |
|
|
|
|
|
content.Id, |
|
|
|
|
|
new ChangeStatus |
|
|
{ |
|
|
{ |
|
|
Status = "Draft" |
|
|
Status = "Draft" |
|
|
}); |
|
|
}); |
|
|
@ -100,10 +113,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
const string text = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36"; |
|
|
const string text = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36"; |
|
|
|
|
|
|
|
|
// STEP 1: Create a content item with a text that caused a bug before.
|
|
|
// STEP 1: Create a content item with a text that caused a bug before.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
String = text |
|
|
String = text |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Get the item and ensure that the text is the same.
|
|
|
// STEP 2: Get the item and ensure that the text is the same.
|
|
|
@ -118,13 +133,15 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_create_null_localized_text() |
|
|
public async Task Should_create_null_localized_text() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a content item with a text that caused a bug before.
|
|
|
// STEP 1: Create a content item with a text that caused a bug before.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Localized = new Dictionary<string, string?> |
|
|
Localized = new Dictionary<string, string?> |
|
|
{ |
|
|
{ |
|
|
["en"] = null |
|
|
["en"] = null |
|
|
} |
|
|
} |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Get the item and ensure that the text is the same.
|
|
|
// STEP 2: Get the item and ensure that the text is the same.
|
|
|
@ -139,13 +156,15 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_create_json_with_dot() |
|
|
public async Task Should_create_json_with_dot() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a content item with a text that caused a bug before.
|
|
|
// STEP 1: Create a content item with a text that caused a bug before.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Json = new JObject |
|
|
Json = new JObject |
|
|
{ |
|
|
{ |
|
|
["field.with.dot"] = 42 |
|
|
["field.with.dot"] = 42 |
|
|
} |
|
|
} |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Get the item and ensure that the text is the same.
|
|
|
// STEP 2: Get the item and ensure that the text is the same.
|
|
|
@ -160,10 +179,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_create_default_text() |
|
|
public async Task Should_create_default_text() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a content item with a text that caused a bug before.
|
|
|
// STEP 1: Create a content item with a text that caused a bug before.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Localized = [] |
|
|
Localized = [] |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Get the item and ensure that the text is the same.
|
|
|
// STEP 2: Get the item and ensure that the text is the same.
|
|
|
@ -176,7 +197,8 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_create_non_published_content() |
|
|
public async Task Should_create_non_published_content() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create the item unpublished.
|
|
|
// STEP 1: Create the item unpublished.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 1 |
|
|
Number = 1 |
|
|
}); |
|
|
}); |
|
|
@ -195,10 +217,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_create_published_content() |
|
|
public async Task Should_create_published_content() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create the item published.
|
|
|
// STEP 1: Create the item published.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 1 |
|
|
Number = 1 |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Get the item.
|
|
|
// STEP 2: Get the item.
|
|
|
@ -211,10 +235,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_create_draft_version() |
|
|
public async Task Should_create_draft_version() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 1 |
|
|
Number = 1 |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Create draft.
|
|
|
// STEP 2: Create draft.
|
|
|
@ -222,7 +248,9 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 3: Update the item and ensure that the data has not changed.
|
|
|
// STEP 3: Update the item and ensure that the data has not changed.
|
|
|
await _.Contents.PatchAsync(content.Id, new TestEntityData |
|
|
await _.Contents.PatchAsync( |
|
|
|
|
|
content.Id, |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 2 |
|
|
Number = 2 |
|
|
}); |
|
|
}); |
|
|
@ -239,7 +267,9 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 5: Publish draft and ensure that it has been updated.
|
|
|
// STEP 5: Publish draft and ensure that it has been updated.
|
|
|
await _.Contents.ChangeStatusAsync(content.Id, new ChangeStatus |
|
|
await _.Contents.ChangeStatusAsync( |
|
|
|
|
|
content.Id, |
|
|
|
|
|
new ChangeStatus |
|
|
{ |
|
|
{ |
|
|
Status = "Published" |
|
|
Status = "Published" |
|
|
}); |
|
|
}); |
|
|
@ -255,12 +285,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
var id = $"custom-{Guid.NewGuid()}"; |
|
|
var id = $"custom-{Guid.NewGuid()}"; |
|
|
|
|
|
|
|
|
// STEP 1: Create a new item with a custom id.
|
|
|
// STEP 1: Create a new item with a custom id.
|
|
|
var options = new ContentCreateOptions { Id = id, Publish = true }; |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
|
|
|
{ |
|
|
{ |
|
|
Number = 1 |
|
|
Number = 1 |
|
|
}, options); |
|
|
}, |
|
|
|
|
|
new ContentCreateOptions { Id = id, Publish = true }); |
|
|
|
|
|
|
|
|
Assert.Equal(id, content.Id); |
|
|
Assert.Equal(id, content.Id); |
|
|
} |
|
|
} |
|
|
@ -271,12 +301,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
var id = $"custom-{Guid.NewGuid()}"; |
|
|
var id = $"custom-{Guid.NewGuid()}"; |
|
|
|
|
|
|
|
|
// STEP 1: Create a new item with a custom id.
|
|
|
// STEP 1: Create a new item with a custom id.
|
|
|
var options = new ContentCreateOptions { Id = id, Publish = true }; |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
|
|
|
{ |
|
|
{ |
|
|
Number = 1 |
|
|
Number = 1 |
|
|
}, options); |
|
|
}, |
|
|
|
|
|
new ContentCreateOptions { Id = id, Publish = true }); |
|
|
|
|
|
|
|
|
Assert.Equal(id, content.Id); |
|
|
Assert.Equal(id, content.Id); |
|
|
|
|
|
|
|
|
@ -284,10 +314,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
// STEP 2: Create a new item with a custom id.
|
|
|
// STEP 2: Create a new item with a custom id.
|
|
|
var ex = await Assert.ThrowsAnyAsync<SquidexException>(() => |
|
|
var ex = await Assert.ThrowsAnyAsync<SquidexException>(() => |
|
|
{ |
|
|
{ |
|
|
return _.Contents.CreateAsync(new TestEntityData |
|
|
return _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 1 |
|
|
Number = 1 |
|
|
}, options); |
|
|
}, |
|
|
|
|
|
new ContentCreateOptions { Id = id, Publish = true }); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
Assert.Equal(409, ex.StatusCode); |
|
|
Assert.Equal(409, ex.StatusCode); |
|
|
@ -299,16 +331,21 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
var id = $"custom-{Guid.NewGuid()}"; |
|
|
var id = $"custom-{Guid.NewGuid()}"; |
|
|
|
|
|
|
|
|
// STEP 1: Upsert a new item with a custom id.
|
|
|
// STEP 1: Upsert a new item with a custom id.
|
|
|
var content = await _.Contents.UpsertAsync(id, new TestEntityData |
|
|
var content = await _.Contents.UpsertAsync( |
|
|
|
|
|
id, |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 1 |
|
|
Number = 1 |
|
|
}, ContentUpsertOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentUpsertOptions.AsPublish); |
|
|
|
|
|
|
|
|
Assert.Equal(id, content.Id); |
|
|
Assert.Equal(id, content.Id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Make an update with the upsert endpoint.
|
|
|
// STEP 2: Make an update with the upsert endpoint.
|
|
|
content = await _.Contents.UpsertAsync(id, new TestEntityData |
|
|
content = await _.Contents.UpsertAsync( |
|
|
|
|
|
id, |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 2 |
|
|
Number = 2 |
|
|
}); |
|
|
}); |
|
|
@ -317,7 +354,9 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 3: Make an update with the update endpoint.
|
|
|
// STEP 3: Make an update with the update endpoint.
|
|
|
content = await _.Contents.UpdateAsync(id, new TestEntityData |
|
|
content = await _.Contents.UpdateAsync( |
|
|
|
|
|
id, |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 3 |
|
|
Number = 3 |
|
|
}); |
|
|
}); |
|
|
@ -357,17 +396,22 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_update_content(ContentStrategies.Update strategy) |
|
|
public async Task Should_update_content(ContentStrategies.Update strategy) |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
String = "2" |
|
|
String = "2" |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Update with selected strategy.
|
|
|
// STEP 2: Update with selected strategy.
|
|
|
await _.Client.UpdateAsync(content, new TestEntityData |
|
|
await _.Client.UpdateAsync( |
|
|
|
|
|
content, |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 200 |
|
|
Number = 200 |
|
|
}, strategy); |
|
|
}, |
|
|
|
|
|
strategy); |
|
|
|
|
|
|
|
|
var updated = await _.Contents.GetAsync(content.Id); |
|
|
var updated = await _.Contents.GetAsync(content.Id); |
|
|
|
|
|
|
|
|
@ -381,14 +425,17 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_update_content_with_script() |
|
|
public async Task Should_update_content_with_script() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 100 |
|
|
Number = 100 |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Update content with script.
|
|
|
// STEP 2: Update content with script.
|
|
|
await _.Client.DynamicContents(_.SchemaName).UpdateAsync(content.Id, |
|
|
await _.Client.DynamicContents(_.SchemaName).UpdateAsync( |
|
|
|
|
|
content.Id, |
|
|
new DynamicData |
|
|
new DynamicData |
|
|
{ |
|
|
{ |
|
|
[TestEntityData.NumberField] = new JObject |
|
|
[TestEntityData.NumberField] = new JObject |
|
|
@ -412,12 +459,14 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_unset_field_with_patch() |
|
|
public async Task Should_unset_field_with_patch() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
String = "Hello", |
|
|
String = "Hello", |
|
|
// Not relevant for the test, but required in the schema.
|
|
|
// Not relevant for the test, but required in the schema.
|
|
|
Number = 100 |
|
|
Number = 100 |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Update content with script.
|
|
|
// STEP 2: Update content with script.
|
|
|
@ -439,12 +488,14 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_unset_field_value_with_patch() |
|
|
public async Task Should_unset_field_value_with_patch() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
String = "Hello", |
|
|
String = "Hello", |
|
|
// Not relevant for the test, but required in the schema.
|
|
|
// Not relevant for the test, but required in the schema.
|
|
|
Number = 100 |
|
|
Number = 100 |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Update content with script.
|
|
|
// STEP 2: Update content with script.
|
|
|
@ -475,17 +526,22 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_update_content_to_null(ContentStrategies.Update strategy) |
|
|
public async Task Should_update_content_to_null(ContentStrategies.Update strategy) |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
String = "initial" |
|
|
String = "initial" |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Update with selected strategy.
|
|
|
// STEP 2: Update with selected strategy.
|
|
|
await _.Client.UpdateAsync(content, new TestEntityData |
|
|
await _.Client.UpdateAsync( |
|
|
|
|
|
content, |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
String = null |
|
|
String = null |
|
|
}, strategy); |
|
|
}, |
|
|
|
|
|
strategy); |
|
|
|
|
|
|
|
|
var updated = await _.Contents.GetAsync(content.Id); |
|
|
var updated = await _.Contents.GetAsync(content.Id); |
|
|
|
|
|
|
|
|
@ -502,17 +558,22 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_patch_content(ContentStrategies.Patch strategy) |
|
|
public async Task Should_patch_content(ContentStrategies.Patch strategy) |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
String = "initial" |
|
|
String = "initial" |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Patch with selected strategy.
|
|
|
// STEP 2: Patch with selected strategy.
|
|
|
await _.Client.PatchAsync(content, new TestEntityData |
|
|
await _.Client.PatchAsync( |
|
|
|
|
|
content, |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 200 |
|
|
Number = 200 |
|
|
}, strategy); |
|
|
}, |
|
|
|
|
|
strategy); |
|
|
|
|
|
|
|
|
var updated = await _.Contents.GetAsync(content.Id); |
|
|
var updated = await _.Contents.GetAsync(content.Id); |
|
|
|
|
|
|
|
|
@ -526,10 +587,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_patch_content_with_script() |
|
|
public async Task Should_patch_content_with_script() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 100 |
|
|
Number = 100 |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Patch content with script.
|
|
|
// STEP 2: Patch content with script.
|
|
|
@ -563,17 +626,22 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_patch_id_data_value(ContentStrategies.Patch strategy) |
|
|
public async Task Should_patch_id_data_value(ContentStrategies.Patch strategy) |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Id = "id1" |
|
|
Id = "id1" |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Patch with selected strategy.
|
|
|
// STEP 2: Patch with selected strategy.
|
|
|
await _.Client.PatchAsync(content, new TestEntityData |
|
|
await _.Client.PatchAsync( |
|
|
|
|
|
content, |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Id = "id2" |
|
|
Id = "id2" |
|
|
}, strategy); |
|
|
}, |
|
|
|
|
|
strategy); |
|
|
|
|
|
|
|
|
var updated = await _.Contents.GetAsync(content.Id); |
|
|
var updated = await _.Contents.GetAsync(content.Id); |
|
|
|
|
|
|
|
|
@ -590,17 +658,22 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_patch_content_to_null(ContentStrategies.Patch strategy) |
|
|
public async Task Should_patch_content_to_null(ContentStrategies.Patch strategy) |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
String = "initial" |
|
|
String = "initial" |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Patch with selected strategy.
|
|
|
// STEP 2: Patch with selected strategy.
|
|
|
await _.Client.PatchAsync(content, new |
|
|
await _.Client.PatchAsync( |
|
|
|
|
|
content, |
|
|
|
|
|
new |
|
|
{ |
|
|
{ |
|
|
@string = new { iv = (string?)null } |
|
|
@string = new { iv = (string?)null } |
|
|
}, strategy); |
|
|
}, |
|
|
|
|
|
strategy); |
|
|
|
|
|
|
|
|
var updated = await _.Contents.GetAsync(content.Id); |
|
|
var updated = await _.Contents.GetAsync(content.Id); |
|
|
|
|
|
|
|
|
@ -615,10 +688,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_delete_content(ContentStrategies.Deletion strategy) |
|
|
public async Task Should_delete_content(ContentStrategies.Deletion strategy) |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 2 |
|
|
Number = 2 |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Delete with selected strategy.
|
|
|
// STEP 2: Delete with selected strategy.
|
|
|
@ -649,12 +724,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
var id = $"custom-{Guid.NewGuid()}"; |
|
|
var id = $"custom-{Guid.NewGuid()}"; |
|
|
|
|
|
|
|
|
// STEP 1: Create a new item with a custom id.
|
|
|
// STEP 1: Create a new item with a custom id.
|
|
|
var options = new ContentCreateOptions { Id = id, Publish = true }; |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
|
|
|
{ |
|
|
{ |
|
|
Number = 1 |
|
|
Number = 1 |
|
|
}, options); |
|
|
}, |
|
|
|
|
|
new ContentCreateOptions { Id = id, Publish = true }); |
|
|
|
|
|
|
|
|
Assert.Equal(id, content.Id); |
|
|
Assert.Equal(id, content.Id); |
|
|
|
|
|
|
|
|
@ -677,10 +752,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_recreate_deleted_content(ContentStrategies.Deletion strategy) |
|
|
public async Task Should_recreate_deleted_content(ContentStrategies.Deletion strategy) |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content_1 = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content_1 = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 2 |
|
|
Number = 2 |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Delete with selected strategy.
|
|
|
// STEP 2: Delete with selected strategy.
|
|
|
@ -688,12 +765,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 3: Recreate the item with the same id.
|
|
|
// STEP 3: Recreate the item with the same id.
|
|
|
var createOptions = new ContentCreateOptions { Id = content_1.Id, Publish = true }; |
|
|
var content_2 = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
var content_2 = await _.Contents.CreateAsync(new TestEntityData |
|
|
|
|
|
{ |
|
|
{ |
|
|
Number = 2 |
|
|
Number = 2 |
|
|
}, createOptions); |
|
|
}, |
|
|
|
|
|
new ContentCreateOptions { Id = content_1.Id, Publish = true }); |
|
|
|
|
|
|
|
|
Assert.Equal(Status.Published, content_2.Status); |
|
|
Assert.Equal(Status.Published, content_2.Status); |
|
|
|
|
|
|
|
|
@ -714,10 +791,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_recreate_deleted_content_with_upsert(ContentStrategies.Deletion strategy) |
|
|
public async Task Should_recreate_deleted_content_with_upsert(ContentStrategies.Deletion strategy) |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content_1 = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content_1 = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 2 |
|
|
Number = 2 |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Delete with selected strategy.
|
|
|
// STEP 2: Delete with selected strategy.
|
|
|
@ -725,10 +804,13 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 3: Recreate the item with the same id.
|
|
|
// STEP 3: Recreate the item with the same id.
|
|
|
var content_2 = await _.Contents.UpsertAsync(content_1.Id, new TestEntityData |
|
|
var content_2 = await _.Contents.UpsertAsync( |
|
|
|
|
|
content_1.Id, |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 2 |
|
|
Number = 2 |
|
|
}, ContentUpsertOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentUpsertOptions.AsPublish); |
|
|
|
|
|
|
|
|
Assert.Equal(Status.Published, content_2.Status); |
|
|
Assert.Equal(Status.Published, content_2.Status); |
|
|
} |
|
|
} |
|
|
@ -745,10 +827,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
// STEP 1: Create a new item with a custom id.
|
|
|
// STEP 1: Create a new item with a custom id.
|
|
|
var options = new ContentCreateOptions { Id = id, Publish = true }; |
|
|
var options = new ContentCreateOptions { Id = id, Publish = true }; |
|
|
|
|
|
|
|
|
var content_1 = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content_1 = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 1 |
|
|
Number = 1 |
|
|
}, options); |
|
|
}, |
|
|
|
|
|
options); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Permanently delete content with custom id.
|
|
|
// STEP 2: Permanently delete content with custom id.
|
|
|
@ -756,10 +840,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 3: Create a new item with same custom id.
|
|
|
// STEP 3: Create a new item with same custom id.
|
|
|
var content_2 = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content_2 = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 2 |
|
|
Number = 2 |
|
|
}, options); |
|
|
}, |
|
|
|
|
|
options); |
|
|
|
|
|
|
|
|
Assert.Equal(2, content_2.Data.Number); |
|
|
Assert.Equal(2, content_2.Data.Number); |
|
|
|
|
|
|
|
|
@ -801,7 +887,9 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 3: Update content.
|
|
|
// STEP 3: Update content.
|
|
|
var content_2 = await client.UpdateAsync("_schemaId_", new DynamicData |
|
|
var content_2 = await client.UpdateAsync( |
|
|
|
|
|
"_schemaId_", |
|
|
|
|
|
new DynamicData |
|
|
{ |
|
|
{ |
|
|
["my-field"] = new JObject |
|
|
["my-field"] = new JObject |
|
|
{ |
|
|
{ |
|
|
@ -818,14 +906,18 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_get_content_by_version() |
|
|
public async Task Should_get_content_by_version() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 1 |
|
|
Number = 1 |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Update content.
|
|
|
// STEP 2: Update content.
|
|
|
content = await _.Contents.UpdateAsync(content.Id, new TestEntityData |
|
|
content = await _.Contents.UpdateAsync( |
|
|
|
|
|
content.Id, |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 2 |
|
|
Number = 2 |
|
|
}); |
|
|
}); |
|
|
@ -855,10 +947,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_update_content_in_parallel() |
|
|
public async Task Should_update_content_in_parallel() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 2 |
|
|
Number = 2 |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 3: Make parallel updates.
|
|
|
// STEP 3: Make parallel updates.
|
|
|
@ -866,10 +960,13 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
await _.Contents.UpdateAsync(content.Id, new TestEntityData |
|
|
await _.Contents.UpdateAsync( |
|
|
|
|
|
content.Id, |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = i |
|
|
Number = i |
|
|
}, ct: ct); |
|
|
}, |
|
|
|
|
|
ct: ct); |
|
|
} |
|
|
} |
|
|
catch (SquidexException ex) when (ex.StatusCode is 409 or 412) |
|
|
catch (SquidexException ex) when (ex.StatusCode is 409 or 412) |
|
|
{ |
|
|
{ |
|
|
@ -879,7 +976,9 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 3: Make an normal update to ensure nothing is corrupt.
|
|
|
// STEP 3: Make an normal update to ensure nothing is corrupt.
|
|
|
await _.Contents.UpdateAsync(content.Id, new TestEntityData |
|
|
await _.Contents.UpdateAsync( |
|
|
|
|
|
content.Id, |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 2 |
|
|
Number = 2 |
|
|
}); |
|
|
}); |
|
|
@ -893,10 +992,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_upsert_content_in_parallel() |
|
|
public async Task Should_upsert_content_in_parallel() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 2 |
|
|
Number = 2 |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 3: Make parallel upserts.
|
|
|
// STEP 3: Make parallel upserts.
|
|
|
@ -904,10 +1005,13 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
await _.Contents.UpsertAsync(content.Id, new TestEntityData |
|
|
await _.Contents.UpsertAsync( |
|
|
|
|
|
content.Id, |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = i |
|
|
Number = i |
|
|
}, ct: ct); |
|
|
}, |
|
|
|
|
|
ct: ct); |
|
|
} |
|
|
} |
|
|
catch (SquidexException ex) when (ex.StatusCode is 409 or 412) |
|
|
catch (SquidexException ex) when (ex.StatusCode is 409 or 412) |
|
|
{ |
|
|
{ |
|
|
@ -917,7 +1021,9 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 3: Make an normal update to ensure nothing is corrupt.
|
|
|
// STEP 3: Make an normal update to ensure nothing is corrupt.
|
|
|
await _.Contents.UpdateAsync(content.Id, new TestEntityData |
|
|
await _.Contents.UpdateAsync( |
|
|
|
|
|
content.Id, |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Number = 2 |
|
|
Number = 2 |
|
|
}); |
|
|
}); |
|
|
@ -1118,7 +1224,8 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
var prefix = Guid.NewGuid().ToString(); |
|
|
var prefix = Guid.NewGuid().ToString(); |
|
|
|
|
|
|
|
|
// STEP 1: Create contents.
|
|
|
// STEP 1: Create contents.
|
|
|
var result_0 = await _.Contents.BulkUpdateAsync(new BulkUpdate |
|
|
var result_0 = await _.Contents.BulkUpdateAsync( |
|
|
|
|
|
new BulkUpdate |
|
|
{ |
|
|
{ |
|
|
Jobs = |
|
|
Jobs = |
|
|
[ |
|
|
[ |
|
|
@ -1158,7 +1265,8 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Update contents by filter.
|
|
|
// STEP 2: Update contents by filter.
|
|
|
var result_1 = await _.Contents.BulkUpdateAsync(new BulkUpdate |
|
|
var result_1 = await _.Contents.BulkUpdateAsync( |
|
|
|
|
|
new BulkUpdate |
|
|
{ |
|
|
{ |
|
|
Jobs = |
|
|
Jobs = |
|
|
[ |
|
|
[ |
|
|
@ -1221,7 +1329,8 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Get contents.
|
|
|
// STEP 2: Get contents.
|
|
|
var contents = await _.Contents.GetAsync(new ContentQuery |
|
|
var contents = await _.Contents.GetAsync( |
|
|
|
|
|
new ContentQuery |
|
|
{ |
|
|
{ |
|
|
Ids = result_0.Select(x => x.ContentId).ToHashSet() |
|
|
Ids = result_0.Select(x => x.ContentId).ToHashSet() |
|
|
}); |
|
|
}); |
|
|
@ -1237,10 +1346,12 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
public async Task Should_prevent_update() |
|
|
public async Task Should_prevent_update() |
|
|
{ |
|
|
{ |
|
|
// STEP 1: Create a new item.
|
|
|
// STEP 1: Create a new item.
|
|
|
var content = await _.Contents.CreateAsync(new TestEntityData |
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
{ |
|
|
{ |
|
|
Immutable = "v1" |
|
|
Immutable = "v1" |
|
|
}, ContentCreateOptions.AsPublish); |
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// STEP 2: Update content, but do not change immutable.
|
|
|
// STEP 2: Update content, but do not change immutable.
|
|
|
@ -1257,4 +1368,22 @@ public class ContentUpdateTests(ContentFixture fixture) : IClassFixture<ContentF |
|
|
Assert.Equal(400, ex.StatusCode); |
|
|
Assert.Equal(400, ex.StatusCode); |
|
|
Assert.Contains("Validation error: immutable.iv: Field cannot be changed", ex.ToString()); |
|
|
Assert.Contains("Validation error: immutable.iv: Field cannot be changed", ex.ToString()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
|
|
public async Task Should_create_content_and_only_return_subset_of_fields() |
|
|
|
|
|
{ |
|
|
|
|
|
// STEP 1: Create a new item.
|
|
|
|
|
|
var content = await _.Contents.CreateAsync( |
|
|
|
|
|
new TestEntityData |
|
|
|
|
|
{ |
|
|
|
|
|
String = "Hello", |
|
|
|
|
|
// No included in results.
|
|
|
|
|
|
Number = 42, |
|
|
|
|
|
}, |
|
|
|
|
|
ContentCreateOptions.AsPublish, |
|
|
|
|
|
QueryContext.Default.WithFields(TestEntityData.StringField)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal(0, content.Data.Number); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|