Beispiel #1
0
        internal override bool Eval(string left, Func <string, string, string, IEnumerable <string[]> > getArgumentsFunc, bool hasError)
        {
            var factory = Dev2DecisionFactory.Instance();

            if (MatchType == enDecisionType.IsError)
            {
                return(hasError);
            }
            if (MatchType == enDecisionType.IsNotError)
            {
                return(!hasError);
            }
            IList <bool> ret = new List <bool>();

            var items = getArgumentsFunc(left, From, To);

            foreach (var arguments in items)
            {
                try
                {
                    ret.Add(factory.FetchDecisionFunction(MatchType).Invoke(arguments));
                }
                catch (Exception)
                {
                    ret.Add(false);
                }
            }
            return(ret.All(o => o));
        }
Beispiel #2
0
 public void Dev2DecisionFactory_Instance_ShouldHaveAStaticInstance()
 {
     //------------Setup for test--------------------------
     //------------Execute Test---------------------------
     //------------Assert Results-------------------------
     Assert.IsNotNull(Dev2DecisionFactory.Instance());
 }
Beispiel #3
0
        public void GivenIsLessThanDev2DecisionFactory_HandleType_ShouldReturnIsLessThan()
        {
            var decisionType = enDecisionType.IsLessThan;
            //------------Setup for test--------------------------
            var decisionFactory = new Dev2DecisionFactory();
            //------------Execute Test---------------------------
            var fetchDecisionFunction = decisionFactory.FetchDecisionFunction(decisionType);

            //------------Assert Results-------------------------
            Assert.AreEqual(decisionType, fetchDecisionFunction.HandlesType());
        }
Beispiel #4
0
        private IServiceTestModelTO Eval(Guid resourceId, IDSFDataObject dataObject, IServiceTestModelTO test)
        {
            Dev2Logger.Debug("Getting Resource to Execute");
            var                resourceCatalog = ResourceCat ?? ResourceCatalog.Instance;
            IDev2Activity      resource        = resourceCatalog.Parse(TheWorkspace.ID, resourceId);
            Dev2JsonSerializer serializer      = new Dev2JsonSerializer();
            var                execPlan        = serializer.SerializeToBuilder(resource);
            var                clonedExecPlan  = serializer.Deserialize <IDev2Activity>(execPlan);

            Dev2Logger.Debug("Got Resource to Execute");

            if (test != null)
            {
                var testPassed     = true;
                var canExecute     = true;
                var failureMessage = new StringBuilder();
                if (ServerAuthorizationService.Instance != null)
                {
                    var authorizationService = ServerAuthorizationService.Instance;
                    var hasView    = authorizationService.IsAuthorized(AuthorizationContext.View, DataObject.ResourceID.ToString());
                    var hasExecute = authorizationService.IsAuthorized(AuthorizationContext.Execute, DataObject.ResourceID.ToString());
                    canExecute = hasExecute && hasView;
                }
                if (!canExecute)
                {
                    dataObject.Environment.AllErrors.Add("Unauthorized to execute this resource.");
                }
                else
                {
                    if (!dataObject.StopExecution)
                    {
                        dataObject.ServiceTest = test;
                        UpdateToPending(test.TestSteps);
                        EvalInner(dataObject, clonedExecPlan, dataObject.ForEachUpdateValue, test.TestSteps);
                        if (test.Outputs != null)
                        {
                            var dev2DecisionFactory = Dev2DecisionFactory.Instance();
                            var testRunResults      = test.Outputs.SelectMany(output => GetTestRunResults(dataObject, output, dev2DecisionFactory)).ToList();
                            testPassed = testRunResults.All(result => result.RunTestResult == RunResult.TestPassed);
                            if (!testPassed)
                            {
                                failureMessage = failureMessage.Append(string.Join("", testRunResults.Select(result => result.Message).Where(s => !string.IsNullOrEmpty(s)).ToList()));
                            }
                        }
                    }
                }
                ValidateError(test, testPassed, failureMessage);
                test.FailureMessage = failureMessage.ToString();
                return(test);
            }
            throw new Exception($"Test {dataObject.TestName} for Resource {dataObject.ServiceName} ID {resourceId}");
        }
