public async Task CanCreate_should_not_throw_exception_if_added_to_root()
        {
            var command = new CreateAssetFolder {
                AppId = appId, FolderName = "My Folder"
            };

            await GuardAssetFolder.CanCreate(command, 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 void CanRename_should_not_throw_exception_if_names_are_different()
        {
            var command = new RenameAssetFolder {
                AppId = appId, FolderName = "New Folder Name"
            };

            GuardAssetFolder.CanRename(command);
        }
        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);
        }
Beispiel #5
0
        public void CanDelete_should_not_throw_exception()
        {
            var command = new DeleteAssetFolder {
                AppId = appId
            };

            GuardAssetFolder.CanDelete(command);
        }
        public void CanRename_should_throw_exception_if_folder_name_is_empty()
        {
            var command = new RenameAssetFolder {
                AppId = appId
            };

            ValidationAssert.Throws(() => GuardAssetFolder.CanRename(command),
                                    new ValidationError("Folder name is required.", "FolderName"));
        }
        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 CanCreate_should_throw_exception_if_folder_name_not_defined()
        {
            var command = new CreateAssetFolder {
                AppId = appId
            };

            A.CallTo(() => assetQuery.FindAssetFolderAsync(appId.Id, command.ParentId, A <CancellationToken> ._))
            .Returns(new List <IAssetFolderEntity>());

            await ValidationAssert.ThrowsAsync(() => GuardAssetFolder.CanCreate(command, assetQuery),
                                               new ValidationError("Folder name is required.", "FolderName"));
        }
Beispiel #9
0
        public async Task CanCreate_should_throw_exception_when_folder_not_found()
        {
            var command = new CreateAssetFolder {
                AppId = appId, FolderName = "My Folder", ParentId = DomainId.NewGuid()
            };

            A.CallTo(() => assetQuery.FindAssetFolderAsync(appId.Id, command.ParentId))
            .Returns(new List <IAssetFolderEntity>());

            await ValidationAssert.ThrowsAsync(() => GuardAssetFolder.CanCreate(command, assetQuery),
                                               new ValidationError("Asset folder does not exist.", "ParentId"));
        }
Beispiel #10
0
        public async Task CanCreate_should_not_throw_exception_if_folder_found()
        {
            var command = new CreateAssetFolder {
                AppId = appId, FolderName = "My Folder", ParentId = DomainId.NewGuid()
            };

            A.CallTo(() => assetQuery.FindAssetFolderAsync(appId.Id, command.ParentId, A <CancellationToken> ._))
            .Returns(new List <IAssetFolderEntity> {
                AssetFolder()
            });

            await GuardAssetFolder.CanCreate(command, assetQuery);
        }
Beispiel #11
0
        public async Task CanMove_should_not_throw_exception_when_folder_found()
        {
            var command = new MoveAssetFolder {
                AppId = appId, ParentId = DomainId.NewGuid()
            };

            A.CallTo(() => assetQuery.FindAssetFolderAsync(appId.Id, command.ParentId))
            .Returns(new List <IAssetFolderEntity> {
                AssetFolder()
            });

            await GuardAssetFolder.CanMove(command, AssetFolder(), assetQuery);
        }
Beispiel #12
0
        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"));
        }