Ejemplo n.º 1
0
        public void VerifyThatExceptionIsNotThrownWhenGeneralReferenceDoesNotLeadToCircularDependency()
        {
            this.sideEffect = new SpecializedQuantityKindSideEffect
            {
                SpecializedQuantityKindService =
                    this.specializedQuantityKindService.Object,
                SiteReferenceDataLibraryService =
                    this.siteReferenceDataLibraryService.Object
            };

            // There is a chain a -> b -> c
            this.rawUpdateInfo = new ClasslessDTO()
            {
                { TestKey, this.specializedQuantityKindD.Iid }
            };

            Assert.DoesNotThrow(
                () => this.sideEffect.BeforeUpdate(
                    this.specializedQuantityKindC,
                    this.referenceDataLibraryA,
                    this.npgsqlTransaction,
                    "partition",
                    this.securityContext.Object,
                    this.rawUpdateInfo));
        }
Ejemplo n.º 2
0
        public void VerifyThatExceptionIsThrownWhenGeneralReferenceIsOutOfChainOrLeadsToCircularDependency()
        {
            this.sideEffect = new SpecializedQuantityKindSideEffect
            {
                SpecializedQuantityKindService =
                    this.specializedQuantityKindService.Object,
                SiteReferenceDataLibraryService =
                    this.siteReferenceDataLibraryService.Object
            };

            // Out of chain
            this.rawUpdateInfo = new ClasslessDTO()
            {
                { TestKey, this.specializedQuantityKindE.Iid }
            };

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

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

            Assert.Throws <AcyclicValidationException>(
                () => this.sideEffect.BeforeUpdate(
                    this.specializedQuantityKindC,
                    this.referenceDataLibraryA,
                    this.npgsqlTransaction,
                    "partition",
                    this.securityContext.Object,
                    this.rawUpdateInfo));
        }
Ejemplo n.º 3
0
        public void VerifyThatExceptionIsThrownWhenGeneralReferenceIsKindItself()
        {
            this.sideEffect = new SpecializedQuantityKindSideEffect
            {
                SpecializedQuantityKindService =
                    this.specializedQuantityKindService.Object,
                SiteReferenceDataLibraryService =
                    this.siteReferenceDataLibraryService.Object
            };

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

            Assert.Throws <AcyclicValidationException>(
                () => this.sideEffect.BeforeUpdate(
                    this.specializedQuantityKindA,
                    this.referenceDataLibraryA,
                    this.npgsqlTransaction,
                    "partition",
                    this.securityContext.Object,
                    this.rawUpdateInfo));
        }
        public void Setup()
        {
            this.npgsqlTransaction = null;
            this.securityContext   = new Mock <ISecurityContext>();

            // There is a chain a -> b -> c
            this.specializedQuantityKindC = new SpecializedQuantityKind {
                Iid = Guid.NewGuid()
            };
            this.specializedQuantityKindB =
                new SpecializedQuantityKind {
                Iid = Guid.NewGuid(), General = this.specializedQuantityKindC.Iid
            };
            this.specializedQuantityKindA =
                new SpecializedQuantityKind {
                Iid = Guid.NewGuid(), General = this.specializedQuantityKindB.Iid
            };
            this.specializedQuantityKindD = new SpecializedQuantityKind {
                Iid = Guid.NewGuid()
            };

            // Outside the rdl chain
            this.specializedQuantityKindE = new SpecializedQuantityKind {
                Iid = Guid.NewGuid()
            };

            // There is a chain librayA -> LibraryB
            this.referenceDataLibraryB = new SiteReferenceDataLibrary
            {
                Iid           = Guid.NewGuid(),
                ParameterType =
                {
                    this.specializedQuantityKindD.Iid
                }
            };
            this.referenceDataLibraryA = new ModelReferenceDataLibrary
            {
                Iid           = Guid.NewGuid(),
                ParameterType =
                {
                    this.specializedQuantityKindA.Iid,
                    this.specializedQuantityKindB.Iid,
                    this.specializedQuantityKindC.Iid
                },
                RequiredRdl = this.referenceDataLibraryB.Iid
            };

            this.siteReferenceDataLibraryService = new Mock <ISiteReferenceDataLibraryService>();
            this.siteReferenceDataLibraryService
            .Setup(
                x => x.Get(
                    this.npgsqlTransaction,
                    It.IsAny <string>(),
                    null,
                    It.IsAny <ISecurityContext>()))
            .Returns(new List <ReferenceDataLibrary> {
                this.referenceDataLibraryB
            });

            this.specializedQuantityKindService = new Mock <ISpecializedQuantityKindService>();
            this.specializedQuantityKindService
            .Setup(
                x => x.Get(
                    this.npgsqlTransaction,
                    It.IsAny <string>(),
                    new List <Guid>
            {
                this.specializedQuantityKindD.Iid,
                this.specializedQuantityKindA.Iid,
                this.specializedQuantityKindB.Iid,
                this.specializedQuantityKindC.Iid
            },
                    It.IsAny <ISecurityContext>())).Returns(
                new List <SpecializedQuantityKind>
            {
                this.specializedQuantityKindD,
                this.specializedQuantityKindA,
                this.specializedQuantityKindB,
                this.specializedQuantityKindC
            });

            this.sideEffect = new SpecializedQuantityKindSideEffect
            {
                SpecializedQuantityKindService  = this.specializedQuantityKindService.Object,
                SiteReferenceDataLibraryService = this.siteReferenceDataLibraryService.Object
            };
        }