Browse Source

Validation tests for assets improved.

pull/303/head
Sebastian 8 years ago
parent
commit
b9554f89c2
  1. 2
      src/Squidex.Domain.Apps.Entities/Assets/Guards/GuardAsset.cs
  2. 7
      tests/Squidex.Domain.Apps.Entities.Tests/Assets/Guards/GuardAssetTests.cs

2
src/Squidex.Domain.Apps.Entities/Assets/Guards/GuardAsset.cs

@ -25,7 +25,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.Guards
if (string.Equals(command.FileName, oldName))
{
error(new ValidationError("Name is equal to old name.", nameof(command.FileName)));
error(new ValidationError("Asset has already this name.", nameof(command.FileName)));
}
});
}

7
tests/Squidex.Domain.Apps.Entities.Tests/Assets/Guards/GuardAssetTests.cs

@ -6,6 +6,7 @@
// ==========================================================================
using Squidex.Domain.Apps.Entities.Assets.Commands;
using Squidex.Domain.Apps.Entities.TestHelpers;
using Squidex.Infrastructure;
using Xunit;
@ -18,7 +19,8 @@ namespace Squidex.Domain.Apps.Entities.Assets.Guards
{
var command = new RenameAsset();
Assert.Throws<ValidationException>(() => GuardAsset.CanRename(command, "asset-name"));
ValidationAssert.Throws(() => GuardAsset.CanRename(command, "asset-name"),
new ValidationError("Name is required.", "FileName"));
}
[Fact]
@ -26,7 +28,8 @@ namespace Squidex.Domain.Apps.Entities.Assets.Guards
{
var command = new RenameAsset { FileName = "asset-name" };
Assert.Throws<ValidationException>(() => GuardAsset.CanRename(command, "asset-name"));
ValidationAssert.Throws(() => GuardAsset.CanRename(command, "asset-name"),
new ValidationError("Asset has already this name.", "FileName"));
}
[Fact]

Loading…
Cancel
Save