コード例 #1
0
        public void ActivityHelper_InjectExpression_Dev2DecisionStack()
        {
            //---------------Set up test pack-------------------
            var dev2DecisionStack = new Dev2DecisionStack()
            {
                DisplayText  = "",
                FalseArmText = "",
                TrueArmText  = "",
                Version      = "2",
                Mode         = Dev2DecisionMode.AND
            };

            dev2DecisionStack.TheStack = new List <Dev2Decision>();

            var testAct = new DsfFlowSwitchActivity {
                ExpressionText = ""
            };
            var prop = new Mock <ModelProperty>();

            prop.Setup(p => p.ComputedValue).Returns(testAct);

            ActivityHelper.InjectExpression(dev2DecisionStack, prop.Object);

            //------------Assert Results-------------------------
            var act = new DsfDecision {
                Conditions = dev2DecisionStack, And = true
            };
            var stateItems = act.GetState();

            Assert.AreEqual(5, stateItems.Count());
            var serializer      = new Dev2JsonSerializer();
            var expectedResults = new[]
            {
                new StateVariable
                {
                    Name  = "Conditions",
                    Type  = StateVariable.StateType.Input,
                    Value = serializer.Serialize(dev2DecisionStack)
                },
                new StateVariable
                {
                    Name  = "And",
                    Type  = StateVariable.StateType.Input,
                    Value = "True"
                },
                new StateVariable
                {
                    Name  = "Result",
                    Type  = StateVariable.StateType.Output,
                    Value = null
                },
                new StateVariable
                {
                    Name  = "TrueArm",
                    Type  = StateVariable.StateType.Output,
                    Value = ActivityHelper.GetSerializedStateValueFromCollection(act.TrueArm?.ToList())
                },
                new StateVariable
                {
                    Name  = "FalseArm",
                    Type  = StateVariable.StateType.Output,
                    Value = ActivityHelper.GetSerializedStateValueFromCollection(act.FalseArm?.ToList())
                }
            };

            var iter = act.GetState().Select((item, index) => new
            {
                value       = item,
                expectValue = expectedResults[index]
            });

            Assert.AreEqual(expectedResults.Length, iter.Count());
            foreach (var entry in iter)
            {
                Assert.AreEqual(entry.expectValue.Name, entry.value.Name);
                Assert.AreEqual(entry.expectValue.Type, entry.value.Type);
                Assert.AreEqual(entry.expectValue.Value, entry.value.Value);
            }
        }
コード例 #2
0
        public void DsfDecision_GetState_ReturnsStateVariable()
        {
            //---------------Set up test pack-------------------
            var conditions = new Dev2DecisionStack();

            conditions.TheStack = new List <Dev2Decision>();
            conditions.AddModelItem(new Dev2Decision
            {
                Col1         = "[[a]]",
                EvaluationFn = Data.Decisions.Operations.enDecisionType.IsEqual,
                Col2         = "bob"
            });
            var serializer = new Dev2JsonSerializer();
            //------------Setup for test--------------------------
            var act = new DsfDecision {
                Conditions = conditions, And = true
            };
            //------------Execute Test---------------------------
            var stateItems = act.GetState();

            Assert.AreEqual(5, stateItems.Count());

            var expectedResults = new[]
            {
                new StateVariable
                {
                    Name  = "Conditions",
                    Type  = StateVariable.StateType.Input,
                    Value = serializer.Serialize(conditions)
                },
                new StateVariable
                {
                    Name  = "And",
                    Type  = StateVariable.StateType.Input,
                    Value = "True"
                },
                new StateVariable
                {
                    Name  = "Result",
                    Type  = StateVariable.StateType.Output,
                    Value = null
                },
                new StateVariable
                {
                    Name  = "TrueArm",
                    Type  = StateVariable.StateType.Output,
                    Value = ActivityHelper.GetSerializedStateValueFromCollection(act.TrueArm?.ToList())
                },
                new StateVariable
                {
                    Name  = "FalseArm",
                    Type  = StateVariable.StateType.Output,
                    Value = ActivityHelper.GetSerializedStateValueFromCollection(act.FalseArm?.ToList())
                }
            };

            var iter = act.GetState().Select(
                (item, index) => new
            {
                value       = item,
                expectValue = expectedResults[index]
            }
                );

            //------------Assert Results-------------------------
            foreach (var entry in iter)
            {
                Assert.AreEqual(entry.expectValue.Name, entry.value.Name);
                Assert.AreEqual(entry.expectValue.Type, entry.value.Type);
                Assert.AreEqual(entry.expectValue.Value, entry.value.Value);
            }
        }
コード例 #3
0
        public void ActivityHelper_Dev2Decision_SetArmTextDefaults_SetArmText_SetDisplayName()
        {
            //---------------Set up test pack-------------------
            var serializer        = new Dev2JsonSerializer();
            var viewModel         = new DecisionDesignerViewModel(CreateModelItem());
            var dev2DecisionStack = new Dev2DecisionStack()
            {
                DisplayText  = "",
                FalseArmText = "",
                TrueArmText  = "",
                Version      = "2",
                Mode         = Dev2DecisionMode.AND
            };

            dev2DecisionStack.TheStack = new List <Dev2Decision>();
            var decisionExpressionMessage = new ConfigureDecisionExpressionMessage();

            viewModel.Handle(decisionExpressionMessage);

            //------------Setup for test--------------------------

            ActivityHelper.SetArmTextDefaults(dev2DecisionStack);
            ActivityHelper.SetArmText(viewModel.ModelItem, dev2DecisionStack);
            ActivityHelper.SetDisplayName(viewModel.ModelItem, dev2DecisionStack);

            //------------Assert Results-------------------------
            var act = new DsfDecision {
                Conditions = dev2DecisionStack, And = true
            };
            var stateItems = act.GetState();

            Assert.AreEqual(5, stateItems.Count());
            var expectedResults = new[]
            {
                new StateVariable
                {
                    Name  = "Conditions",
                    Type  = StateVariable.StateType.Input,
                    Value = serializer.Serialize(dev2DecisionStack)
                },
                new StateVariable
                {
                    Name  = "And",
                    Type  = StateVariable.StateType.Input,
                    Value = "True"
                },
                new StateVariable
                {
                    Name  = "Result",
                    Type  = StateVariable.StateType.Output,
                    Value = null
                },
                new StateVariable
                {
                    Name  = "TrueArm",
                    Type  = StateVariable.StateType.Output,
                    Value = ActivityHelper.GetSerializedStateValueFromCollection(act.TrueArm?.ToList())
                },
                new StateVariable
                {
                    Name  = "FalseArm",
                    Type  = StateVariable.StateType.Output,
                    Value = ActivityHelper.GetSerializedStateValueFromCollection(act.FalseArm?.ToList())
                }
            };

            var iter = act.GetState().Select((item, index) => new
            {
                value       = item,
                expectValue = expectedResults[index]
            });

            Assert.AreEqual(expectedResults.Length, iter.Count());
            foreach (var entry in iter)
            {
                Assert.AreEqual(entry.expectValue.Name, entry.value.Name);
                Assert.AreEqual(entry.expectValue.Type, entry.value.Type);
                Assert.AreEqual(entry.expectValue.Value, entry.value.Value);
            }
        }