Browse Source

Test for Id patch.

pull/816/head
Sebastian 5 years ago
parent
commit
097819a547
  1. 35
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs
  2. 15
      backend/tools/TestSuite/TestSuite.Shared/Model/TestEntity.cs

35
backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs

@ -485,15 +485,46 @@ namespace TestSuite.ApiTests
try
{
// STEP 1: Create a new item.
content = await _.Contents.CreateAsync(new TestEntityData { Number = 1 }, true);
content = await _.Contents.CreateAsync(new TestEntityData { String = "test" }, true);
// STEP 2: Update the item and ensure that the data has changed.
// STEP 2: Path an item.
await _.Contents.PatchAsync(content.Id, new TestEntityData { Number = 1 });
// STEP 3: Update the item and ensure that the data has changed.
await _.Contents.PatchAsync(content.Id, new TestEntityData { Number = 2 });
var updated = await _.Contents.GetAsync(content.Id);
Assert.Equal(2, updated.Data.Number);
Assert.Equal("test", updated.Data.String);
}
finally
{
if (content != null)
{
await _.Contents.DeleteAsync(content.Id);
}
}
}
[Fact]
public async Task Should_patch_id_data_value()
{
TestEntity content = null;
try
{
// STEP 1: Create a new item.
content = await _.Contents.CreateAsync(new TestEntityData { Id = "id1" }, true);
// STEP 2: Update the item and ensure that the data has changed.
await _.Contents.PatchAsync(content.Id, new TestEntityData { Id = "id2" });
var updated = await _.Contents.GetAsync(content.Id);
Assert.Equal("id2", updated.Data.Id);
}
finally
{

15
backend/tools/TestSuite/TestSuite.Shared/Model/TestEntity.cs

@ -54,7 +54,15 @@ namespace TestSuite.Model
{
DefaultValue = "default"
}
}
},
new UpsertSchemaFieldDto
{
Name = TestEntityData.IdField,
Properties = new StringFieldPropertiesDto
{
IsRequired = false
}
},
},
Scripts = new SchemaScriptsDto
{
@ -81,11 +89,16 @@ namespace TestSuite.Model
public static readonly string GeoField = nameof(Geo).ToLowerInvariant();
public static readonly string IdField = nameof(Id).ToLowerInvariant();
public Dictionary<string, string> Localized { get; set; }
[JsonConverter(typeof(InvariantConverter))]
public int Number { get; set; }
[JsonConverter(typeof(InvariantConverter))]
public string Id { get; set; }
[JsonConverter(typeof(InvariantConverter))]
public string String { get; set; }

Loading…
Cancel
Save