コード例 #1
0
        public async Task CanCreate_should_not_throw_exception_when_added_to_root()
        {
            var command = new CreateAssetFolder {
                FolderName = "My Folder"
            };

            await GuardAssetFolder.CanCreate(command, assetQuery);
        }
コード例 #2
0
        public async Task CanCreate_should_throw_exception_when_folder_name_not_defined()
        {
            var command = new CreateAssetFolder();

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

            await ValidationAssert.ThrowsAsync(() => GuardAssetFolder.CanCreate(command, assetQuery),
                                               new ValidationError("Folder name is required.", "FolderName"));
        }
コード例 #3
0
        public async Task CanCreate_should_throw_exception_when_folder_not_found()
        {
            var command = new CreateAssetFolder {
                FolderName = "My Folder", ParentId = Guid.NewGuid()
            };

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

            await ValidationAssert.ThrowsAsync(() => GuardAssetFolder.CanCreate(command, assetQuery),
                                               new ValidationError("Asset folder does not exist.", "ParentId"));
        }
コード例 #4
0
        public async Task CanCreate_should_not_throw_exception_when_folder_found()
        {
            var command = new CreateAssetFolder {
                FolderName = "My Folder", ParentId = Guid.NewGuid()
            };

            A.CallTo(() => assetQuery.FindAssetFolderAsync(command.ParentId))
            .Returns(new List <IAssetFolderEntity> {
                CreateFolder()
            });

            await GuardAssetFolder.CanCreate(command, assetQuery);
        }