public void CanAnnotate_should_throw_exception_if_nothing_defined() { var command = new AnnotateAsset(); ValidationAssert.Throws(() => GuardAsset.CanAnnotate(command), new ValidationError("At least one property must be defined.", "FileName", "IsProtected", "Metadata", "Slug", "Tags")); }
public void CanAnnotate_should_throw_exception_if_nothing_defined() { var command = new AnnotateAsset(); ValidationAssert.Throws(() => GuardAsset.CanAnnotate(command), new ValidationError("Either file name, slug, tags or metadata must be defined.", "FileName", "Slug", "Tags", "Metadata")); }
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")); }
public async Task CanDelete_should_not_throw_exception() { var command = new DeleteAsset { AppId = appId }; await GuardAsset.CanDelete(command, Asset(), contentRepository); }
public void CanAnnotate_should_not_throw_exception_if_empty() { var command = new AnnotateAsset { AppId = appId }; GuardAsset.CanAnnotate(command); }
public void CanRename_not_should_throw_exception_if_name_are_different() { var command = new RenameAsset { FileName = "new-name" }; GuardAsset.CanRename(command, "asset-name"); }
public void CanDelete_should_not_throw_exception() { var command = new DeleteAsset { AppId = appId }; GuardAsset.CanDelete(command); }
public async Task CanMove_should_not_throw_exception_when_folder_has_not_changed() { var command = new MoveAsset { AppId = appId, ParentId = DomainId.NewGuid() }; await GuardAsset.CanMove(command, assetQuery, command.ParentId); }
public async Task CanCreate_should_not_throw_exception_when_added_to_root() { var command = new CreateAsset { AppId = appId }; await GuardAsset.CanCreate(command, assetQuery); }
public async Task CanMove_should_not_throw_exception_when_added_to_root() { var command = new MoveAsset { AppId = appId }; await GuardAsset.CanMove(command, assetQuery, DomainId.NewGuid()); }
public void CanAnnotate_should_not_throw_exception_if_a_value_is_passed() { var command = new AnnotateAsset { AppId = appId, FileName = "new-name", Slug = "new-slug" }; GuardAsset.CanAnnotate(command); }
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")); }
public void CanAnnotate_should_not_throw_exception_if_names_are_different() { var command = new AnnotateAsset { FileName = "new-name", Slug = "new-slug" }; GuardAsset.CanAnnotate(command, "asset-name", "asset-slug"); }
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")); }
public async Task CanMove_should_throw_exception_when_folder_has_not_changed() { var command = new MoveAsset { ParentId = Guid.NewGuid() }; await ValidationAssert.ThrowsAsync(() => GuardAsset.CanMove(command, assetQuery, command.ParentId), new ValidationError("Asset is already part of this folder.", "ParentId")); }
public void CanAnnotate_should_throw_exception_if_slugs_are_the_same() { var command = new AnnotateAsset { Slug = "asset-slug" }; ValidationAssert.Throws(() => GuardAsset.CanAnnotate(command, "asset-name", "asset-slug"), new ValidationError("Asset has already this slug.", "Slug")); }
public async Task CanMove_should_throw_exception_when_folder_not_found() { var command = new MoveAsset { AppId = appId, ParentId = DomainId.NewGuid() }; A.CallTo(() => assetQuery.FindAssetFolderAsync(appId.Id, command.ParentId)) .Returns(new List <IAssetFolderEntity>()); await ValidationAssert.ThrowsAsync(() => GuardAsset.CanMove(command, assetQuery, DomainId.NewGuid()), new ValidationError("Asset folder does not exist.", "ParentId")); }
public async Task CanMove_should_not_throw_exception_when_folder_found() { var command = new MoveAsset { AppId = appId, ParentId = DomainId.NewGuid() }; A.CallTo(() => assetQuery.FindAssetFolderAsync(appId.Id, command.ParentId)) .Returns(new List <IAssetFolderEntity> { CreateFolder() }); await GuardAsset.CanMove(command, assetQuery, DomainId.NewGuid()); }
public async Task CanCreate_should_not_throw_exception_when_folder_found() { var command = new CreateAsset { ParentId = Guid.NewGuid() }; A.CallTo(() => assetQuery.FindAssetFolderAsync(command.ParentId)) .Returns(new List <IAssetFolderEntity> { CreateFolder() }); await GuardAsset.CanCreate(command, assetQuery); }
public async Task CanDelete_should_throw_exception_if_referenced() { var asset = Asset(); var command = new DeleteAsset { AppId = appId, CheckReferrers = true }; A.CallTo(() => contentRepository.HasReferrersAsync(appId.Id, asset.Id, SearchScope.All)) .Returns(true); await Assert.ThrowsAsync <DomainException>(() => GuardAsset.CanDelete(command, asset, contentRepository)); }
public void CanUpdate_should_not_throw_exception() { var command = new UpdateAsset(); GuardAsset.CanUpdate(command); }
public void CanRename_should_throw_exception_if_name_not_defined() { var command = new RenameAsset(); Assert.Throws <ValidationException>(() => GuardAsset.CanRename(command, "asset-name")); }