Browse Source

Fix for recreation.

pull/664/head
Sebastian 5 years ago
parent
commit
29fc6c4c47
  1. 2
      backend/src/Squidex.Infrastructure/Commands/DomainObject.cs
  2. 46
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs
  3. 2
      backend/tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj
  4. 2
      backend/tools/TestSuite/TestSuite.LoadTests/TestSuite.LoadTests.csproj
  5. 2
      backend/tools/TestSuite/TestSuite.Shared/TestSuite.Shared.csproj

2
backend/src/Squidex.Infrastructure/Commands/DomainObject.cs

@ -182,6 +182,8 @@ namespace Squidex.Infrastructure.Commands
if (persistence != null) if (persistence != null)
{ {
await persistence.DeleteAsync(); await persistence.DeleteAsync();
Setup(uniqueId);
} }
snapshots.Clear(); snapshots.Clear();

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

@ -505,15 +505,17 @@ namespace TestSuite.ApiTests
} }
} }
[Fact] [Theory]
public async Task Should_delete_item() [InlineData(true)]
[InlineData(false)]
public async Task Should_delete_item(bool permanent)
{ {
// STEP 1: Create a new item. // STEP 1: Create a new item.
var content = await _.Contents.CreateAsync(new TestEntityData { Number = 2 }, true); var content = await _.Contents.CreateAsync(new TestEntityData { Number = 2 }, true);
// STEP 2: Delete the item. // STEP 2: Delete the item.
await _.Contents.DeleteAsync(content.Id); await _.Contents.DeleteAsync(content.Id, permanent);
// STEP 3: Retrieve all items and ensure that the deleted item does not exist. // STEP 3: Retrieve all items and ensure that the deleted item does not exist.
@ -521,5 +523,43 @@ namespace TestSuite.ApiTests
Assert.DoesNotContain(updated.Items, x => x.Id == content.Id); Assert.DoesNotContain(updated.Items, x => x.Id == content.Id);
} }
[Theory]
[InlineData(true)]
[InlineData(false)]
public async Task Should_recreate_delete_item(bool permanent)
{
// STEP 1: Create a new item.
var content_1 = await _.Contents.CreateAsync(new TestEntityData { Number = 2 }, true);
// STEP 2: Delete the item.
await _.Contents.DeleteAsync(content_1.Id, permanent);
// STEP 3: Recreate the item with the same id.
var content_2 = await _.Contents.CreateAsync(new TestEntityData { Number = 2 }, content_1.Id, true);
Assert.Equal(Status.Published, content_2.Status);
}
[Theory]
[InlineData(true)]
[InlineData(false)]
public async Task Should_recreate_delete_item_with_upsert(bool permanent)
{
// STEP 1: Create a new item.
var content_1 = await _.Contents.CreateAsync(new TestEntityData { Number = 2 }, true);
// STEP 2: Delete the item.
await _.Contents.DeleteAsync(content_1.Id, permanent);
// STEP 3: Recreate the item with the same id.
var content_2 = await _.Contents.UpsertAsync(content_1.Id, new TestEntityData { Number = 2 }, true);
Assert.Equal(Status.Published, content_2.Status);
}
} }
} }

2
backend/tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj

@ -4,7 +4,7 @@
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" /> <PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="2.4.1" />

2
backend/tools/TestSuite/TestSuite.LoadTests/TestSuite.LoadTests.csproj

@ -4,7 +4,7 @@
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" /> <PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="2.4.1" />

2
backend/tools/TestSuite/TestSuite.Shared/TestSuite.Shared.csproj

@ -11,7 +11,7 @@
</PackageReference> </PackageReference>
<PackageReference Include="Lazy.Fody" Version="1.9.0" PrivateAssets="all" /> <PackageReference Include="Lazy.Fody" Version="1.9.0" PrivateAssets="all" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" /> <PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.ClientLibrary" Version="6.11.0" /> <PackageReference Include="Squidex.ClientLibrary" Version="6.16.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="2.4.1" />
</ItemGroup> </ItemGroup>

Loading…
Cancel
Save