Headless CMS and Content Managment Hub
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.
 
 
 
 
 

65 lines
1.8 KiB

// ==========================================================================
// GuardAssetTests.cs
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex Group
// All rights reserved.
// ==========================================================================
using Squidex.Domain.Apps.Write.Assets.Commands;
using Squidex.Infrastructure;
using Xunit;
namespace Squidex.Domain.Apps.Write.Assets.Guards
{
public class GuardAssetTests
{
[Fact]
public void CanRename_should_throw_exception_if_name_not_defined()
{
var command = new RenameAsset();
Assert.Throws<ValidationException>(() => GuardAsset.CanRename(command, "asset-name"));
}
[Fact]
public void CanRename_should_throw_exception_if_name_are_the_same()
{
var command = new RenameAsset { FileName = "asset-name" };
Assert.Throws<ValidationException>(() => GuardAsset.CanRename(command, "asset-name"));
}
[Fact]
public void CanRename_not_should_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);
}
}
}