Ejemplo n.º 1
0
 protected override void ExecuteTool(IDSFDataObject dataObject, int update)
 {
     if (dataObject.IsDebugMode())
     {
         InitializeDebug(dataObject);
     }
     AddRecordsetsOutputs(Outputs.Where(output => DataListUtil.IsValueRecordset(output.Variable) && !output.Variable.Contains("@")), dataObject.Environment);
     foreach (var output in Outputs)
     {
         if (!string.IsNullOrEmpty(output.Variable))
         {
             var variable = DataListUtil.AddBracketsToValueIfNotExist(output.Variable);
             var value    = output.Value;
             if (variable.StartsWith("[[@"))
             {
                 dataObject.Environment.AssignJson(new AssignValue(variable, value), update);
             }
             else
             {
                 AssignNotJson(dataObject, output, variable, value);
             }
             if (dataObject.IsServiceTestExecution && dataObject.IsDebugMode())
             {
                 var res = new DebugEvalResult(dataObject.Environment.ToStar(variable), "", dataObject.Environment, update, false, false, true);
                 AddDebugOutputItem(new DebugEvalResult(variable, "", dataObject.Environment, update));
                 AddDebugAssertResultItem(res);
             }
         }
     }
     if (dataObject.IsDebugMode())
     {
         DispatchDebugState(dataObject, StateType.After, update);
     }
     NextNodes = _originalActivity.NextNodes;
 }
Ejemplo n.º 2
0
        void UpdateEnvironmentAndDebugOutput(IDSFDataObject dataObject, int update, ErrorResultTO allErrors)
        {
            var colItr = new WarewolfListIterator();

            var dtItr = CreateDataListEvaluateIterator(DateTime, dataObject.Environment, update);

            colItr.AddVariableToIterateOn(dtItr);
            var ifItr = CreateDataListEvaluateIterator(string.IsNullOrEmpty(InputFormat) ? GlobalConstants.Dev2DotNetDefaultDateTimeFormat : InputFormat, dataObject.Environment, update);

            colItr.AddVariableToIterateOn(ifItr);
            var ofItr = CreateDataListEvaluateIterator(string.IsNullOrEmpty(OutputFormat) ? GlobalConstants.Dev2DotNetDefaultDateTimeFormat : OutputFormat, dataObject.Environment, update);

            colItr.AddVariableToIterateOn(ofItr);
            var tmaItr = CreateDataListEvaluateIterator(TimeModifierAmountDisplay, dataObject.Environment, update);

            colItr.AddVariableToIterateOn(tmaItr);

            if (!allErrors.HasErrors())
            {
                while (colItr.HasMoreData())
                {
                    var transObj = ConvertToDateTimeTo(colItr.FetchNextValue(dtItr),
                                                       colItr.FetchNextValue(ifItr),
                                                       colItr.FetchNextValue(ofItr),
                                                       TimeModifierType,
                                                       colItr.FetchNextValue(tmaItr)
                                                       );

                    var    format = DateTimeConverterFactory.CreateStandardFormatter();
                    string result;
                    string error;
                    if (format.TryFormat(transObj, out result, out error))
                    {
                        AddDefaultDebugInfo(dataObject, result);
                        AddDebugInfo(dataObject, update);
                        var expression = Result;
                        dataObject.Environment.Assign(expression, result, update);
                    }
                    else
                    {
                        allErrors.AddError(error);
                    }
                }
                if (dataObject.IsDebugMode() && !allErrors.HasErrors())
                {
                    var resDebug = new DebugEvalResult(Result, "", dataObject.Environment, update);
                    AddDebugOutputItem(resDebug);
                }
            }
        }
Ejemplo n.º 3
0
        public void DebugEvalResult_GivenObjectIsJSonArray_ShouldSetObjectArray()
        {
            //---------------Set up test pack-------------------
            var env = new Mock <IExecutionEnvironment>();

            env.Setup(environment => environment.EvalToExpression(It.IsAny <string>(), It.IsAny <int>())).Returns("[[@scalar]]");
            var warewolfAtomResult = CommonFunctions.WarewolfEvalResult.NewWarewolfAtomResult(DataStorage.WarewolfAtom.NewDataString("{\"PolicyNo\":\"A0003\",\"DateId\":32,\"SomeVal\":\"Bob\"}"));

            env.Setup(environment => environment.Eval(It.IsAny <string>(), It.IsAny <int>())).Returns(warewolfAtomResult);
            var debugEvalResult = new DebugEvalResult("[[@scalar]]", "", env.Object, 0);

            //---------------Assert Precondition----------------
            Assert.IsNotNull(debugEvalResult);
            //---------------Execute Test ----------------------
            Assert.AreEqual("", debugEvalResult.LabelText);
            var debugItemResults = debugEvalResult.GetDebugItemResult();
            //---------------Test Result -----------------------
            var variable = debugItemResults[0].Variable;

            Assert.AreEqual("[[@scalar]]", variable);
        }