Beispiel #5
0
        private static void UpdateDebugStateWithAssertion(IDSFDataObject dataObject, IServiceTestStep stepToBeAsserted, IDebugState debugState)
        {
            if (debugState != null)
            {
                var factory                   = Dev2DecisionFactory.Instance();
                var res                       = stepToBeAsserted.StepOutputs.SelectMany(output => GetTestRunResults(dataObject, output, factory, debugState));
                var testRunResults            = res as IList <TestRunResult> ?? res.ToList();
                var testPassed                = testRunResults.All(result => result.RunTestResult == RunResult.TestPassed || result.RunTestResult == RunResult.None);
                var serviceTestFailureMessage = string.Join("", testRunResults.Select(result => result.Message));

                UpdateBasedOnFinalResult(dataObject, stepToBeAsserted, testPassed, testRunResults, serviceTestFailureMessage);
            }
        }
Beispiel #6
0
        static void GetTestResults(IDSFDataObject dataObject, IServiceTestModelTO test, ref bool testPassed, ref StringBuilder failureMessage)
        {
            if (test.Outputs is null)
            {
                return;
            }
            var dev2DecisionFactory = Dev2DecisionFactory.Instance();
            var testRunResults      = test.Outputs.SelectMany(output => GetTestRunResults(dataObject, output, dev2DecisionFactory)).ToList();

            testPassed = testRunResults.All(result => result.RunTestResult == RunResult.TestPassed);
            if (!testPassed)
            {
                failureMessage = failureMessage.Append(string.Join("", testRunResults.Select(result => result.Message).Where(s => !string.IsNullOrEmpty(s)).ToList()));
            }
        }
