예제 #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);
        }
예제 #2
0
        public async Task CanCreate_should_throw_exception_if_folder_not_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>());

            await ValidationAssert.ThrowsAsync(() => GuardAssetFolder.CanCreate(command, assetQuery),
                                               new ValidationError("Asset folder does not exist.", "ParentId"));
        }
예제 #3
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"));
        }
예제 #4
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);
        }