Ejemplo n.º 1
0
        public async Task CheckEquivalenceConstrictors(int conditionStampId, int onConditionNextDepartmentId,
                                                       int onConditionAddedStampId, int onConditionRemovedStampId, int elseConditionNextDepartmentId,
                                                       int elseConditionAddedStampId, int elseConditionRemovedStampId)
        {
            //Arrange
            var bypassSheetDefault = BypassSheetTestHelper.GetInitializedBypassSheet(3, 1, 5);
            var bypassSheetConfig  = BypassSheetTestHelper.GetInitializedBypassSheet(3, 1, 5);

            var ruleDefault = new ConditionDepartmentRule(conditionStampId, onConditionNextDepartmentId,
                                                          elseConditionNextDepartmentId, onConditionAddedStampId, onConditionRemovedStampId,
                                                          elseConditionAddedStampId, elseConditionRemovedStampId);
            var ruleConfig = new ConditionDepartmentRule(new ConditionDepartmentRuleConfig
            {
                ConditionStampId              = conditionStampId,
                OnConditionNextDepartmentId   = onConditionNextDepartmentId,
                OnConditionAddedStampId       = onConditionAddedStampId,
                OnConditionRemovedStampId     = onConditionRemovedStampId,
                ElseConditionNextDepartmentId = elseConditionNextDepartmentId,
                ElseConditionAddedStampId     = elseConditionAddedStampId,
                ElseConditionRemovedStampId   = elseConditionRemovedStampId
            });

            //Act
            var next1 = await ruleDefault.ExecuteRuleAsync(bypassSheetDefault).ConfigureAwait(false);

            var next2 = await ruleConfig.ExecuteRuleAsync(bypassSheetConfig).ConfigureAwait(false);

            //Assert
            Assert.Equal(next1, next2);
            Assert.True(bypassSheetDefault.Stamps.SetEquals(bypassSheetConfig.Stamps));
        }
Ejemplo n.º 2
0
        private static List <IDepartmentRule> InitDefaultDepartmentsRules()
        {
            var rule1 = new DefaultDepartmentRule(new DefaultDepartmentRuleConfig
            {
                NextDepartmentId = 2,
                AddedStampId     = 6,
                RemovedStampId   = 3
            });

            var rule2 = new ConditionDepartmentRule(new ConditionDepartmentRuleConfig
            {
                ConditionStampId              = 7,
                OnConditionNextDepartmentId   = 3,
                OnConditionAddedStampId       = 9,
                ElseConditionNextDepartmentId = 5,
                ElseConditionAddedStampId     = 8
            });

            var rule3 = new DefaultDepartmentRule(new DefaultDepartmentRuleConfig
            {
                NextDepartmentId = 4,
                AddedStampId     = 3
            });

            var rule4 = new DefaultDepartmentRule(new DefaultDepartmentRuleConfig
            {
                NextDepartmentId = 2,
                AddedStampId     = 4
            });

            var rule5 = new ConditionDepartmentRule(new ConditionDepartmentRuleConfig
            {
                ConditionStampId              = 8,
                OnConditionNextDepartmentId   = 4,
                OnConditionAddedStampId       = 7,
                ElseConditionNextDepartmentId = 1,
                ElseConditionAddedStampId     = 2
            });

            return(new List <IDepartmentRule> {
                rule1, rule2, rule3, rule4, rule5
            });
        }
Ejemplo n.º 3
0
        public async Task ExecuteElseConditionRule()
        {
            //Arrange
            var bypassSheet    = BypassSheetTestHelper.GetInitializedBypassSheet(3, 1, 5);
            var expectedStamps = BypassSheetTestHelper.GetInitializedBypassSheet(5, 4, 3).Stamps;

            var rule = new ConditionDepartmentRule(new ConditionDepartmentRuleConfig
            {
                ConditionStampId              = 2,
                OnConditionNextDepartmentId   = 4,
                OnConditionAddedStampId       = 2,
                OnConditionRemovedStampId     = 5,
                ElseConditionNextDepartmentId = 3,
                ElseConditionAddedStampId     = 4,
                ElseConditionRemovedStampId   = 1
            });

            //Act
            var nextId = await rule.ExecuteRuleAsync(bypassSheet).ConfigureAwait(false);

            //Assert
            Assert.Equal(3, nextId);
            Assert.True(expectedStamps.SetEquals(bypassSheet.Stamps));
        }
Ejemplo n.º 4
0
        private static List <IDepartmentRule> InitNotCycleDepartmentsRules()
        {
            var rule1 = new ConditionDepartmentRule(new ConditionDepartmentRuleConfig
            {
                ConditionStampId              = 2,
                OnConditionNextDepartmentId   = 3,
                ElseConditionNextDepartmentId = 2,
                ElseConditionAddedStampId     = 2
            });

            var rule2 = new DefaultDepartmentRule(new DefaultDepartmentRuleConfig
            {
                NextDepartmentId = 1
            });

            var rule3 = new DefaultDepartmentRule(new DefaultDepartmentRuleConfig
            {
                NextDepartmentId = 2
            });

            return(new List <IDepartmentRule> {
                rule1, rule2, rule3
            });
        }