示例#1
0
        public void VerifyThatExceptionIsThrownWhenContainingFolderIsOutOfChainOrLeadsToCircularDependencyOnCreate()
        {
            this.sideEffect = new FolderSideEffect()
            {
                FolderService = this.folderService.Object
            };

            // Out of the store
            var id = this.folderD.Iid;

            this.folderA.ContainingFolder = id;

            Assert.Throws <AcyclicValidationException>(
                () => this.sideEffect.BeforeCreate(
                    this.folderA,
                    this.fileStore,
                    this.npgsqlTransaction,
                    "partition",
                    this.securityContext.Object));
            this.folderA.ContainingFolder = this.folderB.Iid;

            // Leads to circular dependency
            id = this.folderA.Iid;
            this.folderC.ContainingFolder = id;

            Assert.Throws <AcyclicValidationException>(
                () => this.sideEffect.BeforeCreate(
                    this.folderC,
                    this.fileStore,
                    this.npgsqlTransaction,
                    "partition",
                    this.securityContext.Object));
        }
        public void Setup()
        {
            this.npgsqlTransaction = null;
            this.securityContext   = new Mock <ISecurityContext>();

            // There is a chain a -> b -> c
            this.folderD = new Folder {
                Iid = Guid.NewGuid()
            };
            this.folderC = new Folder {
                Iid = Guid.NewGuid()
            };
            this.folderB = new Folder {
                Iid = Guid.NewGuid(), ContainingFolder = this.folderC.Iid
            };
            this.folderA = new Folder {
                Iid = Guid.NewGuid(), ContainingFolder = this.folderB.Iid
            };

            this.fileStore = new DomainFileStore
            {
                Iid    = Guid.NewGuid(),
                Folder =
                {
                    this.folderA.Iid, this.folderB.Iid, this.folderC.Iid
                }
            };

            this.domainFileStoreService = new Mock <IDomainFileStoreService>();
            this.folderService          = new Mock <IFolderService>();

            this.folderService
            .Setup(
                x => x.Get(
                    this.npgsqlTransaction,
                    It.IsAny <string>(),
                    new List <Guid> {
                this.folderA.Iid, this.folderB.Iid, this.folderC.Iid
            },
                    It.IsAny <ISecurityContext>()))
            .Returns(new List <Folder> {
                this.folderA, this.folderB, this.folderC
            });

            this.sideEffect = new FolderSideEffect
            {
                FolderService          = this.folderService.Object,
                DomainFileStoreService = this.domainFileStoreService.Object
            };
        }
示例#3
0
        public void VerifyThatExceptionIsThrownWhenContainingFolderIsFolderItselfOnCreate()
        {
            this.sideEffect = new FolderSideEffect()
            {
                FolderService = this.folderService.Object
            };

            var id = this.folderA.Iid;

            this.folderA.ContainingFolder = id;

            Assert.Throws <AcyclicValidationException>(
                () => this.sideEffect.BeforeCreate(
                    this.folderA,
                    this.fileStore,
                    this.npgsqlTransaction,
                    "partition",
                    this.securityContext.Object));
        }
示例#4
0
        public void VerifyThatExceptionIsThrownWhenContainingFolderIsFolderItselfOnUpdate()
        {
            this.sideEffect = new FolderSideEffect()
            {
                FolderService = this.folderService.Object
            };

            this.rawUpdateInfo = new ClasslessDTO()
            {
                { TestKey, this.folderA.Iid }
            };

            Assert.Throws <AcyclicValidationException>(
                () => this.sideEffect.BeforeUpdate(
                    this.folderA,
                    this.fileStore,
                    this.npgsqlTransaction,
                    "partition",
                    this.securityContext.Object,
                    this.rawUpdateInfo));
        }
示例#5
0
        public void VerifyThatExceptionIsThrownWhenContainingFolderIsOutOfChainOrLeadsToCircularDependencyOnUpdate()
        {
            this.sideEffect = new FolderSideEffect()
            {
                FolderService = this.folderService.Object
            };

            // Out of the store
            this.rawUpdateInfo = new ClasslessDTO()
            {
                { TestKey, this.folderD.Iid }
            };

            Assert.Throws <AcyclicValidationException>(
                () => this.sideEffect.BeforeUpdate(
                    this.folderA,
                    this.fileStore,
                    this.npgsqlTransaction,
                    "partition",
                    this.securityContext.Object,
                    this.rawUpdateInfo));

            // Leads to circular dependency
            this.rawUpdateInfo = new ClasslessDTO()
            {
                { TestKey, this.folderA.Iid }
            };

            Assert.Throws <AcyclicValidationException>(
                () => this.sideEffect.BeforeUpdate(
                    this.folderC,
                    this.fileStore,
                    this.npgsqlTransaction,
                    "partition",
                    this.securityContext.Object,
                    this.rawUpdateInfo));
        }