コード例 #1
0
ファイル: GuardAssetTests.cs プロジェクト: vmnet04/squidex
        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"));
        }
コード例 #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"));
        }
コード例 #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"));
        }
コード例 #4
0
        public async Task CanDelete_should_not_throw_exception()
        {
            var command = new DeleteAsset {
                AppId = appId
            };

            await GuardAsset.CanDelete(command, Asset(), contentRepository);
        }
コード例 #5
0
        public void CanAnnotate_should_not_throw_exception_if_empty()
        {
            var command = new AnnotateAsset {
                AppId = appId
            };

            GuardAsset.CanAnnotate(command);
        }
コード例 #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");
        }
コード例 #7
0
ファイル: GuardAssetTests.cs プロジェクト: sejohn2020/squidex
        public void CanDelete_should_not_throw_exception()
        {
            var command = new DeleteAsset {
                AppId = appId
            };

            GuardAsset.CanDelete(command);
        }
コード例 #8
0
ファイル: GuardAssetTests.cs プロジェクト: sejohn2020/squidex
        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);
        }
コード例 #9
0
ファイル: GuardAssetTests.cs プロジェクト: sejohn2020/squidex
        public async Task CanCreate_should_not_throw_exception_when_added_to_root()
        {
            var command = new CreateAsset {
                AppId = appId
            };

            await GuardAsset.CanCreate(command, assetQuery);
        }
コード例 #10
0
ファイル: GuardAssetTests.cs プロジェクト: sejohn2020/squidex
        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());
        }
コード例 #11
0
ファイル: GuardAssetTests.cs プロジェクト: sejohn2020/squidex
        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);
        }
コード例 #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"));
        }
コード例 #13
0
ファイル: GuardAssetTests.cs プロジェクト: xiaopohou/squidex
        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");
        }
コード例 #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"));
        }
コード例 #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"));
        }
コード例 #16
0
ファイル: GuardAssetTests.cs プロジェクト: xiaopohou/squidex
        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"));
        }
コード例 #17
0
ファイル: GuardAssetTests.cs プロジェクト: sejohn2020/squidex
        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"));
        }
コード例 #18
0
ファイル: GuardAssetTests.cs プロジェクト: sejohn2020/squidex
        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());
        }
コード例 #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);
        }
コード例 #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));
        }
コード例 #21
0
        public void CanUpdate_should_not_throw_exception()
        {
            var command = new UpdateAsset();

            GuardAsset.CanUpdate(command);
        }
コード例 #22
0
        public void CanRename_should_throw_exception_if_name_not_defined()
        {
            var command = new RenameAsset();

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