Beispiel #7
0
        public bool ExecuteDecisionStack(string decisionDataPayload, IList <string> oldAmbientData, int update)
        {
            var dlId            = FetchDataListID(oldAmbientData);
            var newDecisionData = Dev2DecisionStack.FromVBPersitableModelToJSON(decisionDataPayload);
            var dds             = EvaluateRegion(newDecisionData, dlId, update);

            var env = Dev2DataListDecisionHandler._environments[dlId];

            if (dds != null)
            {
                if (dlId != GlobalConstants.NullDataListID)
                {
                    try
                    {
                        if (dds.TheStack != null)
                        {
                            for (int i = 0; i < dds.TotalDecisions; i++)
                            {
                                var dd     = dds.GetModelItem(i);
                                var typeOf = dd.EvaluationFn;

                                // Treat Errors special
                                if (typeOf == enDecisionType.IsError || typeOf == enDecisionType.IsNotError)
                                {
                                    dd.Col1 = env.FetchErrors();
                                }

                                var op = Dev2DecisionFactory.Instance().FetchDecisionFunction(typeOf);
                                if (op != null)
                                {
                                    try
                                    {
                                        var result = op.Invoke(dds.GetModelItem(i).FetchColsAsArray());

                                        if (!result && dds.Mode == Dev2DecisionMode.AND)
                                        {
                                            // Naughty stuff, we have a false in AND mode... break
                                            return(false);
                                        }

                                        if (result && dds.Mode == Dev2DecisionMode.OR)
                                        {
                                            return(true);
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        // An error, push into the DL
                                        env.AddError(e.Message);

                                        return(false);
                                    }
                                }
                                else
                                {
                                    throw new InvalidExpressionException(string.Format(ErrorResource.CouldNotEvaluateDecisionData, typeOf));
                                }
                            }

                            // else we are in AND mode and all have passed ;)
                            if (dds.Mode == Dev2DecisionMode.AND)
                            {
                                return(true);
                            }

                            //finally, it must be OR mode with no matches ;(
                            return(false);
                        }

                        throw new InvalidExpressionException(ErrorResource.InvalidModelDataSent);
                    }
                    catch
                    {
                        // all hell has broken loose... ;)
                        throw new InvalidExpressionException(ErrorResource.NoModelDataSent);
                    }
                }

                throw new InvalidExpressionException(ErrorResource.NoDataListIDsent);
            }

            throw new InvalidExpressionException(ErrorResource.DataListErrors);
        }
        public override IDev2Activity Execute(IDSFDataObject dataObject, int update)
        {
            ErrorResultTO allErrors = new ErrorResultTO();

            try
            {
                InitializeDebug(dataObject);


                if (dataObject.IsDebugMode())
                {
                    _debugInputs = CreateDebugInputs(dataObject.Environment);
                    DispatchDebugState(dataObject, StateType.Before, 0);
                }

                var stack = Conditions.TheStack.Select(a => ParseDecision(dataObject.Environment, a));


                var factory = Dev2DecisionFactory.Instance();
                var res     = stack.SelectMany(a =>
                {
                    if (a.EvaluationFn == enDecisionType.IsError)
                    {
                        return(new[] { dataObject.Environment.AllErrors.Count > 0 });
                    }
                    if (a.EvaluationFn == enDecisionType.IsNotError)
                    {
                        return(new[] { dataObject.Environment.AllErrors.Count == 0 });
                    }
                    IList <bool> ret = new List <bool>();
                    var iter         = new WarewolfListIterator();
                    var c1           = new WarewolfAtomIterator(a.Cols1);
                    var c2           = new WarewolfAtomIterator(a.Cols2);
                    var c3           = new WarewolfAtomIterator(a.Cols3);
                    iter.AddVariableToIterateOn(c1);
                    iter.AddVariableToIterateOn(c2);
                    iter.AddVariableToIterateOn(c3);
                    while (iter.HasMoreData())
                    {
                        ret.Add(factory.FetchDecisionFunction(a.EvaluationFn).Invoke(new[] { iter.FetchNextValue(c1), iter.FetchNextValue(c2), iter.FetchNextValue(c3) }));
                    }
                    return(ret);
                });
                var resultval = And ? res.Aggregate(true, (a, b) => a && b) : res.Any(a => a);
                if (dataObject.IsDebugMode())
                {
                    _debugOutputs = GetDebugOutputs(resultval.ToString());
                }

                if (resultval)
                {
                    if (TrueArm != null)
                    {
                        var activity = TrueArm.FirstOrDefault();
                        return(activity);
                    }
                }
                else
                {
                    if (FalseArm != null)
                    {
                        var activity = FalseArm.FirstOrDefault();
                        return(activity);
                    }
                }
            }
            catch (Exception e)
            {
                allErrors.AddError(e.Message);
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfDeleteRecordsActivity", allErrors);
                    var errorString = allErrors.MakeDisplayReady();
                    dataObject.Environment.AddError(errorString);
                }
            }
            if (dataObject.IsDebugMode())
            {
                _debugOutputs = new List <DebugItem>();
                _debugOutputs = new List <DebugItem>();
                DispatchDebugState(dataObject, StateType.Duration, update);
            }
            return(null);
        }
Beispiel #9
0
#pragma warning disable S1541 // Methods and properties should not be too complex
#pragma warning disable S3776 // Cognitive Complexity of methods should not be too high
        IDev2Activity ExecuteDecision(IDSFDataObject dataObject)
