Exemple #1
0
        public static List <AnalyzerItemBase> Analyze(GingerExecutionEngine GR, BusinessFlow BusinessFlow)
        {
            List <AnalyzerItemBase> IssuesList = new List <AnalyzerItemBase>();

            //code added to analyze for BFFlowControls in Runner BF.
            if (BusinessFlow.BFFlowControls.Count > 0)
            {
                foreach (FlowControl f in BusinessFlow.BFFlowControls)
                {
                    if (f.Active == true)
                    {
                        if (f.BusinessFlowControlAction == eBusinessFlowControlAction.GoToBusinessFlow)
                        {
                            string       GoToBusinessFlow = f.GetNameFromValue();
                            BusinessFlow bf           = null;
                            Guid         guidToLookBy = Guid.Empty;

                            if (!string.IsNullOrEmpty(f.GetGuidFromValue().ToString()))
                            {
                                guidToLookBy = Guid.Parse(f.GetGuidFromValue().ToString());
                            }

                            List <BusinessFlow> lstBusinessFlow = null;
                            if (guidToLookBy != Guid.Empty)
                            {
                                lstBusinessFlow = GR.BusinessFlows.Where(x => x.InstanceGuid == guidToLookBy).ToList();
                            }

                            if (lstBusinessFlow == null || lstBusinessFlow.Count == 0)
                            {
                                bf = null;
                            }
                            else if (lstBusinessFlow.Count == 1)
                            {
                                bf = (BusinessFlow)lstBusinessFlow[0];
                            }
                            else//we have more than 1
                            {
                                BusinessFlow firstActive = (BusinessFlow)lstBusinessFlow.Where(x => x.Active == true).FirstOrDefault();
                                if (firstActive != null)
                                {
                                    bf = firstActive;
                                }
                                else
                                {
                                    bf = (BusinessFlow)lstBusinessFlow[0];//no one is Active so returning the first one
                                }
                            }
                            if (bf == null)
                            {
                                AnalyzeRunnerBusinessFlow ABF = CreateNewIssue(IssuesList, GR, BusinessFlow);
                                ABF.Description = "Flow control is mapped to " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " which does not exist";
                                ABF.Details     = "'" + GoToBusinessFlow + "' " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " does not exist in the '" + GR.GingerRunner.Name + " ' " + GingerDicser.GetTermResValue(eTermResKey.RunSet);
                                ABF.HowToFix    = "Remap the Flow Control Action";
                                ABF.IssueType   = eType.Error;
                                ABF.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                                ABF.Impact      = "Flow Control will fail on run time";
                                ABF.Severity    = eSeverity.High;
                            }
                        }
                        if (f.BusinessFlowControlAction == eBusinessFlowControlAction.SetVariableValue)
                        {
                            if (string.IsNullOrEmpty(f.Value) || ValueExpression.IsThisDynamicVE(f.Value) == false)
                            {
                                string   SetVariableValue = f.GetNameFromValue();
                                string[] vals             = SetVariableValue.Split(new char[] { '=' });
                                if ((BusinessFlow.GetAllHierarchyVariables().Where(x => x.Name == vals[0].Trim()).Select(x => x.Name).FirstOrDefault() == null))
                                {
                                    AnalyzeRunnerBusinessFlow ABF = CreateNewIssue(IssuesList, GR, BusinessFlow);
                                    ABF.Description = "Flow control mapped to " + GingerDicser.GetTermResValue(eTermResKey.Variable) + " which does not exist";;
                                    ABF.Details     = "'" + vals[0].Trim() + "' " + GingerDicser.GetTermResValue(eTermResKey.Variable) + " does not exist in parent items";
                                    ABF.HowToFix    = "Remap the Flow Control Action";
                                    ABF.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                                    ABF.IssueType   = eType.Error;
                                    ABF.Impact      = "Flow Control will fail on run time";
                                    ABF.Severity    = eSeverity.High;
                                }
                            }
                        }
                    }
                }
            }

            IssuesList.AddRange(AnalyzeBusinessFlow.AnalyzeForMissingMandatoryInputValues(BusinessFlow));

            return(IssuesList);
        }