Пример #1
0
        private static DeploymentStepDecision RemoveCreateElement(DeploymentStep step, KeeperDecider decider)
        {
            var createStep = step as CreateElementStep;

            return(createStep == null ? null : new DeploymentStepDecision()
            {
                Remove = decider.ShouldRemoveFromPlan(createStep.SourceElement?.Name ?? new ObjectIdentifier(), createStep.SourceElement?.ObjectType, StepType.Create),
                StepType = StepType.Create,
                ObjectName = createStep.SourceElement?.Name?.ToString() ?? ""
            });
        }
Пример #2
0
        private static DeploymentStepDecision RemoveDataLossCheckStep(DeploymentStep step, KeeperDecider decider)
        {
            var dlcStep = new DataLossCheckStep(step);

            return(!dlcStep.IsDataLossCheck ? null : new DeploymentStepDecision()
            {
                Remove = decider.ShouldRemoveFromPlan(dlcStep.ObjectName, ModelSchema.Table, StepType.Drop),
                StepType = StepType.DataLossCheck,
                ObjectName = dlcStep.ObjectName.ToString()
            });
        }
Пример #3
0
        private static DeploymentStepDecision RemoveDropStep(DeploymentStep step, KeeperDecider decider)
        {
            var dropStep = step as DropElementStep;

            return(dropStep == null ? null : new DeploymentStepDecision()
            {
                Remove = decider.ShouldRemoveFromPlan(dropStep.TargetElement?.Name ?? new ObjectIdentifier(), dropStep.TargetElement?.ObjectType, StepType.Drop),
                StepType = StepType.Drop,
                ObjectName = dropStep.TargetElement?.Name?.ToString() ?? ""
            });
        }
Пример #4
0
        public void Create_Step_Does_Not_Call_Keep_Rule()
        {
            var keepRule = new Mock <FilterRule>();

            keepRule.Setup(p => p.Operation()).Returns(FilterOperation.Keep);
            keepRule.Setup(p => p.Matches(It.IsAny <ObjectIdentifier>(), It.IsAny <ModelTypeClass>(), It.IsAny <DeploymentStep>())).Callback(() => Assert.Fail("Rule should not have been called"));

            var decider = new KeeperDecider(new List <FilterRule>()
            {
                keepRule.Object
            });

            decider.ShouldRemoveFromPlan(new ObjectIdentifier("aa"), ModelSchema.Aggregate, StepType.Create);
        }
Пример #5
0
        public void Alter_Step_Does_Call_Ignore_Rule()
        {
            var ignoreRule = new Mock <FilterRule>();

            ignoreRule.Setup(p => p.Operation()).Returns(FilterOperation.Ignore);
            ignoreRule.Setup(p => p.Matches(It.IsAny <ObjectIdentifier>(), It.IsAny <ModelTypeClass>(), null)).Returns(true);

            var decider = new KeeperDecider(new List <FilterRule>()
            {
                ignoreRule.Object
            });
            var result = decider.ShouldRemoveFromPlan(new ObjectIdentifier("aa"), ModelSchema.Aggregate, StepType.Alter);

            Assert.IsTrue(result);
        }
Пример #6
0
        public void Drop_Step_Does_Call_Keep_Rule()
        {
            var keepRule = new Mock <FilterRule>();

            keepRule.Setup(p => p.Operation()).Returns(FilterOperation.Keep);
            keepRule.Setup(p => p.Matches(It.IsAny <ObjectIdentifier>(), It.IsAny <ModelTypeClass>(), It.IsAny <DeploymentStep>())).Returns(true);

            var decider = new KeeperDecider(new List <FilterRule>()
            {
                keepRule.Object
            });
            var result = decider.ShouldRemoveFromPlan(new ObjectIdentifier("aa"), ModelSchema.Aggregate, StepType.Drop);

            Assert.IsTrue(result);
        }
Пример #7
0
        private static DeploymentStepDecision RemoveCreateElement(DeploymentStep step, KeeperDecider decider)
        {
            var createStep = step as CreateElementStep;

            if (createStep == null)
            {
                return(null);
            }

            var objectNames = GetAllIdentifiersFromStep(step);

            return(new DeploymentStepDecision()
            {
                Remove = decider.ShouldRemoveFromPlan(new ObjectIdentifier(objectNames), createStep.SourceElement?.ObjectType, StepType.Create),
                StepType = StepType.Create,
                ObjectNames = objectNames
            });
        }
Пример #8
0
        private static DeploymentStepDecision RemoveDropStep(DeploymentStep step, KeeperDecider decider)
        {
            var dropStep = step as DropElementStep;

            if (dropStep == null)
            {
                return(null);
            }

            var objectNames = GetAllIdentifiersFromStep(step);

            return(new DeploymentStepDecision()
            {
                Remove = decider.ShouldRemoveFromPlan(new ObjectIdentifier(objectNames), dropStep.TargetElement?.ObjectType, StepType.Drop),
                StepType = StepType.Drop,
                ObjectNames = objectNames
            });
        }
Пример #9
0
        private static DeploymentStepDecision RemoveDataLossCheckStep(DeploymentStep step, KeeperDecider decider)
        {
            var dlcStep = new DataLossCheckStep(step);

            if (dlcStep == null || !dlcStep.IsDataLossCheck)
            {
                return(null);
            }

            var objectNames = GetAllIdentifiersFromStep(step);

            return(new DeploymentStepDecision()
            {
                Remove = decider.ShouldRemoveFromPlan(new ObjectIdentifier(objectNames), ModelSchema.Table, StepType.Drop),
                StepType = StepType.DataLossCheck,
                ObjectNames = objectNames
            });
        }
Пример #10
0
        public void All_Rules_Ignored_For_Other_Steps()
        {
            var ignoreRule = new Mock <FilterRule>();

            ignoreRule.Setup(p => p.Operation()).Returns(FilterOperation.Ignore);
            ignoreRule.Setup(p => p.Matches(It.IsAny <ObjectIdentifier>(), It.IsAny <ModelTypeClass>(), null)).Callback(() => Assert.Fail("Ignore Rule should not have been called"));;


            var keepRule = new Mock <FilterRule>();

            keepRule.Setup(p => p.Operation()).Returns(FilterOperation.Keep);
            keepRule.Setup(p => p.Matches(It.IsAny <ObjectIdentifier>(), It.IsAny <ModelTypeClass>(), null)).Callback(() => Assert.Fail("Keep Rule should not have been called"));

            var decider = new KeeperDecider(new List <FilterRule>()
            {
                ignoreRule.Object, keepRule.Object
            });
            var result = decider.ShouldRemoveFromPlan(new ObjectIdentifier("aa"), ModelSchema.Aggregate, StepType.Other);

            Assert.IsFalse(result);
        }