#pragma warning restore S3776 // Cognitive Complexity of methods should not be too high
#pragma warning restore S1541 // Methods and properties should not be too complex
        {
            InitializeDebug(dataObject);

            if (dataObject.IsDebugMode())
            {
                _debugInputs = CreateDebugInputs(dataObject.Environment);
                DispatchDebugState(dataObject, StateType.Before, 0);
            }

            var errorIfNull = !Conditions.TheStack.Any(decision => decision.EvaluationFn == enDecisionType.IsNull || decision.EvaluationFn == enDecisionType.IsNotNull);

            var stack = Conditions.TheStack.Select(a => ParseDecision(dataObject.Environment, a, errorIfNull));

            var factory = Dev2DecisionFactory.Instance();
            var res     = stack.SelectMany(a =>
            {
                if (a.EvaluationFn == enDecisionType.IsError)
                {
                    return(new[] { dataObject.Environment.AllErrors.Count > 0 });
                }
                if (a.EvaluationFn == enDecisionType.IsNotError)
                {
                    return(new[] { dataObject.Environment.AllErrors.Count == 0 });
                }
                IList <bool> ret = new List <bool>();
                var iter         = new WarewolfListIterator();
                var c1           = new WarewolfAtomIterator(a.Cols1);
                var c2           = new WarewolfAtomIterator(a.Cols2);
                var c3           = new WarewolfAtomIterator(a.Cols3);
                iter.AddVariableToIterateOn(c1);
                iter.AddVariableToIterateOn(c2);
                iter.AddVariableToIterateOn(c3);
                while (iter.HasMoreData())
                {
                    try
                    {
                        ret.Add(factory.FetchDecisionFunction(a.EvaluationFn).Invoke(new[] { iter.FetchNextValue(c1), iter.FetchNextValue(c2), iter.FetchNextValue(c3) }));
                    }
                    catch (Exception)
                    {
                        if (errorIfNull)
                        {
                            throw;
                        }
                        ret.Add(false);
                    }
                }
                return(ret);
            });

            var results   = res as IList <bool> ?? res.ToList();
            var resultval = true;

            if (results.Any())
            {
                if (And)
                {
                    if (results.Any(b => !b))
                    {
                        resultval = false;
                    }
                }
                else
                {
                    resultval = results.Any(b => b);
                }
            }

            Result = GetResultString(resultval.ToString(), Conditions);
            if (dataObject.IsDebugMode())
            {
                _debugOutputs = GetDebugOutputs(resultval.ToString());
            }
            if (resultval)
            {
                if (TrueArm != null)
                {
                    var activity = TrueArm.FirstOrDefault();
                    return(activity);
                }
            }
            else
            {
                if (FalseArm != null)
                {
                    var activity = FalseArm.FirstOrDefault();
                    return(activity);
                }
            }

            return(null);
        }
