public void VerifyThatExceptionIsNotThrownWhenReferenceUnitDoesNotLeadToCircularDependency()
        {
            this.sideEffect = new PrefixedUnitSideEffect
            {
                ConversionBasedUnitService =
                    this.conversionBasedUnitService.Object,
                SiteReferenceDataLibraryService =
                    this.siteReferenceDataLibraryService.Object
            };

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

            Assert.DoesNotThrow(
                () => this.sideEffect.BeforeUpdate(
                    this.prefixedUnitC,
                    this.referenceDataLibraryA,
                    this.npgsqlTransaction,
                    "partition",
                    this.securityContext.Object,
                    this.rawUpdateInfo));
        }
        public void VerifyThatExceptionIsThrownWhenReferenceUnitIsOutOfChainOrLeadsToCircularDependency()
        {
            this.sideEffect = new PrefixedUnitSideEffect
            {
                ConversionBasedUnitService =
                    this.conversionBasedUnitService.Object,
                SiteReferenceDataLibraryService =
                    this.siteReferenceDataLibraryService.Object
            };

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

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

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

            Assert.Throws <AcyclicValidationException>(
                () => this.sideEffect.BeforeUpdate(
                    this.prefixedUnitC,
                    this.referenceDataLibraryA,
                    this.npgsqlTransaction,
                    "partition",
                    this.securityContext.Object,
                    this.rawUpdateInfo));
        }
        public void VerifyThatExceptionIsThrownWhenReferenceIsUnitItself()
        {
            this.sideEffect = new PrefixedUnitSideEffect
            {
                ConversionBasedUnitService =
                    this.conversionBasedUnitService.Object,
                SiteReferenceDataLibraryService =
                    this.siteReferenceDataLibraryService.Object
            };

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

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