Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public async Task CanMove_should_not_throw_exception_if_added_to_root()
        {
            var command = new MoveAssetFolder {
                AppId = appId
            };

            await GuardAssetFolder.CanMove(command, AssetFolder(), assetQuery);
        }
Ejemplo n.º 3
0
        public void CanRename_should_not_throw_exception_if_names_are_different()
        {
            var command = new RenameAssetFolder {
                AppId = appId, FolderName = "New Folder Name"
            };

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

            GuardAssetFolder.CanDelete(command);
        }
Ejemplo n.º 6
0
        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"));
        }
Ejemplo n.º 7
0
        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"));
        }
Ejemplo n.º 8
0
        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"));
        }
Ejemplo n.º 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"));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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"));
        }