2023-02-23 07:30:16 +01:00
|
|
|
|
using NUnit.Framework;
|
2023-03-21 12:41:20 +01:00
|
|
|
|
using Umbraco.Cms.Core;
|
2023-02-23 07:30:16 +01:00
|
|
|
|
using Umbraco.Cms.Core.Services.OperationStatus;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services;
|
|
|
|
|
|
|
|
|
|
|
|
public partial class ContentEditingServiceTests
|
|
|
|
|
|
{
|
|
|
|
|
|
[TestCase(true)]
|
2023-08-28 08:56:57 +02:00
|
|
|
|
[TestCase(false)]
|
2024-01-22 15:58:18 +01:00
|
|
|
|
public async Task Can_Delete_FromRecycleBin(bool variant)
|
2023-02-23 07:30:16 +01:00
|
|
|
|
{
|
|
|
|
|
|
var content = await (variant ? CreateVariantContent() : CreateInvariantContent());
|
2023-08-28 08:56:57 +02:00
|
|
|
|
await ContentEditingService.MoveToRecycleBinAsync(content.Key, Constants.Security.SuperUserKey);
|
2023-02-23 07:30:16 +01:00
|
|
|
|
|
2024-01-22 15:58:18 +01:00
|
|
|
|
var result = await ContentEditingService.DeleteFromRecycleBinAsync(content.Key, Constants.Security.SuperUserKey);
|
2023-02-23 07:30:16 +01:00
|
|
|
|
Assert.IsTrue(result.Success);
|
|
|
|
|
|
Assert.AreEqual(ContentEditingOperationStatus.Success, result.Status);
|
|
|
|
|
|
|
|
|
|
|
|
// re-get and verify deletion
|
|
|
|
|
|
content = await ContentEditingService.GetAsync(content.Key);
|
|
|
|
|
|
Assert.IsNull(content);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-28 08:56:57 +02:00
|
|
|
|
[TestCase(true)]
|
|
|
|
|
|
[TestCase(false)]
|
2024-01-22 15:58:18 +01:00
|
|
|
|
public async Task Can_Delete_FromOutsideOfRecycleBin(bool variant)
|
2023-08-28 08:56:57 +02:00
|
|
|
|
{
|
|
|
|
|
|
var content = await (variant ? CreateVariantContent() : CreateInvariantContent());
|
|
|
|
|
|
|
|
|
|
|
|
var result = await ContentEditingService.DeleteAsync(content.Key, Constants.Security.SuperUserKey);
|
2024-01-22 15:58:18 +01:00
|
|
|
|
Assert.IsTrue(result.Success);
|
|
|
|
|
|
Assert.AreEqual(ContentEditingOperationStatus.Success, result.Status);
|
2023-08-28 08:56:57 +02:00
|
|
|
|
|
2024-01-22 15:58:18 +01:00
|
|
|
|
// re-get and verify deletion
|
2023-08-28 08:56:57 +02:00
|
|
|
|
content = await ContentEditingService.GetAsync(content.Key);
|
2024-01-22 15:58:18 +01:00
|
|
|
|
Assert.IsNull(content);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public async Task Cannot_Delete_Non_Existing()
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = await ContentEditingService.DeleteAsync(Guid.NewGuid(), Constants.Security.SuperUserKey);
|
|
|
|
|
|
Assert.IsFalse(result.Success);
|
|
|
|
|
|
Assert.AreEqual(ContentEditingOperationStatus.NotFound, result.Status);
|
2023-08-28 08:56:57 +02:00
|
|
|
|
}
|
2023-02-23 07:30:16 +01:00
|
|
|
|
}
|