// Travis.Frisinger - 28.01.2013 : Amended for Debug
        public override List <DebugItem> GetDebugOutputs(IBinaryDataList dataList)
        {
            var               result       = new List <DebugItem>();
            string            resultString = _theResult.ToString();
            DebugItem         itemToAdd    = new DebugItem();
            IDataListCompiler c            = DataListFactory.CreateDataListCompiler();
            var               val          = new StringBuilder(Dev2DecisionStack.ExtractModelFromWorkflowPersistedData(ExpressionText));

            try
            {
                Dev2DecisionStack dds = c.ConvertFromJsonToModel <Dev2DecisionStack>(val);

                if (_theResult.ToString() == "True")
                {
                    resultString = dds.TrueArmText;
                }
                else if (_theResult.ToString() == "False")
                {
                    resultString = dds.FalseArmText;
                }

                itemToAdd.AddRange(new DebugItemStaticDataParams(resultString, "").GetDebugItemResult());
                result.Add(itemToAdd);
            }
            catch (Exception)
            {
                if (!dataList.HasErrors())
                {
                    itemToAdd.AddRange(new DebugItemStaticDataParams(resultString, "").GetDebugItemResult());
                    result.Add(itemToAdd);
                }
            }

            return(result);
        }
Beispiel #2
0
        List <DebugItem> GetDebugOutputs(string theResult)
        {
            var       result       = new List <DebugItem>();
            string    resultString = theResult;
            DebugItem itemToAdd    = new DebugItem();
            var       dds          = Conditions;

            try
            {
                resultString = GetResultString(theResult, dds);

                itemToAdd.AddRange(new DebugItemStaticDataParams(resultString, "").GetDebugItemResult());
                result.Add(itemToAdd);
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch (Exception)
            // ReSharper restore EmptyGeneralCatchClause
            {
                itemToAdd.AddRange(new DebugItemStaticDataParams(resultString, "").GetDebugItemResult());
                result.Add(itemToAdd);
            }

            _inner?.SetDebugOutputs(result);
            return(result);
        }
        // Travis.Frisinger - 28.01.2013 : Amended for Debug
        public List <DebugItem> GetDebugOutputs(IExecutionEnvironment dataList, string _theResult)
        {
            var               result       = new List <DebugItem>();
            string            resultString = _theResult;
            DebugItem         itemToAdd    = new DebugItem();
            IDataListCompiler c            = DataListFactory.CreateDataListCompiler();
            var               dds          = Conditions;

            try
            {
                if (_theResult == "True")
                {
                    resultString = dds.TrueArmText;
                }
                else if (_theResult == "False")
                {
                    resultString = dds.FalseArmText;
                }

                itemToAdd.AddRange(new DebugItemStaticDataParams(resultString, "").GetDebugItemResult());
                result.Add(itemToAdd);
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch (Exception)
            // ReSharper restore EmptyGeneralCatchClause
            {
                itemToAdd.AddRange(new DebugItemStaticDataParams(resultString, "").GetDebugItemResult());
                result.Add(itemToAdd);
            }

            _inner.SetDebugOutputs(result);
            return(result);
        }
        // Travis.Frisinger - 28.01.2013 : Amended for Debug
        List <DebugItem> GetDebugOutputs(string theResult)
        {
            var       result       = new List <DebugItem>();
            string    resultString = theResult;
            DebugItem itemToAdd    = new DebugItem();
            var       dds          = Conditions;

            try
            {
                if (theResult == "True")
                {
                    resultString = dds.TrueArmText;
                }
                else if (theResult == "False")
                {
                    resultString = dds.FalseArmText;
                }

                itemToAdd.AddRange(new DebugItemStaticDataParams(resultString, "").GetDebugItemResult());
                result.Add(itemToAdd);
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch (Exception)
            // ReSharper restore EmptyGeneralCatchClause
            {
                itemToAdd.AddRange(new DebugItemStaticDataParams(resultString, "").GetDebugItemResult());
                result.Add(itemToAdd);
            }

            _inner.SetDebugOutputs(result);
            return(result);
        }
 void Debug(IDSFDataObject dataObject, string firstOrDefault, Dev2Switch ds)
 {
     try
     {
         if (dataObject.IsDebugMode())
         {
             List <DebugItem> result    = new List <DebugItem>();
             DebugItem        itemToAdd = new DebugItem();
             var debugResult            = new DebugItemWarewolfAtomResult(firstOrDefault, "", ds.SwitchVariable, "", "Switch on", "", "=");
             itemToAdd.AddRange(debugResult.GetDebugItemResult());
             result.Add(itemToAdd);
             _debugInputs = result;
             DispatchDebugState(dataObject, StateType.Before);
             DispatchDebugState(dataObject, StateType.After);
             if (_inner != null)
             {
                 _inner.SetDebugInputs(_debugInputs);
             }
         }
     }
     // ReSharper disable EmptyGeneralCatchClause
     catch
     // ReSharper restore EmptyGeneralCatchClause
     {
     }
 }
        void DebugOutput(IDSFDataObject dataObject)
        {
            try
            {
                if (dataObject.IsDebugMode())
                {
                    List <DebugItem> result   = new List <DebugItem>();
                    var       debugOutputBase = new DebugItemStaticDataParams(Result, "");
                    DebugItem itemToAdd       = new DebugItem();
                    itemToAdd.AddRange(debugOutputBase.GetDebugItemResult());
                    result.Add(itemToAdd);
                    _debugOutputs = result;

                    if (Inner != null)
                    {
                        Inner.SetDebugOutputs(_debugOutputs);
                    }
                }
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch
            // ReSharper restore EmptyGeneralCatchClause
            {
            }
        }
Beispiel #7
0
        void DebugOutput(IDSFDataObject dataObject)
        {
            try
            {
                if (dataObject.IsDebugMode())
                {
                    var result          = new List <DebugItem>();
                    var debugOutputBase = new DebugItemStaticDataParams(Result, "");
                    var itemToAdd       = new DebugItem();
                    itemToAdd.AddRange(debugOutputBase.GetDebugItemResult());
                    result.Add(itemToAdd);
                    _debugOutputs = result;

                    if (Inner != null)
                    {
                        Inner.SetDebugOutputs(_debugOutputs);
                    }
                }
            }

            catch (Exception e)
            {
                Dev2Logger.Warn(e.Message, GlobalConstants.WarewolfWarn);
            }
        }
        protected void AddDebugOutputItem(DebugOutputBase parameters)
        {
            DebugItem itemToAdd = new DebugItem();

            itemToAdd.AddRange(parameters.GetDebugItemResult());
            _debugOutputs.Add(itemToAdd);
        }
        static void AddDebugItem(TestRunResult testRunResult, IDebugState debugState)
        {
            var msg = testRunResult.Message;

            if (testRunResult.RunTestResult == RunResult.TestPassed)
            {
                msg = Messages.Test_PassedResult;
            }

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

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

            itemToAdd.AddRange(debugItemStaticDataParams.GetDebugItemResult());

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

                if (addItem)
                {
                    debugState.AssertResultList.Add(itemToAdd);
                }
            }
        }
 protected void AddDebugItem(DebugOutputBase parameters, DebugItem debugItem)
 {
     try
     {
         var debugItemResults = parameters.GetDebugItemResult();
         debugItem.AddRange(debugItemResults);
     }
     catch (Exception e)
     {
         Dev2Logger.Log.Error(e);
     }
 }
Beispiel #11
0
        void AddInputDebugItemResultsAfterEvaluate(List <IDebugItem> result, ref string userModel, IExecutionEnvironment env, string expression, out ErrorResultTO error, DebugItem parent = null)
        {
            error = new ErrorResultTO();
            if (expression != null && DataListUtil.IsEvaluated(expression))
            {
                DebugOutputBase debugResult;
                if (error.HasErrors())
                {
                    debugResult = new DebugItemStaticDataParams("", expression, "");
                }
                else
                {
                    string expressiomToStringValue;
                    try
                    {
                        expressiomToStringValue = ExecutionEnvironment.WarewolfEvalResultToString(env.Eval(expression, 0, true));
                    }
                    catch (NullValueInVariableException)
                    {
                        expressiomToStringValue = expression;
                    }
                    // EvaluateExpressiomToStringValue(expression, decisionMode, dataList);
                    userModel   = userModel.Replace(expression, expressiomToStringValue);
                    debugResult = new DebugItemWarewolfAtomResult(expressiomToStringValue, expression, "");
                }

                var itemResults = debugResult.GetDebugItemResult();

                var allReadyAdded = new List <IDebugItemResult>();

                itemResults.ForEach(a =>
                {
                    var found = result.SelectMany(r => r.FetchResultsList())
                                .SingleOrDefault(r => r.Variable.Equals(a.Variable));
                    if (found != null)
                    {
                        allReadyAdded.Add(a);
                    }
                });

                allReadyAdded.ForEach(i => itemResults.Remove(i));

                if (parent == null)
                {
                    result.Add(new DebugItem(itemResults));
                }
                else
                {
                    parent.AddRange(itemResults);
                }
            }
        }
        // Travis.Frisinger - 28.01.2013 : Amended for Debug
        public override List <DebugItem> GetDebugOutputs(IExecutionEnvironment dataList)
        {
            if (_debugOutputs != null && _debugOutputs.Count > 0)
            {
                return(_debugOutputs);
            }
            var               result       = new List <DebugItem>();
            string            resultString = _theResult.ToString();
            DebugItem         itemToAdd    = new DebugItem();
            IDataListCompiler c            = DataListFactory.CreateDataListCompiler();
            var               val          = new StringBuilder(Dev2DecisionStack.ExtractModelFromWorkflowPersistedData(ExpressionText));

            try
            {
                Dev2DecisionStack dds = c.ConvertFromJsonToModel <Dev2DecisionStack>(val);

                if (_theResult.ToString() == "True")
                {
                    resultString = dds.TrueArmText;
                }
                else if (_theResult.ToString() == "False")
                {
                    resultString = dds.FalseArmText;
                }

                itemToAdd.AddRange(new DebugItemStaticDataParams(resultString, "").GetDebugItemResult());
                result.Add(itemToAdd);
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch (Exception)
            // ReSharper restore EmptyGeneralCatchClause
            {
                itemToAdd.AddRange(new DebugItemStaticDataParams(resultString, "").GetDebugItemResult());
                result.Add(itemToAdd);
            }

            return(result);
        }
Beispiel #13
0
        List <DebugItem> GetDebugOutputs(string theResult)
        {
            var result       = new List <DebugItem>();
            var resultString = theResult;
            var itemToAdd    = new DebugItem();
            var dds          = Conditions;

            try
            {
                resultString = GetResultString(theResult, dds);

                itemToAdd.AddRange(new DebugItemStaticDataParams(resultString, "").GetDebugItemResult());
                result.Add(itemToAdd);
            }
            catch (Exception)
            {
                itemToAdd.AddRange(new DebugItemStaticDataParams(resultString, "").GetDebugItemResult());
                result.Add(itemToAdd);
            }

            _inner?.SetDebugOutputs(result);
            return(result);
        }
        void AddInputDebugItemResultsAfterEvaluate(List <IDebugItem> result, ref string userModel, IBinaryDataList dataList, Dev2DecisionMode decisionMode, string expression, out ErrorResultTO error, DebugItem parent = null)
        {
            error = new ErrorResultTO();
            if (expression != null && DataListUtil.IsEvaluated(expression))
            {
                DebugOutputBase debugResult;
                if (error.HasErrors())
                {
                    debugResult = new DebugItemStaticDataParams("", expression, "");
                }
                else
                {
                    var expressiomToStringValue = EvaluateExpressiomToStringValue(expression, decisionMode, dataList);
                    userModel = userModel.Replace(expression, expressiomToStringValue);
                    ErrorResultTO        errors;
                    IDataListCompiler    compiler         = DataListFactory.CreateDataListCompiler();
                    IBinaryDataListEntry expressionsEntry = compiler.Evaluate(dataList.UID, enActionType.User, expression, false, out errors);
                    debugResult = new DebugItemVariableParams(expression, "", expressionsEntry, dataList.UID);
                }

                var itemResults = debugResult.GetDebugItemResult();

                var allReadyAdded = new List <IDebugItemResult>();

                itemResults.ForEach(a =>
                {
                    var found = result.SelectMany(r => r.FetchResultsList())
                                .SingleOrDefault(r => r.Variable.Equals(a.Variable));
                    if (found != null)
                    {
                        allReadyAdded.Add(a);
                    }
                });

                allReadyAdded.ForEach(i => itemResults.Remove(i));

                if (parent == null)
                {
                    result.Add(new DebugItem(itemResults));
                }
                else
                {
                    parent.AddRange(itemResults);
                }
            }
        }
        private void HandleDebug(IDSFDataObject dataObject, IServiceTestStep serviceTestStep)
        {
            if (dataObject.IsDebugMode())
            {
                if (dataObject.IsServiceTestExecution && serviceTestStep != null)
                {
                    var debugItems = TestDebugMessageRepo.Instance.GetDebugItems(dataObject.ResourceID, dataObject.TestName);
                    debugItems = debugItems.Where(state => state.WorkSurfaceMappingId == serviceTestStep.ActivityID).ToList();
                    var debugStates = debugItems.LastOrDefault();

                    var debugItemStaticDataParams = new DebugItemServiceTestStaticDataParams(serviceTestStep.Result.Message, serviceTestStep.Result.RunTestResult == RunResult.TestFailed);
                    var itemToAdd = new DebugItem();
                    itemToAdd.AddRange(debugItemStaticDataParams.GetDebugItemResult());
                    debugStates?.AssertResultList?.Add(itemToAdd);
                }
                DispatchDebugState(dataObject, StateType.Duration, 0);
            }
        }
Beispiel #16
0
        void GetTestOurputResultForDebug(IDSFDataObject dataObject)
        {
            var serviceTestStep  = dataObject.ServiceTest?.TestSteps?.Flatten(step => step.Children)?.FirstOrDefault(step => step.ActivityID == _originalUniqueID);
            var serviceTestSteps = serviceTestStep?.Children;

            UpdateDebugStateWithAssertions(dataObject, serviceTestSteps?.ToList());
            if (serviceTestStep != null)
            {
                var testRunResult = new TestRunResult();
                GetFinalTestRunResult(serviceTestStep, testRunResult, dataObject);
                serviceTestStep.Result = testRunResult;

                var debugItems = TestDebugMessageRepo.Instance.GetDebugItems(dataObject.ResourceID, dataObject.TestName);
                debugItems = debugItems.Where(state => state.WorkSurfaceMappingId == serviceTestStep.ActivityID).ToList();
                var debugStates = debugItems.LastOrDefault();

                var debugItemStaticDataParams = new DebugItemServiceTestStaticDataParams(serviceTestStep.Result.Message, serviceTestStep.Result.RunTestResult == RunResult.TestFailed);
                var itemToAdd = new DebugItem();
                itemToAdd.AddRange(debugItemStaticDataParams.GetDebugItemResult());
                debugStates?.AssertResultList?.Add(itemToAdd);
            }
        }
Beispiel #17
0
        void Debug(IDSFDataObject dataObject, string firstOrDefault, Dev2Switch ds)
        {
            try
            {
                if (dataObject.IsDebugMode())
                {
                    var result      = new List <DebugItem>();
                    var itemToAdd   = new DebugItem();
                    var debugResult = new DebugItemWarewolfAtomResult(firstOrDefault, "", ds.SwitchVariable, "", "Switch on", "", "=");
                    itemToAdd.AddRange(debugResult.GetDebugItemResult());
                    result.Add(itemToAdd);
                    _debugInputs = result;

                    if (Inner != null)
                    {
                        Inner.SetDebugInputs(_debugInputs);
                    }
                }
            }
            catch (Exception e)
            {
                Dev2Logger.Warn(e.Message, GlobalConstants.WarewolfWarn);
            }
        }
Beispiel #18
0
        // Travis.Frisinger - 28.01.2013 : Amended for Debug
        public override List <DebugItem> GetDebugInputs(IExecutionEnvironment env, int update)
        {
            if (_debugInputs != null && _debugInputs.Count > 0)
            {
                return(_debugInputs);
            }
            List <IDebugItem> result = new List <IDebugItem>();
            var allErrors            = new ErrorResultTO();

            var val = new StringBuilder(Dev2DecisionStack.ExtractModelFromWorkflowPersistedData(ExpressionText));

            try
            {
                Dev2DecisionStack dds = DataListUtil.ConvertFromJsonToModel <Dev2DecisionStack>(val);
                ErrorResultTO     error;
                string            userModel = dds.GenerateUserFriendlyModel(env, dds.Mode, out error);
                allErrors.MergeErrors(error);

                foreach (Dev2Decision dev2Decision in dds.TheStack)
                {
                    AddInputDebugItemResultsAfterEvaluate(result, ref userModel, env, dds.Mode, dev2Decision.Col1, out error);
                    allErrors.MergeErrors(error);
                    AddInputDebugItemResultsAfterEvaluate(result, ref userModel, env, dds.Mode, dev2Decision.Col2, out error);
                    allErrors.MergeErrors(error);
                    AddInputDebugItemResultsAfterEvaluate(result, ref userModel, env, dds.Mode, dev2Decision.Col3, out error);
                    allErrors.MergeErrors(error);
                }

                var itemToAdd = new DebugItem();

                userModel = userModel.Replace("OR", " OR\r\n")
                            .Replace("AND", " AND\r\n")
                            .Replace("\r\n ", "\r\n")
                            .Replace("\r\n\r\n", "\r\n")
                            .Replace("  ", " ");

                AddDebugItem(new DebugItemStaticDataParams(userModel, "Statement"), itemToAdd);
                result.Add(itemToAdd);

                itemToAdd = new DebugItem();
                AddDebugItem(new DebugItemStaticDataParams(dds.Mode == Dev2DecisionMode.AND ? "YES" : "NO", "Require All decisions to be True"), itemToAdd);
                result.Add(itemToAdd);
            }
            catch (JsonSerializationException)
            {
                Dev2Switch ds = new Dev2Switch {
                    SwitchVariable = val.ToString()
                };
                DebugItem itemToAdd = new DebugItem();

                var a           = env.Eval(ds.SwitchVariable, 0);
                var debugResult = new DebugItemWarewolfAtomResult(ExecutionEnvironment.WarewolfEvalResultToString(a), "", ds.SwitchVariable, "", "Switch on", "", "=");
                itemToAdd.AddRange(debugResult.GetDebugItemResult());
                result.Add(itemToAdd);
            }
            catch (Exception e)
            {
                allErrors.AddError(e.Message);
            }
            finally
            {
                if (allErrors.HasErrors())
                {
                    var serviceName = GetType().Name;
                    DisplayAndWriteError(serviceName, allErrors);
                }
            }

            return(result.Select(a => a as DebugItem).ToList());
        }
Beispiel #19
0
        protected override void ExecuteTool(IDSFDataObject dataObject, int update)
        {
            ErrorResultTO allErrors = new ErrorResultTO();

            InitializeDebug(dataObject);

            if (string.IsNullOrEmpty(DataSource))
            {
                allErrors.AddError(ErrorResource.DataSourceEmpty);
            }
            if (string.IsNullOrEmpty(Alias))
            {
                allErrors.AddError(string.Format(ErrorResource.CanNotBeEmpty, "Alias"));
            }
            if (allErrors.HasErrors())
            {
                DisplayAndWriteError("DsfSelectAndApplyActivity", allErrors);
                foreach (var fetchError in allErrors.FetchErrors())
                {
                    dataObject.Environment.AddError(fetchError);
                }
            }
            var startTime = DateTime.Now;

            _previousParentId = dataObject.ParentInstanceID;
            _debugInputs      = new List <DebugItem>();
            _debugOutputs     = new List <DebugItem>();

            dataObject.ForEachNestingLevel++;

            List <string> expressions = new List <string>();

            try
            {
                string ds;
                try
                {
                    ds          = dataObject.Environment.ToStar(DataSource);
                    expressions = dataObject.Environment.GetIndexes(ds);
                    if (expressions.Count == 0)
                    {
                        expressions.Add(ds);
                    }
                }
                catch (NullReferenceException)
                {
                    //Do nothing exception aleady added to errors
                    throw new NullDataSource();
                }


                if (dataObject.IsDebugMode())
                {
                    AddDebugInputItem(new DebugItemStaticDataParams(Alias, "As", DataSource));
                }

                var scopedEnvironment = new ScopedEnvironment(dataObject.Environment, ds, Alias);

                //Push the new environment
                dataObject.PushEnvironment(scopedEnvironment);
                dataObject.ForEachNestingLevel++;
                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(dataObject, StateType.Before, update);
                }
                dataObject.ParentInstanceID = UniqueID;
                dataObject.IsDebugNested    = true;
                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(dataObject, StateType.After, update);
                }

                foreach (var exp in expressions)
                {
                    //Assign the warewolfAtom to Alias using new environment
                    scopedEnvironment.SetDataSource(exp);

                    var exeAct = ApplyActivityFunc.Handler as IDev2Activity;
                    if (exeAct != null)
                    {
                        _childUniqueID = exeAct.UniqueID;
                        exeAct.Execute(dataObject, 0);
                    }
                }
            }
            catch (NullDataSource e)
            {
                Dev2Logger.Error("DSFSelectAndApply", e);
            }
            catch (Exception e)
            {
                Dev2Logger.Error("DSFSelectAndApply", e);
                allErrors.AddError(e.Message);
            }
            finally
            {
                if (dataObject.IsDebugMode())
                {
                    if (dataObject.IsServiceTestExecution)
                    {
                        var serviceTestStep  = dataObject.ServiceTest?.TestSteps?.Flatten(step => step.Children)?.FirstOrDefault(step => step.UniqueId == _originalUniqueID);
                        var serviceTestSteps = serviceTestStep?.Children;
                        UpdateDebugStateWithAssertions(dataObject, serviceTestSteps?.ToList());
                        if (serviceTestStep != null)
                        {
                            var testRunResult = new TestRunResult();
                            GetFinalTestRunResult(serviceTestStep, testRunResult, dataObject);
                            serviceTestStep.Result = testRunResult;

                            var debugItems = TestDebugMessageRepo.Instance.GetDebugItems(dataObject.ResourceID, dataObject.TestName);
                            debugItems = debugItems.Where(state => state.WorkSurfaceMappingId == serviceTestStep.UniqueId).ToList();
                            var debugStates = debugItems.LastOrDefault();

                            var       debugItemStaticDataParams = new DebugItemServiceTestStaticDataParams(serviceTestStep.Result.Message, serviceTestStep.Result.RunTestResult == RunResult.TestFailed);
                            DebugItem itemToAdd = new DebugItem();
                            itemToAdd.AddRange(debugItemStaticDataParams.GetDebugItemResult());
                            debugStates?.AssertResultList?.Add(itemToAdd);
                        }
                    }
                }
                dataObject.PopEnvironment();
                dataObject.ForEachNestingLevel--;
                if (allErrors.HasErrors())
                {
                    if (allErrors.HasErrors())
                    {
                        DisplayAndWriteError("DsfSelectAndApplyActivity", allErrors);
                        foreach (var fetchError in allErrors.FetchErrors())
                        {
                            dataObject.Environment.AddError(fetchError);
                        }
                    }
                }
                if (dataObject.IsDebugMode())
                {
                    foreach (var expression in expressions)
                    {
                        var data = dataObject.Environment.Eval(expression, update);
                        if (data.IsWarewolfAtomListresult)
                        {
                            var lst = data as CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult;
                            AddDebugOutputItem(new DebugItemWarewolfAtomListResult(lst, "", "", expression, "", "", "="));
                        }
                        else
                        {
                            if (data.IsWarewolfAtomResult)
                            {
                                var atom = data as CommonFunctions.WarewolfEvalResult.WarewolfAtomResult;
                                if (atom != null)
                                {
                                    AddDebugOutputItem(new DebugItemWarewolfAtomResult(atom.Item.ToString(), expression, ""));
                                }
                            }
                        }
                    }

                    DispatchDebugState(dataObject, StateType.End, update, startTime, DateTime.Now);
                }
                OnCompleted(dataObject);
            }
        }
        // Travis.Frisinger - 28.01.2013 : Amended for Debug
        public override List <DebugItem> GetDebugInputs(IBinaryDataList dataList)
        {
            List <IDebugItem> result   = new List <IDebugItem>();
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();
            var allErrors = new ErrorResultTO();

            var val = new StringBuilder(Dev2DecisionStack.ExtractModelFromWorkflowPersistedData(ExpressionText));

            try
            {
                Dev2DecisionStack dds = compiler.ConvertFromJsonToModel <Dev2DecisionStack>(val);
                ErrorResultTO     error;
                string            userModel = dds.GenerateUserFriendlyModel(dataList.UID, dds.Mode, out error);
                allErrors.MergeErrors(error);

                foreach (Dev2Decision dev2Decision in dds.TheStack)
                {
                    AddInputDebugItemResultsAfterEvaluate(result, ref userModel, dataList, dds.Mode, dev2Decision.Col1, out error);
                    allErrors.MergeErrors(error);
                    AddInputDebugItemResultsAfterEvaluate(result, ref userModel, dataList, dds.Mode, dev2Decision.Col2, out error);
                    allErrors.MergeErrors(error);
                    AddInputDebugItemResultsAfterEvaluate(result, ref userModel, dataList, dds.Mode, dev2Decision.Col3, out error);
                    allErrors.MergeErrors(error);
                }

                var itemToAdd = new DebugItem();

                userModel = userModel.Replace("OR", " OR\r\n")
                            .Replace("AND", " AND\r\n")
                            .Replace("\r\n ", "\r\n")
                            .Replace("\r\n\r\n", "\r\n")
                            .Replace("  ", " ");

                AddDebugItem(new DebugItemStaticDataParams(userModel, "Statement"), itemToAdd);
                result.Add(itemToAdd);

                itemToAdd = new DebugItem();
                AddDebugItem(new DebugItemStaticDataParams(dds.Mode == Dev2DecisionMode.AND ? "YES" : "NO", "Require All decisions to be True"), itemToAdd);
                result.Add(itemToAdd);
            }
            catch (JsonSerializationException)
            {
                Dev2Switch ds = new Dev2Switch {
                    SwitchVariable = val.ToString()
                };
                DebugItem            itemToAdd = new DebugItem();
                ErrorResultTO        errors;
                IBinaryDataListEntry expressionsEntry = compiler.Evaluate(dataList.UID, enActionType.User, ds.SwitchVariable, false, out errors);
                var debugResult = new DebugItemVariableParams(ds.SwitchVariable, "Switch on", expressionsEntry, dataList.UID);
                itemToAdd.AddRange(debugResult.GetDebugItemResult());
                result.Add(itemToAdd);
            }
            catch (Exception e)
            {
                allErrors.AddError(e.Message);
            }
            finally
            {
                if (allErrors.HasErrors())
                {
                    var serviceName = GetType().Name;
                    DisplayAndWriteError(serviceName, allErrors);
                    ErrorResultTO error;
                    compiler.UpsertSystemTag(_dataListId, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out error);
                }
            }

            return(result.Select(a => a as DebugItem).ToList());
        }
Beispiel #21
0
        Guid ExecuteWf(ErrorResultTO to, IServiceTestModelTO test)
        {
            Guid          result       = new Guid();
            var           wfappUtils   = new WfApplicationUtils();
            ErrorResultTO invokeErrors = new ErrorResultTO();
            var           resourceId   = DataObject.ResourceID;

            if (test?.Inputs != null)
            {
                AddRecordsetsInputs(test.Inputs.Where(input => DataListUtil.IsValueRecordset(input.Variable) && !input.Variable.Contains("@")), DataObject.Environment);
                foreach (var input in test.Inputs)
                {
                    var variable = DataListUtil.AddBracketsToValueIfNotExist(input.Variable);
                    var value    = input.Value;
                    if (variable.StartsWith("[[@"))
                    {
                        var jContainer = JsonConvert.DeserializeObject(value) as JObject;
                        DataObject.Environment.AddToJsonObjects(variable, jContainer);
                    }
                    else if (!DataListUtil.IsValueRecordset(input.Variable))
                    {
                        string errorMessage;
                        if (ExecutionEnvironment.IsValidVariableExpression(input.Value, out errorMessage, 0))
                        {
                            DataObject.Environment.AllErrors.Add("Cannot use variables as input value.");
                        }
                        else
                        {
                            if (!input.EmptyIsNull || !string.IsNullOrEmpty(value))
                            {
                                DataObject.Environment.Assign(variable, value, 0);
                            }
                        }
                    }
                }
            }
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            try
            {
                IExecutionToken exeToken = new ExecutionToken {
                    IsUserCanceled = false
                };
                DataObject.ExecutionToken = exeToken;

                if (DataObject.IsDebugMode())
                {
                    var debugState = wfappUtils.GetDebugState(DataObject, StateType.Start, DataObject.Environment.HasErrors(), DataObject.Environment.FetchErrors(), invokeErrors, DateTime.Now, true, false, false);
                    wfappUtils.WriteDebug(DataObject, debugState);
                }

                var testRunResult = Eval(resourceId, DataObject, test);

                if (DataObject.IsDebugMode())
                {
                    if (!DataObject.StopExecution)
                    {
                        var       debugState      = wfappUtils.GetDebugState(DataObject, StateType.End, DataObject.Environment.HasErrors(), DataObject.Environment.FetchErrors(), invokeErrors, DataObject.StartTime, false, true, true);
                        DebugItem outputDebugItem = new DebugItem();
                        if (test != null)
                        {
                            var msg = test.FailureMessage;
                            if (test.TestPassed)
                            {
                                msg = Warewolf.Resource.Messages.Messages.Test_PassedResult;
                            }
                            outputDebugItem.AddRange(new DebugItemServiceTestStaticDataParams(msg, test.TestFailing).GetDebugItemResult());
                        }
                        debugState.AssertResultList.Add(outputDebugItem);
                        wfappUtils.WriteDebug(DataObject, debugState);
                    }
                    var testAggregateDebugState = wfappUtils.GetDebugState(DataObject, StateType.TestAggregate, false, string.Empty, new ErrorResultTO(), DataObject.StartTime, false, false, false);
                    AggregateTestResult(resourceId, test);

                    DebugItem itemToAdd = new DebugItem();
                    if (test != null)
                    {
                        var msg = test.FailureMessage;
                        if (test.TestPassed)
                        {
                            msg = Warewolf.Resource.Messages.Messages.Test_PassedResult;
                        }
                        itemToAdd.AddRange(new DebugItemServiceTestStaticDataParams(msg, test.TestFailing).GetDebugItemResult());
                    }
                    testAggregateDebugState.AssertResultList.Add(itemToAdd);
                    wfappUtils.WriteDebug(DataObject, testAggregateDebugState);

                    if (testRunResult != null)
                    {
                        if (test != null)
                        {
                            test.Result.DebugForTest = TestDebugMessageRepo.Instance.FetchDebugItems(resourceId, test.TestName);
                        }
                        _request.ExecuteResult = serializer.SerializeToBuilder(testRunResult);
                    }
                }
                else
                {
                    AggregateTestResult(resourceId, test);
                    if (test != null)
                    {
                        _request.ExecuteResult = serializer.SerializeToBuilder(test);
                    }
                }
                result = DataObject.DataListID;
            }
            catch (InvalidWorkflowException iwe)
            {
                Dev2Logger.Error(iwe);
                var msg = iwe.Message;

                int start = msg.IndexOf("Flowchart ", StringComparison.Ordinal);
                to?.AddError(start > 0 ? GlobalConstants.NoStartNodeError : iwe.Message);
                var failureMessage = DataObject.Environment.FetchErrors();
                wfappUtils.DispatchDebugState(DataObject, StateType.End, DataObject.Environment.HasErrors(), failureMessage, out invokeErrors, DataObject.StartTime, false, true);

                // ReSharper disable once PossibleNullReferenceException
                test.TestFailing = false;
                test.TestPassed  = false;
                test.TestPending = false;
                test.TestInvalid = true;
                test.LastRunDate = DateTime.Now;


                Common.Utilities.PerformActionInsideImpersonatedContext(Common.Utilities.ServerUser, () => { TestCatalog.Instance.SaveTest(resourceId, test); });

                var testRunResult = new TestRunResult {
                    TestName = test.TestName
                };
                if (test.TestInvalid)
                {
                    testRunResult.RunTestResult = RunResult.TestInvalid;
                    testRunResult.Message       = failureMessage;
                    Dev2Logger.Error($"Test {DataObject.TestName} for Resource {DataObject.ServiceName} ID {DataObject.ResourceID} marked invalid in exception for no start node");
                }
                testRunResult.DebugForTest = TestDebugMessageRepo.Instance.FetchDebugItems(resourceId, test.TestName);
                if (_request != null)
                {
                    _request.ExecuteResult = serializer.SerializeToBuilder(testRunResult);
                }
            }
            catch (Exception ex)
            {
                Dev2Logger.Error(ex);
                to.AddError(ex.Message);
                var failureMessage = DataObject.Environment.FetchErrors();
                wfappUtils.DispatchDebugState(DataObject, StateType.End, DataObject.Environment.HasErrors(), failureMessage, out invokeErrors, DataObject.StartTime, false, true);
                // ReSharper disable once PossibleNullReferenceException
                test.TestFailing = false;
                test.TestPassed  = false;
                test.TestPending = false;
                test.TestInvalid = true;
                test.LastRunDate = DateTime.Now;


                Common.Utilities.PerformActionInsideImpersonatedContext(Common.Utilities.ServerUser, () => { TestCatalog.Instance.SaveTest(resourceId, test); });

                var testRunResult = new TestRunResult {
                    TestName = test.TestName
                };
                if (test.TestInvalid)
                {
                    testRunResult.RunTestResult = RunResult.TestInvalid;
                    testRunResult.Message       = ex.Message;
                    Dev2Logger.Error($"Test {DataObject.TestName} for Resource {DataObject.ServiceName} ID {DataObject.ResourceID} marked invalid in general exception");
                }
                testRunResult.DebugForTest = TestDebugMessageRepo.Instance.FetchDebugItems(resourceId, test.TestName);
                _request.ExecuteResult     = serializer.SerializeToBuilder(testRunResult);
            }
            return(result);
        }
Beispiel #22
0
        Guid ExecuteWf(IServiceTestModelTO test, WfApplicationUtils wfappUtils, ErrorResultTO invokeErrors, Guid resourceId, Dev2JsonSerializer serializer)
        {
            Guid            result;
            IExecutionToken exeToken = new ExecutionToken {
                IsUserCanceled = false
            };

            DataObject.ExecutionToken = exeToken;

            if (DataObject.IsDebugMode())
            {
                var debugState = wfappUtils.GetDebugState(DataObject, StateType.Start, DataObject.Environment.HasErrors(), DataObject.Environment.FetchErrors(), invokeErrors, DateTime.Now, true, false, false);
                wfappUtils.TryWriteDebug(DataObject, debugState);
            }

            var testRunResult = Eval(resourceId, DataObject, test);

            if (DataObject.IsDebugMode())
            {
                if (!DataObject.StopExecution)
                {
                    var debugState      = wfappUtils.GetDebugState(DataObject, StateType.End, DataObject.Environment.HasErrors(), DataObject.Environment.FetchErrors(), invokeErrors, DataObject.StartTime, false, true, true);
                    var outputDebugItem = new DebugItem();
                    if (test != null)
                    {
                        var msg = test.TestPassed ? Warewolf.Resource.Messages.Messages.Test_PassedResult : test.FailureMessage;
                        outputDebugItem.AddRange(new DebugItemServiceTestStaticDataParams(msg, test.TestFailing).GetDebugItemResult());
                    }
                    debugState.AssertResultList.Add(outputDebugItem);
                    wfappUtils.TryWriteDebug(DataObject, debugState);
                }
                DebugState testAggregateDebugState;
                if (DataObject.StopExecution && DataObject.Environment.HasErrors())
                {
                    var existingErrors = DataObject.Environment.FetchErrors();
                    DataObject.Environment.AllErrors.Clear();
                    testAggregateDebugState = wfappUtils.GetDebugState(DataObject, StateType.TestAggregate, DataObject.Environment.HasErrors(), string.Empty, new ErrorResultTO(), DataObject.StartTime, false, false, false);
                    SetTestFailureBasedOnExpectedError(test, existingErrors);
                }
                else
                {
                    testAggregateDebugState = wfappUtils.GetDebugState(DataObject, StateType.TestAggregate, false, string.Empty, new ErrorResultTO(), DataObject.StartTime, false, false, false);
                    AggregateTestResult(resourceId, test);
                }

                var itemToAdd = new DebugItem();
                if (test != null)
                {
                    var msg = test.FailureMessage;
                    if (test.TestPassed)
                    {
                        msg = Warewolf.Resource.Messages.Messages.Test_PassedResult;
                    }
                    itemToAdd.AddRange(new DebugItemServiceTestStaticDataParams(msg, test.TestFailing).GetDebugItemResult());
                }
                testAggregateDebugState.AssertResultList.Add(itemToAdd);
                wfappUtils.TryWriteDebug(DataObject, testAggregateDebugState);

                if (testRunResult != null)
                {
                    if (test?.Result != null)
                    {
                        test.Result.DebugForTest = TestDebugMessageRepo.Instance.FetchDebugItems(resourceId, test.TestName);
                    }

                    _request.ExecuteResult = serializer.SerializeToBuilder(testRunResult);
                }
            }
            else
            {
                if (DataObject.StopExecution && DataObject.Environment.HasErrors())
                {
                    var existingErrors = DataObject.Environment.FetchErrors();
                    DataObject.Environment.AllErrors.Clear();
                    SetTestFailureBasedOnExpectedError(test, existingErrors);
                    _request.ExecuteResult = serializer.SerializeToBuilder(test);
                }
                else
                {
                    AggregateTestResult(resourceId, test);
                    if (test != null)
                    {
                        _request.ExecuteResult = serializer.SerializeToBuilder(test);
                    }
                }
            }
            result = DataObject.DataListID;
            return(result);
        }
Beispiel #23
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);
        }
        protected override void ExecuteTool(IDSFDataObject dataObject, int update)
        {
            _previousParentId = dataObject.ParentInstanceID;
            _debugInputs      = new List <DebugItem>();
            _debugOutputs     = new List <DebugItem>();

            ErrorResultTO  allErrors = new ErrorResultTO();
            IIndexIterator itr       = null;

            InitializeDebug(dataObject);
            dataObject.ForEachNestingLevel++;
            try
            {
                ErrorResultTO      errors;
                ForEachBootstrapTO exePayload = FetchExecutionType(dataObject, dataObject.Environment, out errors, update);

                foreach (var err in errors.FetchErrors())
                {
                    dataObject.Environment.AddError(err);
                }
                itr = exePayload.IndexIterator;

                string error;
                ForEachInnerActivityTO innerA = GetInnerActivity(out error);
                var exeAct = innerA?.InnerActivity;
                allErrors.AddError(error);
                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(dataObject, StateType.Before, update);
                }
                dataObject.ParentInstanceID = UniqueID;
                dataObject.IsDebugNested    = true;
                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(dataObject, StateType.After, update);
                }
                exePayload.InnerActivity = innerA;

                while (itr?.HasMore() ?? false)
                {
                    operationalData = exePayload;
                    int idx         = exePayload.IndexIterator.FetchNextIndex();
                    int innerupdate = 0;
                    if (exePayload.ForEachType != enForEachType.NumOfExecution)
                    {
                        innerupdate = idx;
                    }
                    _childUniqueID = exeAct?.UniqueID;
                    exeAct?.Execute(dataObject, innerupdate);

                    operationalData.IncIterationCount();
                }
                if (errors.HasErrors())
                {
                    allErrors.MergeErrors(errors);
                }
            }
            catch (Exception e)
            {
                Dev2Logger.Error("DSFForEach", e);
                allErrors.AddError(e.Message);
            }
            finally
            {
                if (itr != null)
                {
                    if (ForEachType != enForEachType.NumOfExecution)
                    {
                        RestoreHandlerFn();
                    }
                }
                var serviceTestStep = dataObject.ServiceTest?.TestSteps?.Flatten(step => step.Children)?.FirstOrDefault(step => step.UniqueId == _originalUniqueID);
                if (dataObject.IsServiceTestExecution)
                {
                    var serviceTestSteps = serviceTestStep?.Children;
                    UpdateDebugStateWithAssertions(dataObject, serviceTestSteps?.ToList());
                    if (serviceTestStep != null)
                    {
                        var testRunResult = new TestRunResult();
                        GetFinalTestRunResult(serviceTestStep, testRunResult);
                        serviceTestStep.Result = testRunResult;
                    }
                }
                dataObject.ParentInstanceID = _previousParentId;
                dataObject.ForEachNestingLevel--;
                dataObject.IsDebugNested = false;
                if (dataObject.IsDebugMode())
                {
                    if (dataObject.IsServiceTestExecution && serviceTestStep != null)
                    {
                        var debugItems = TestDebugMessageRepo.Instance.GetDebugItems(dataObject.ResourceID, dataObject.TestName);
                        debugItems = debugItems.Where(state => state.WorkSurfaceMappingId == serviceTestStep.UniqueId).ToList();
                        var debugStates = debugItems.LastOrDefault();

                        var       debugItemStaticDataParams = new DebugItemServiceTestStaticDataParams(serviceTestStep.Result.Message, serviceTestStep.Result.RunTestResult == RunResult.TestFailed);
                        DebugItem itemToAdd = new DebugItem();
                        itemToAdd.AddRange(debugItemStaticDataParams.GetDebugItemResult());
                        debugStates?.AssertResultList?.Add(itemToAdd);
                    }
                    DispatchDebugState(dataObject, StateType.Duration, 0);
                }
                // Handle Errors
                if (allErrors.HasErrors())
                {
                    dataObject.ParentInstanceID = _previousParentId;
                    dataObject.ForEachNestingLevel--;
                    dataObject.IsDebugNested = false;
                    // Handle Errors
                    if (allErrors.HasErrors())
                    {
                        DisplayAndWriteError("DsfForEachActivity", allErrors);
                        foreach (var fetchError in allErrors.FetchErrors())
                        {
                            dataObject.Environment.AddError(fetchError);
                        }

                        dataObject.ParentInstanceID = _previousParentId;
                    }
                }
            }
        }
        protected override void ChildDebugStateDispatch(IDSFDataObject dataObject)
        {
            if (dataObject.IsDebugMode())
            {
                foreach (var debugState in _childStatesToDispatch)
                {
                    DispatchDebugState(debugState, dataObject);
                    if (dataObject.IsServiceTestExecution)
                    {
                        var serviceTestStep  = dataObject.ServiceTest?.TestSteps?.Flatten(step => step.Children)?.FirstOrDefault(step => step.UniqueId == Guid.Parse(UniqueID));
                        var serviceTestSteps = serviceTestStep?.Children;
                        dataObject.ResourceID = debugState.SourceResourceID;
                        UpdateDebugWithAssertions(dataObject, serviceTestSteps?.ToList(), debugState.ID);
                    }
                }
            }
            if (dataObject.IsServiceTestExecution)
            {
                var serviceTestStep = dataObject.ServiceTest?.TestSteps?.Flatten(step => step.Children)?.FirstOrDefault(step => step.UniqueId == Guid.Parse(UniqueID));
                if (serviceTestStep != null)
                {
                    if (!dataObject.IsDebugMode())
                    {
                        var serviceTestSteps = serviceTestStep.Children;
                        foreach (var serviceTestTestStep in serviceTestSteps)
                        {
                            UpdateForRegularActivity(dataObject, serviceTestTestStep);
                        }
                    }
                    var testRunResult = new TestRunResult();
                    GetFinalTestRunResult(serviceTestStep, testRunResult);
                    serviceTestStep.Result = testRunResult;
                    if (dataObject.IsDebugMode())
                    {
                        var states = TestDebugMessageRepo.Instance.GetDebugItems(dataObject.ResourceID, dataObject.TestName);
                        if (states != null)
                        {
                            states = states.Where(state => state.ID == Guid.Parse(UniqueID)).ToList();
                            var debugState = states.FirstOrDefault();
                            if (debugState != null)
                            {
                                var msg = testRunResult.Message;
                                if (testRunResult.RunTestResult == RunResult.TestPassed)
                                {
                                    msg = Messages.Test_PassedResult;
                                }

                                var hasError = testRunResult.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);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }