コード例 #1
0
        public void TestMockStep_ServiceTestOutputs_HaveOutput()
        {
            var originalAct = new Mock <DsfActivityAbstract <string> >();
            var env         = new ExecutionEnvironment();
            var dataMock    = new Mock <IDSFDataObject>();

            dataMock.Setup(o => o.Environment).Returns(() => env);

            const string theValue = "theValue";
            var          input    = new Mock <IServiceTestOutput>();

            input.Setup(o => o.Variable).Returns(() => "[[list()]]");
            input.Setup(o => o.Value).Returns(() => theValue);
            var outputs = new List <IServiceTestOutput>
            {
                input.Object
            };
            var act = new TestMockStep(originalAct.Object, outputs);


            act.Execute(dataMock.Object, 0);

            var results = env.EvalAsListOfStrings("[[@list()]]", 0);

            Assert.AreEqual(theValue, results[0]);
        }
コード例 #2
0
ファイル: Evaluator.cs プロジェクト: Year-2019-20/Warewolf
        static IDev2Activity ReplaceActivityWithMock(IDev2Activity resource, IServiceTestStep foundTestStep)
        {
            IDev2Activity overriddenActivity = null;

            if (foundTestStep.ActivityType == typeof(DsfDecision).Name)
            {
                var serviceTestOutput = foundTestStep.StepOutputs.FirstOrDefault(output => output.Variable == GlobalConstants.ArmResultText);
                if (serviceTestOutput != null)
                {
                    overriddenActivity = new TestMockDecisionStep(resource.As <DsfDecision>())
                    {
                        NameOfArmToReturn = serviceTestOutput.Value
                    };
                }
            }
            else if (foundTestStep.ActivityType == typeof(DsfSwitch).Name)
            {
                var serviceTestOutput = foundTestStep.StepOutputs.FirstOrDefault(output => output.Variable == GlobalConstants.ArmResultText);
                if (serviceTestOutput != null)
                {
                    overriddenActivity = new TestMockSwitchStep(resource.As <DsfSwitch>())
                    {
                        ConditionToUse = serviceTestOutput.Value
                    };
                }
            }
            else
            {
                overriddenActivity = new TestMockStep(resource, foundTestStep.StepOutputs.ToList());
            }

            return(overriddenActivity);
        }
コード例 #3
0
        public void TestMockStep_GetState_ReturnsStateVariable()
        {
            //---------------Set up test pack-------------------
            //------------Setup for test--------------------------
            var act = new TestMockStep();
            //------------Execute Test---------------------------
            var stateItems = act.GetState();

            //------------Assert Results-------------------------
            Assert.AreEqual(0, stateItems.Count());
        }
コード例 #4
0
        public void TestMockStep_Equality()
        {
            var    act  = new TestMockStep();
            Object act1 = null;

            Assert.IsFalse(act.Equals(act1));
            Assert.IsTrue(act.Equals(act));
            act1 = act;
            Assert.IsTrue(act.Equals(act1));

            act1 = new TestMockStep();
            Assert.IsFalse(act.Equals(act1));
        }
コード例 #5
0
        private static IDev2Activity NextActivity(IDev2Activity resource, List <IServiceTestStep> testSteps)
        {
            var foundTestStep = testSteps?.FirstOrDefault(step => resource != null && step.UniqueId.ToString() == resource.UniqueID);

            if (foundTestStep != null)
            {
                if (foundTestStep.ActivityType == typeof(DsfDecision).Name && foundTestStep.Type == StepType.Mock)
                {
                    var serviceTestOutput = foundTestStep.StepOutputs.FirstOrDefault(output => output.Variable == GlobalConstants.ArmResultText);
                    if (serviceTestOutput != null)
                    {
                        resource = new TestMockDecisionStep(resource as DsfDecision)
                        {
                            NameOfArmToReturn = serviceTestOutput.Value
                        };
                    }
                }
                else if (foundTestStep.ActivityType == typeof(DsfSwitch).Name && foundTestStep.Type == StepType.Mock)
                {
                    var serviceTestOutput = foundTestStep.StepOutputs.FirstOrDefault(output => output.Variable == GlobalConstants.ArmResultText);
                    if (serviceTestOutput != null)
                    {
                        resource = new TestMockSwitchStep(resource as DsfSwitch)
                        {
                            ConditionToUse = serviceTestOutput.Value
                        };
                    }
                }
                else if (foundTestStep.ActivityType == typeof(DsfSequenceActivity).Name)
                {
                    var sequenceActivity = resource as DsfSequenceActivity;
                    if (sequenceActivity != null)
                    {
                        var acts = sequenceActivity.Activities;
                        for (int index = 0; index < acts.Count; index++)
                        {
                            var activity = acts[index];
                            if (foundTestStep.Children != null)
                            {
                                var replacement = NextActivity(activity as IDev2Activity, foundTestStep.Children.ToList()) as Activity;
                                acts[index] = replacement;
                            }
                        }
                    }
                }
                else if (foundTestStep.ActivityType == typeof(DsfForEachActivity).Name)
                {
                    var forEach = resource as DsfForEachActivity;
                    if (forEach != null)
                    {
                        if (foundTestStep.Children != null)
                        {
                            var replacement = NextActivity(forEach.DataFunc.Handler as IDev2Activity, foundTestStep.Children.ToList()) as Activity;
                            forEach.DataFunc.Handler = replacement;
                        }
                    }
                }
                else if (foundTestStep.ActivityType == typeof(DsfSelectAndApplyActivity).Name)
                {
                    var forEach = resource as DsfSelectAndApplyActivity;
                    if (forEach != null)
                    {
                        if (foundTestStep.Children != null)
                        {
                            var replacement = NextActivity(forEach.ApplyActivityFunc.Handler as IDev2Activity, foundTestStep.Children.ToList()) as Activity;
                            forEach.ApplyActivityFunc.Handler = replacement;
                        }
                    }
                }
                else if (foundTestStep.Type == StepType.Mock)
                {
                    resource = new TestMockStep(resource, foundTestStep.StepOutputs.ToList());
                }
            }
            return(resource);
        }