mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.0 KiB
67 lines
2.0 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using Squidex.Domain.Apps.Entities.Assets.Commands;
|
|
using Squidex.Domain.Apps.Entities.TestHelpers;
|
|
using Squidex.Infrastructure;
|
|
using Xunit;
|
|
|
|
namespace Squidex.Domain.Apps.Entities.Assets.Guards
|
|
{
|
|
public class GuardAssetTests
|
|
{
|
|
[Fact]
|
|
public void CanRename_should_throw_exception_if_name_not_defined()
|
|
{
|
|
var command = new RenameAsset();
|
|
|
|
ValidationAssert.Throws(() => GuardAsset.CanRename(command, "asset-name"),
|
|
new ValidationError("Name is required.", "FileName"));
|
|
}
|
|
|
|
[Fact]
|
|
public void CanRename_should_throw_exception_if_name_are_the_same()
|
|
{
|
|
var command = new RenameAsset { FileName = "asset-name" };
|
|
|
|
ValidationAssert.Throws(() => GuardAsset.CanRename(command, "asset-name"),
|
|
new ValidationError("Asset has already this name.", "FileName"));
|
|
}
|
|
|
|
[Fact]
|
|
public void CanRename_should_not_throw_exception_if_name_are_different()
|
|
{
|
|
var command = new RenameAsset { FileName = "new-name" };
|
|
|
|
GuardAsset.CanRename(command, "asset-name");
|
|
}
|
|
|
|
[Fact]
|
|
public void CanCreate_should_not_throw_exception()
|
|
{
|
|
var command = new CreateAsset();
|
|
|
|
GuardAsset.CanCreate(command);
|
|
}
|
|
|
|
[Fact]
|
|
public void CanUpdate_should_not_throw_exception()
|
|
{
|
|
var command = new UpdateAsset();
|
|
|
|
GuardAsset.CanUpdate(command);
|
|
}
|
|
|
|
[Fact]
|
|
public void CanDelete_should_not_throw_exception()
|
|
{
|
|
var command = new DeleteAsset();
|
|
|
|
GuardAsset.CanDelete(command);
|
|
}
|
|
}
|
|
}
|
|
|