Exemplo n.º 1
0
        public void CanAnnotate_should_throw_exception_if_nothing_defined()
        {
            var command = new AnnotateAsset();

            ValidationAssert.Throws(() => GuardAsset.CanAnnotate(command),
                                    new ValidationError("At least one property must be defined.", "FileName", "IsProtected", "Metadata", "Slug", "Tags"));
        }
Exemplo n.º 2
0
        public void CanAnnotate_should_throw_exception_if_nothing_defined()
        {
            var command = new AnnotateAsset();

            ValidationAssert.Throws(() => GuardAsset.CanAnnotate(command),
                                    new ValidationError("Either file name, slug, tags or metadata must be defined.", "FileName", "Slug", "Tags", "Metadata"));
        }
Exemplo n.º 3
0
        public void CanRename_should_throw_exception_if_name_not_defined()
        {
            var command = new RenameAsset();

            ValidationAssert.Throws(() => GuardAsset.CanRename(command, "asset-name"),
                                    new ValidationError("Name is required.", "FileName"));
        }
Exemplo n.º 4
0
        public async Task CanDelete_should_not_throw_exception()
        {
            var command = new DeleteAsset {
                AppId = appId
            };

            await GuardAsset.CanDelete(command, Asset(), contentRepository);
        }
Exemplo n.º 5
0
        public void CanAnnotate_should_not_throw_exception_if_empty()
        {
            var command = new AnnotateAsset {
                AppId = appId
            };

            GuardAsset.CanAnnotate(command);
        }
Exemplo n.º 6
0
        public void CanRename_not_should_throw_exception_if_name_are_different()
        {
            var command = new RenameAsset {
                FileName = "new-name"
            };

            GuardAsset.CanRename(command, "asset-name");
        }
Exemplo n.º 7
0
        public void CanDelete_should_not_throw_exception()
        {
            var command = new DeleteAsset {
                AppId = appId
            };

            GuardAsset.CanDelete(command);
        }
Exemplo n.º 8
0
        public async Task CanMove_should_not_throw_exception_when_folder_has_not_changed()
        {
            var command = new MoveAsset {
                AppId = appId, ParentId = DomainId.NewGuid()
            };

            await GuardAsset.CanMove(command, assetQuery, command.ParentId);
        }
Exemplo n.º 9
0
        public async Task CanCreate_should_not_throw_exception_when_added_to_root()
        {
            var command = new CreateAsset {
                AppId = appId
            };

            await GuardAsset.CanCreate(command, assetQuery);
        }
Exemplo n.º 10
0
        public async Task CanMove_should_not_throw_exception_when_added_to_root()
        {
            var command = new MoveAsset {
                AppId = appId
            };

            await GuardAsset.CanMove(command, assetQuery, DomainId.NewGuid());
        }
Exemplo n.º 11
0
        public void CanAnnotate_should_not_throw_exception_if_a_value_is_passed()
        {
            var command = new AnnotateAsset {
                AppId = appId, FileName = "new-name", Slug = "new-slug"
            };

            GuardAsset.CanAnnotate(command);
        }
Exemplo n.º 12
0
        public void CanRename_should_throw_exception_if_name_are_the_same()
        {
            var command = new RenameAsset {
                FileName = "asset-name"
            };

            Assert.Throws <ValidationException>(() => GuardAsset.CanRename(command, "asset-name"));
        }
Exemplo n.º 13
0
        public void CanAnnotate_should_not_throw_exception_if_names_are_different()
        {
            var command = new AnnotateAsset {
                FileName = "new-name", Slug = "new-slug"
            };

            GuardAsset.CanAnnotate(command, "asset-name", "asset-slug");
        }
Exemplo n.º 14
0
        public void CanRename_should_throw_exception_if_name_are_the_same()
        {
            var command = new RenameAsset {
                FileName = "asset-name"
            };

            ValidationAssert.Throws(() => GuardAsset.CanRename(command, "asset-name"),
                                    new ValidationError("Asset has already this name.", "FileName"));
        }
Exemplo n.º 15
0
        public async Task CanMove_should_throw_exception_when_folder_has_not_changed()
        {
            var command = new MoveAsset {
                ParentId = Guid.NewGuid()
            };

            await ValidationAssert.ThrowsAsync(() => GuardAsset.CanMove(command, assetQuery, command.ParentId),
                                               new ValidationError("Asset is already part of this folder.", "ParentId"));
        }
Exemplo n.º 16
0
        public void CanAnnotate_should_throw_exception_if_slugs_are_the_same()
        {
            var command = new AnnotateAsset {
                Slug = "asset-slug"
            };

            ValidationAssert.Throws(() => GuardAsset.CanAnnotate(command, "asset-name", "asset-slug"),
                                    new ValidationError("Asset has already this slug.", "Slug"));
        }
Exemplo n.º 17
0
        public async Task CanMove_should_throw_exception_when_folder_not_found()
        {
            var command = new MoveAsset {
                AppId = appId, ParentId = DomainId.NewGuid()
            };

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

            await ValidationAssert.ThrowsAsync(() => GuardAsset.CanMove(command, assetQuery, DomainId.NewGuid()),
                                               new ValidationError("Asset folder does not exist.", "ParentId"));
        }
Exemplo n.º 18
0
        public async Task CanMove_should_not_throw_exception_when_folder_found()
        {
            var command = new MoveAsset {
                AppId = appId, ParentId = DomainId.NewGuid()
            };

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

            await GuardAsset.CanMove(command, assetQuery, DomainId.NewGuid());
        }
Exemplo n.º 19
0
        public async Task CanCreate_should_not_throw_exception_when_folder_found()
        {
            var command = new CreateAsset {
                ParentId = Guid.NewGuid()
            };

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

            await GuardAsset.CanCreate(command, assetQuery);
        }
Exemplo n.º 20
0
        public async Task CanDelete_should_throw_exception_if_referenced()
        {
            var asset = Asset();

            var command = new DeleteAsset {
                AppId = appId, CheckReferrers = true
            };

            A.CallTo(() => contentRepository.HasReferrersAsync(appId.Id, asset.Id, SearchScope.All))
            .Returns(true);

            await Assert.ThrowsAsync <DomainException>(() => GuardAsset.CanDelete(command, asset, contentRepository));
        }
Exemplo n.º 21
0
        public void CanUpdate_should_not_throw_exception()
        {
            var command = new UpdateAsset();

            GuardAsset.CanUpdate(command);
        }
Exemplo n.º 22
0
        public void CanRename_should_throw_exception_if_name_not_defined()
        {
            var command = new RenameAsset();

            Assert.Throws <ValidationException>(() => GuardAsset.CanRename(command, "asset-name"));
        }