Beispiel #10
0
        // Guid dlID
        /// <summary>
        /// Executes the decision stack.
        /// </summary>
        /// <param name="decisionDataPayload">The decision data payload.</param>
        /// <param name="oldAmbientData">The old ambient data.</param>
        /// <returns></returns>
        /// <exception cref="System.Data.InvalidExpressionException">Could not evaluate decision data - No decision function found for [  + typeOf + ]</exception>
        public bool ExecuteDecisionStack(string decisionDataPayload, IList <string> oldAmbientData)
        {
            Guid dlId = FetchDataListID(oldAmbientData);
//            if(dlId == GlobalConstants.NullDataListID) throw new InvalidExpressionException("Could not evaluate decision data - no DataList ID sent!");
            string newDecisionData = Dev2DecisionStack.FromVBPersitableModelToJSON(decisionDataPayload);
            var    dds             = EvaluateRegion(newDecisionData, dlId);


            var env = _environments[dlId];

            if (dds != null)
            {
                if (dlId != GlobalConstants.NullDataListID)
                {
                    try
                    {
                        if (dds.TheStack != null)
                        {
                            for (int i = 0; i < dds.TotalDecisions; i++)
                            {
                                Dev2Decision   dd     = dds.GetModelItem(i);
                                enDecisionType typeOf = dd.EvaluationFn;

                                // Treat Errors special
                                if (typeOf == enDecisionType.IsError || typeOf == enDecisionType.IsNotError)
                                {
                                    dd.Col1 = String.Join("", env.Errors);
                                }

                                IDecisionOperation op = Dev2DecisionFactory.Instance().FetchDecisionFunction(typeOf);
                                if (op != null)
                                {
                                    try
                                    {
                                        bool result = op.Invoke(dds.GetModelItem(i).FetchColsAsArray());

                                        if (!result && dds.Mode == Dev2DecisionMode.AND)
                                        {
                                            // Naughty stuff, we have a false in AND mode... break
                                            return(false);
                                        }

                                        if (result && dds.Mode == Dev2DecisionMode.OR)
                                        {
                                            return(true);
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        // An error, push into the DL
                                        env.AddError(e.Message);

                                        return(false);
                                    }
                                }
                                else
                                {
                                    throw new InvalidExpressionException("Could not evaluate decision data - No decision function found for [ " + typeOf + " ]");
                                }
                            }

                            // else we are in AND mode and all have passed ;)
                            if (dds.Mode == Dev2DecisionMode.AND)
                            {
                                return(true);
                            }

                            //finally, it must be OR mode with no matches ;(
                            return(false);
                        }

                        throw new InvalidExpressionException("Could not evaluate decision data - Invalid model data sent!");
                    }
                    catch
                    {
                        // all hell has broken loose... ;)
                        throw new InvalidExpressionException("Could not evaluate decision data - No model data sent!");
                    }
                }

                throw new InvalidExpressionException("Could not evaluate decision data - no DataList ID sent!");
            }

            throw new InvalidExpressionException("Could not populate decision model - DataList Errors!");
        }
        // Guid dlID
        /// <summary>
        /// Executes the decision stack.
        /// </summary>
        /// <param name="decisionDataPayload">The decision data payload.</param>
        /// <param name="oldAmbientData">The old ambient data.</param>
        /// <returns></returns>
        /// <exception cref="System.Data.InvalidExpressionException">Could not evaluate decision data - No decision function found for [  + typeOf + ]</exception>
        public bool ExecuteDecisionStack(string decisionDataPayload, IList <string> oldAmbientData)
        {
            // Evaluate decisionDataPayload through the EvaluateFunction ;)
            Guid dlId = FetchDataListID(oldAmbientData);

            if (dlId == GlobalConstants.NullDataListID)
            {
                throw new InvalidExpressionException("Could not evaluate decision data - no DataList ID sent!");
            }
            // Swap out ! with a new internal token to avoid nasty issues with
            string newDecisionData = Dev2DecisionStack.FromVBPersitableModelToJSON(decisionDataPayload);

            var dds = EvaluateRegion(newDecisionData, dlId);

            ErrorResultTO errors = new ErrorResultTO();

            if (dds != null)
            {
                if (dlId != GlobalConstants.NullDataListID)
                {
                    try
                    {
                        if (dds.TheStack != null)
                        {
                            for (int i = 0; i < dds.TotalDecisions; i++)
                            {
                                Dev2Decision   dd     = dds.GetModelItem(i);
                                enDecisionType typeOf = dd.EvaluationFn;

                                // Treat Errors special
                                if (typeOf == enDecisionType.IsError || typeOf == enDecisionType.IsNotError)
                                {
                                    dd.Col1 = Compiler.EvaluateSystemEntry(dlId, enSystemTag.Dev2Error, out errors);
                                }

                                IDecisionOperation op = Dev2DecisionFactory.Instance().FetchDecisionFunction(typeOf);
                                if (op != null)
                                {
                                    try
                                    {
                                        bool result = op.Invoke(dds.GetModelItem(i).FetchColsAsArray());

                                        if (!result && dds.Mode == Dev2DecisionMode.AND)
                                        {
                                            // Naughty stuff, we have a false in AND mode... break
                                            return(false);
                                        }

                                        if (result && dds.Mode == Dev2DecisionMode.OR)
                                        {
                                            return(true);
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        // An error, push into the DL
                                        ErrorResultTO errorErrors;
                                        errors.AddError(e.Message);
                                        Compiler.UpsertSystemTag(dlId, enSystemTag.Dev2Error, errors.MakeDataListReady(), out errorErrors);

                                        return(false);
                                    }
                                }
                                else
                                {
                                    throw new InvalidExpressionException("Could not evaluate decision data - No decision function found for [ " + typeOf + " ]");
                                }
                            }

                            // else we are in AND mode and all have passed ;)
                            if (dds.Mode == Dev2DecisionMode.AND)
                            {
                                return(true);
                            }

                            //finally, it must be OR mode with no matches ;(
                            return(false);
                        }

                        throw new InvalidExpressionException("Could not evaluate decision data - Invalid model data sent!");
                    }
                    catch
                    {
                        // all hell has broken loose... ;)
                        throw new InvalidExpressionException("Could not evaluate decision data - No model data sent!");
                    }
                }

                throw new InvalidExpressionException("Could not evaluate decision data - no DataList ID sent!");
            }

            throw new InvalidExpressionException("Could not populate decision model - DataList Errors!");
        }
Beispiel #12
0
        private static IEnumerable <TestRunResult> GetTestRunResults(IDSFDataObject dataObject, IServiceTestOutput output, Dev2DecisionFactory factory, IDebugState debugState)
        {
            if (output == null)
            {
                var testResult = new TestRunResult
                {
                    RunTestResult = RunResult.None
                };
                return(new List <TestRunResult> {
                    testResult
                });
            }
            if (string.IsNullOrEmpty(output.Variable) && string.IsNullOrEmpty(output.Value))
            {
                var testResult = new TestRunResult
                {
                    RunTestResult = RunResult.None
                };
                output.Result = testResult;
                return(new List <TestRunResult> {
                    testResult
                });
            }
            if (output.Result != null)
            {
                output.Result.RunTestResult = RunResult.TestInvalid;
            }
            if (string.IsNullOrEmpty(output.Variable))
            {
                var testResult = new TestRunResult
                {
                    RunTestResult = RunResult.TestInvalid,
                    Message       = Messages.Test_NothingToAssert
                };
                output.Result = testResult;
                if (dataObject.IsDebugMode())
                {
                    var       debugItemStaticDataParams = new DebugItemServiceTestStaticDataParams(testResult.Message, true);
                    DebugItem itemToAdd = new DebugItem();
                    itemToAdd.AddRange(debugItemStaticDataParams.GetDebugItemResult());
                    debugState.AssertResultList.Add(itemToAdd);
                }
                return(new List <TestRunResult> {
                    testResult
                });
            }
            IFindRecsetOptions opt = FindRecsetOptions.FindMatch(output.AssertOp);
            var decisionType       = DecisionDisplayHelper.GetValue(output.AssertOp);
            var value = new List <DataStorage.WarewolfAtom> {
                DataStorage.WarewolfAtom.NewDataString(output.Value)
            };
            var from = new List <DataStorage.WarewolfAtom> {
                DataStorage.WarewolfAtom.NewDataString(output.From)
            };
            var to = new List <DataStorage.WarewolfAtom> {
                DataStorage.WarewolfAtom.NewDataString(output.To)
            };

            IList <TestRunResult> ret = new List <TestRunResult>();
            var iter  = new WarewolfListIterator();
            var cols1 = dataObject.Environment.EvalAsList(DataListUtil.AddBracketsToValueIfNotExist(output.Variable), 0);
            var c1    = new WarewolfAtomIterator(cols1);
            var c2    = new WarewolfAtomIterator(value);
            var c3    = new WarewolfAtomIterator(@from);

            if (opt.ArgumentCount > 2)
            {
                c2 = new WarewolfAtomIterator(to);
            }
            iter.AddVariableToIterateOn(c1);
            iter.AddVariableToIterateOn(c2);
            iter.AddVariableToIterateOn(c3);
            while (iter.HasMoreData())
            {
                var val1         = iter.FetchNextValue(c1);
                var val2         = iter.FetchNextValue(c2);
                var val3         = iter.FetchNextValue(c3);
                var assertResult = factory.FetchDecisionFunction(decisionType).Invoke(new[] { val1, val2, val3 });
                var testResult   = new TestRunResult();
                if (assertResult)
                {
                    testResult.RunTestResult = RunResult.TestPassed;
                }
                else
                {
                    testResult.RunTestResult = RunResult.TestFailed;
                    var msg    = DecisionDisplayHelper.GetFailureMessage(decisionType);
                    var actMsg = string.Format(msg, val2, output.Variable, val1, val3);
                    testResult.Message = new StringBuilder(testResult.Message).AppendLine(actMsg).ToString();
                }
                if (dataObject.IsDebugMode())
                {
                    var msg = testResult.Message;
                    if (testResult.RunTestResult == RunResult.TestPassed)
                    {
                        msg = Messages.Test_PassedResult;
                    }

                    var hasError = testResult.RunTestResult == RunResult.TestFailed;

                    var       debugItemStaticDataParams = new DebugItemServiceTestStaticDataParams(msg, hasError);
                    DebugItem itemToAdd = new DebugItem();
                    itemToAdd.AddRange(debugItemStaticDataParams.GetDebugItemResult());

                    if (debugState.AssertResultList != null)
                    {
                        bool addItem = debugState.AssertResultList.Select(debugItem => debugItem.ResultsList.Where(debugItemResult => debugItemResult.Value == Messages.Test_PassedResult)).All(debugItemResults => !debugItemResults.Any());

                        if (addItem)
                        {
                            debugState.AssertResultList.Add(itemToAdd);
                        }
                    }
                }
                output.Result = testResult;
                ret.Add(testResult);
            }
            return(ret);
        }
Beispiel #13
0
        private IEnumerable <TestRunResult> GetTestRunResults(IDSFDataObject dataObject, IServiceTestOutput output, Dev2DecisionFactory factory)
        {
            var expressionType     = output.AssertOp ?? string.Empty;
            IFindRecsetOptions opt = FindRecsetOptions.FindMatch(expressionType);
            var decisionType       = DecisionDisplayHelper.GetValue(expressionType);

            if (decisionType == enDecisionType.IsError)
            {
                var hasErrors  = dataObject.Environment.AllErrors.Count > 0;
                var testResult = new TestRunResult();
                if (hasErrors)
                {
                    testResult.RunTestResult = RunResult.TestPassed;
                }
                else
                {
                    testResult.RunTestResult = RunResult.TestFailed;
                    var msg    = DecisionDisplayHelper.GetFailureMessage(decisionType);
                    var actMsg = string.Format(msg);
                    testResult.Message = new StringBuilder(testResult.Message).AppendLine(actMsg).ToString();
                }
                return(new[] { testResult });
            }
            if (decisionType == enDecisionType.IsNotError)
            {
                var noErrors   = dataObject.Environment.AllErrors.Count == 0;
                var testResult = new TestRunResult();
                if (noErrors)
                {
                    testResult.RunTestResult = RunResult.TestPassed;
                }
                else
                {
                    testResult.RunTestResult = RunResult.TestFailed;
                    var msg    = DecisionDisplayHelper.GetFailureMessage(decisionType);
                    var actMsg = string.Format(msg);
                    testResult.Message = new StringBuilder(testResult.Message).AppendLine(actMsg).ToString();
                }
                return(new[] { testResult });
            }
            var value = new List <DataStorage.WarewolfAtom> {
                DataStorage.WarewolfAtom.NewDataString(output.Value)
            };
            var from = new List <DataStorage.WarewolfAtom> {
                DataStorage.WarewolfAtom.NewDataString(output.From)
            };
            var to = new List <DataStorage.WarewolfAtom> {
                DataStorage.WarewolfAtom.NewDataString(output.To)
            };

            IList <TestRunResult> ret = new List <TestRunResult>();
            var iter     = new WarewolfListIterator();
            var variable = DataListUtil.AddBracketsToValueIfNotExist(output.Variable);
            var cols1    = dataObject.Environment.EvalAsList(variable, 0);
            var c1       = new WarewolfAtomIterator(cols1);
            var c2       = new WarewolfAtomIterator(value);
            var c3       = new WarewolfAtomIterator(to);

            if (opt.ArgumentCount > 2)
            {
                c2 = new WarewolfAtomIterator(from);
            }
            iter.AddVariableToIterateOn(c1);
            iter.AddVariableToIterateOn(c2);
            iter.AddVariableToIterateOn(c3);
            while (iter.HasMoreData())
            {
                var val1         = iter.FetchNextValue(c1);
                var val2         = iter.FetchNextValue(c2);
                var val3         = iter.FetchNextValue(c3);
                var assertResult = factory.FetchDecisionFunction(decisionType).Invoke(new[] { val1, val2, val3 });
                var testResult   = new TestRunResult();
                if (assertResult)
                {
                    testResult.RunTestResult = RunResult.TestPassed;
                }
                else
                {
                    testResult.RunTestResult = RunResult.TestFailed;
                    var msg    = DecisionDisplayHelper.GetFailureMessage(decisionType);
                    var actMsg = string.Format(msg, val2, variable, val1, val3);
                    testResult.Message = new StringBuilder(testResult.Message).AppendLine(actMsg).ToString();
                }
                output.Result = testResult;
                ret.Add(testResult);
            }
            return(ret);
        }