public async Task CanMove_should_not_throw_exception_if_folder_has_not_changed() { var command = new MoveAssetFolder { AppId = appId, ParentId = DomainId.NewGuid() }; await GuardAssetFolder.CanMove(command, AssetFolder(parentId : command.ParentId), assetQuery); }
public async Task CanMove_should_not_throw_exception_if_added_to_root() { var command = new MoveAssetFolder { AppId = appId }; await GuardAssetFolder.CanMove(command, AssetFolder(), assetQuery); }
public async Task CanMove_should_throw_exception_if_folder_not_found() { var command = new MoveAssetFolder { AppId = appId, ParentId = DomainId.NewGuid() }; A.CallTo(() => assetQuery.FindAssetFolderAsync(appId.Id, command.ParentId, A <CancellationToken> ._)) .Returns(new List <IAssetFolderEntity>()); await ValidationAssert.ThrowsAsync(() => GuardAssetFolder.CanMove(command, AssetFolder(), assetQuery), new ValidationError("Asset folder does not exist.", "ParentId")); }
public async Task CanMove_should_not_throw_exception_if_folder_found() { var command = new MoveAssetFolder { AppId = appId, ParentId = DomainId.NewGuid() }; A.CallTo(() => assetQuery.FindAssetFolderAsync(appId.Id, command.ParentId, A <CancellationToken> ._)) .Returns(new List <IAssetFolderEntity> { AssetFolder() }); await GuardAssetFolder.CanMove(command, AssetFolder(), assetQuery); }
public async Task CanMove_should_throw_exception_if_adding_to_its_own_child() { var id = DomainId.NewGuid(); var command = new MoveAssetFolder { AppId = appId, ParentId = DomainId.NewGuid() }; A.CallTo(() => assetQuery.FindAssetFolderAsync(appId.Id, command.ParentId, A <CancellationToken> ._)) .Returns(new List <IAssetFolderEntity> { AssetFolder(id), AssetFolder(command.ParentId) }); await ValidationAssert.ThrowsAsync(() => GuardAssetFolder.CanMove(command, AssetFolder(id), assetQuery), new ValidationError("Cannot add folder to its own child.", "ParentId")); }