Пример #1
0
        public static List <AnalyzerItemBase> Analyze(BusinessFlow BusinessFlow, Activity parentActivity, Act a, ObservableList <DataSourceBase> DSList)
        {
            // Put all tests on Action here
            List <string>           ActivityUsedVariables           = new List <string>();
            List <string>           mUsedGlobalParameters           = new List <string>();
            List <string>           mMissingStoreToGlobalParameters = new List <string>();
            List <AnalyzerItemBase> IssuesList = new List <AnalyzerItemBase>();
            ObservableList <GlobalAppModelParameter> mModelsGlobalParamsList = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <GlobalAppModelParameter>();

            // Check if the action is obsolete and suggest conversion/upgrade/delete
            //if (a is IObsoleteAction)
            //{
            //    if (a.Active)
            //    {
            //        // TODO: get platform from activity in test
            //        Platform.eType ActivitySourcePlatform = Platform.eType.AndroidDevice;  //FIXME temp

            //        // if it is active then create conversion issue
            //        if (((IObsoleteAction)a).IsObsoleteForPlatform(ActivitySourcePlatform))
            //        {
            //            AnalyzeAction AA = CreateNewIssue(IssuesList, BusinessFlow, Activity, a);
            //            AA.Description = GingerDicser.GetTermResValue(eTermResKey.Activity) + " Contains Obsolete action"; ;
            //            AA.Details = a.Description + " Old Class=" + a.ActClass;
            //            AA.HowToFix = "Convert to new action"; // TODO: get name of new action
            //            AA.CanAutoFix = AnalyzerItemBase.eCanFix.Yes;
            //            AA.IssueType = eType.Warning;
            //            AA.Impact = "New action can have more capabilities and more stable, good to upgrade";
            //            AA.Severity = eSeverity.Medium;
            //            AA.FixItHandler = UpgradeAction;
            //            AA.ActivitySourcePlatform = ActivitySourcePlatform;
            //        }
            //    }
            //    else
            //    {
            //        // old action but not active so create issue of delete old unused action
            //        AnalyzeAction AA = CreateNewIssue(IssuesList, BusinessFlow, Activity, a);
            //        AA.Description = GingerDicser.GetTermResValue(eTermResKey.Activity) + " Contains Obsolete action which is not used"; ;
            //        AA.Details = a.Description + " Old Class=" + a.ActClass;
            //        AA.HowToFix = "Delete action";
            //        AA.CanAutoFix = AnalyzerItemBase.eCanFix.Yes;
            //        AA.IssueType = eType.Warning;
            //        AA.Impact = "slower execution, disk space";
            //        AA.Severity = eSeverity.Low;
            //        AA.FixItHandler = DeleteAction;
            //    }
            //}
            //Flow Control -> GoToAction , Check if Action u want to go to exist
            if (a.FlowControls.Count > 0)
            {
                foreach (GingerCore.FlowControlLib.FlowControl f in a.FlowControls)
                {
                    if (f.Active == true)
                    {
                        if (f.FlowControlAction == eFlowControlAction.GoToAction)
                        {
                            string GoToActionName = f.GetNameFromValue();
                            if (parentActivity.GetAct(f.GetGuidFromValue(true), f.GetNameFromValue(true)) == null)
                            {
                                AnalyzeAction AA = CreateNewIssue(BusinessFlow, parentActivity, a);
                                AA.Description = "Flow control is mapped to Action which does not exist";;
                                AA.Details     = "'" + GoToActionName + "' Action does not exist in '" + parentActivity.ActivityName + "' " + GingerDicser.GetTermResValue(eTermResKey.Activity);
                                AA.HowToFix    = "Remap the Flow Control Action";

                                if (parentActivity.Acts.Where(x => x.Description == f.GetNameFromValue()).FirstOrDefault() != null)
                                {
                                    //can be auto fix
                                    AA.HowToFix        = "Remap Flow Control Action. Auto fix found other Action with the same name so it will fix the mapping to this Action.";
                                    AA.ErrorInfoObject = f;
                                    AA.CanAutoFix      = AnalyzerItemBase.eCanFix.Yes;
                                    AA.FixItHandler    = FixFlowControlWrongActionMapping;
                                }
                                else
                                {
                                    AA.CanAutoFix = AnalyzerItemBase.eCanFix.No;
                                }

                                AA.IssueType = eType.Error;
                                AA.Impact    = "Flow Control will fail on run time";
                                AA.Severity  = eSeverity.High;

                                IssuesList.Add(AA);
                            }
                        }
                        if (f.FlowControlAction == eFlowControlAction.GoToActivity)
                        {
                            string GoToActivity = f.GetNameFromValue();
                            //if (BusinessFlow.Activities.Where(x => (x.ActivityName == GoToActivity)).FirstOrDefault() == null)
                            if (BusinessFlow.GetActivity(f.GetGuidFromValue(true), f.GetNameFromValue(true)) == null)
                            {
                                AnalyzeAction AA = CreateNewIssue(BusinessFlow, parentActivity, a);
                                AA.Description = "Flow control is mapped to " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " which does not exist";;
                                AA.Details     = "'" + GoToActivity + "' " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " does not exist in the '" + BusinessFlow.Name + " ' " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow);
                                AA.HowToFix    = "Remap the Flow Control Action";

                                if (BusinessFlow.Activities.Where(x => x.ActivityName == f.GetNameFromValue()).FirstOrDefault() != null)
                                {
                                    //can be auto fix
                                    AA.HowToFix        = "Remap Flow Control " + GingerDicser.GetTermResValue(eTermResKey.Activity) + ". Auto fix found other " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " with the same name so it will fix the mapping to this " + GingerDicser.GetTermResValue(eTermResKey.Activity) + ".";
                                    AA.ErrorInfoObject = f;
                                    AA.CanAutoFix      = AnalyzerItemBase.eCanFix.Yes;
                                    AA.FixItHandler    = FixFlowControlWrongActivityMapping;
                                }
                                else
                                {
                                    AA.CanAutoFix = AnalyzerItemBase.eCanFix.No;
                                }

                                AA.IssueType = eType.Error;
                                AA.Impact    = "Flow Control will fail on run time";
                                AA.Severity  = eSeverity.High;

                                IssuesList.Add(AA);
                            }
                        }
                        if (f.FlowControlAction == eFlowControlAction.GoToNextActivity)
                        {
                            if (BusinessFlow.Activities.IndexOf(parentActivity) == (BusinessFlow.Activities.Count() - 1))
                            {
                                AnalyzeAction AA = CreateNewIssue(BusinessFlow, parentActivity, a);
                                AA.Description = "Flow control is mapped to " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " which does not exist";;
                                AA.Details     = "Flow Control is set to 'GoToNextActivity' but the parent " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " is last one in flow.";
                                AA.HowToFix    = "Remap the Flow Control Action";
                                AA.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                                AA.IssueType   = eType.Error;
                                AA.Impact      = "Flow Control will fail on run time";
                                AA.Severity    = eSeverity.High;

                                IssuesList.Add(AA);
                            }
                        }
                        if (f.FlowControlAction == eFlowControlAction.SetVariableValue)
                        {
                            if (string.IsNullOrEmpty(f.Value) || ValueExpression.IsThisDynamicVE(f.Value) == false)
                            {
                                string   SetVariableValue = f.GetNameFromValue();
                                string[] vals             = SetVariableValue.Split(new char[] { '=' });
                                if (!BusinessFlow.CheckIfVariableExists(vals[0].ToString().Trim(), parentActivity))
                                {
                                    AnalyzeAction AA = CreateNewIssue(BusinessFlow, parentActivity, a);
                                    AA.Description = "Flow control mapped to " + GingerDicser.GetTermResValue(eTermResKey.Variable) + " which does not exist";;
                                    AA.Details     = "'" + vals[0].Trim() + "' " + GingerDicser.GetTermResValue(eTermResKey.Variable) + " does not exist in parent items";
                                    AA.HowToFix    = "Remap the Flow Control Action";
                                    AA.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                                    AA.IssueType   = eType.Error;
                                    AA.Impact      = "Flow Control will fail on run time";
                                    AA.Severity    = eSeverity.High;

                                    IssuesList.Add(AA);
                                }
                            }
                        }
                        if (f.FlowControlAction == eFlowControlAction.RunSharedRepositoryActivity)
                        {
                            if (string.IsNullOrEmpty(f.Value) || ValueExpression.IsThisDynamicVE(f.Value) == false)
                            {
                                //f.CalcualtedValue(BusinessFlow, App.ProjEnvironment, WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<DataSourceBase>());
                                string RunSharedRepositoryActivity   = f.GetNameFromValue();
                                ObservableList <Activity> activities = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Activity>();
                                if (activities.Where(x => x.ActivityName == RunSharedRepositoryActivity).FirstOrDefault() == null)
                                {
                                    AnalyzeAction AA = CreateNewIssue(BusinessFlow, parentActivity, a);
                                    AA.Description = "Flow control mapped to Shared Repository " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " which does not exist";
                                    AA.Details     = "'" + RunSharedRepositoryActivity + "' " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " does not exist in Shared Repository";
                                    AA.HowToFix    = "Remap the Flow Control Action";
                                    AA.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                                    AA.IssueType   = eType.Error;
                                    AA.Impact      = "Flow Control will fail on run time";
                                    AA.Severity    = eSeverity.High;

                                    IssuesList.Add(AA);
                                }
                            }
                        }
                        if (f.FlowControlAction == eFlowControlAction.GoToActivityByName)
                        {
                            if (string.IsNullOrEmpty(f.Value) || ValueExpression.IsThisDynamicVE(f.Value) == false)
                            {
                                string activityToGoTo = f.GetNameFromValue();
                                if (BusinessFlow.Activities.Where(x => x.ActivityName == activityToGoTo).FirstOrDefault() == null)
                                {
                                    AnalyzeAction AA = CreateNewIssue(BusinessFlow, parentActivity, a);
                                    AA.Description = "Flow control mapped to " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " which does not exist";
                                    AA.Details     = "'" + activityToGoTo + "' " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " does not exist in the parent " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow);
                                    AA.HowToFix    = "Remap the Flow Control Action";
                                    AA.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                                    AA.IssueType   = eType.Error;
                                    AA.Impact      = "Flow Control will fail on run time";
                                    AA.Severity    = eSeverity.High;

                                    IssuesList.Add(AA);
                                }
                            }
                        }
                    }
                }
            }

            if (a.ActReturnValues.Count > 0)
            {
                foreach (ActReturnValue ARV in a.ActReturnValues)
                {
                    if (ARV.StoreTo != ActReturnValue.eStoreTo.None)
                    {
                        string StoreToValue = ARV.StoreToValue;
                        ActReturnValue.eStoreTo StoreToType = ARV.StoreTo;
                        if (StoreToType == ActReturnValue.eStoreTo.Variable)
                        {
                            if (BusinessFlow.GetAllVariables(parentActivity).Where(x => x.Name == StoreToValue).Select(x => x.Name).FirstOrDefault() == null)
                            {
                                AnalyzeAction AA = CreateNewIssue(BusinessFlow, parentActivity, a);
                                AA.Description = "Output Values is missing " + GingerDicser.GetTermResValue(eTermResKey.Variable) + " '" + StoreToValue + "'";
                                AA.Details     = "'" + StoreToValue + "' does not exist In " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " '" + BusinessFlow.Name + "' => " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " '" + parentActivity.ActivityName + "' =>" + "Action '" + a.Description + "' ";
                                AA.HowToFix    = "Remap Output Values";
                                AA.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                                AA.IssueType   = eType.Error;
                                AA.Impact      = "Execution will fail in run time";
                                AA.Severity    = eSeverity.Critical;

                                IssuesList.Add(AA);
                            }
                        }
                        else if (StoreToType == ActReturnValue.eStoreTo.DataSource)
                        {
                            if (StoreToValue != "" && StoreToValue != null)
                            {
                                string chkDataSource = "";
                                Regex  rxDSPattern   = new Regex(@"{(\bDS Name=)\w+\b[^{}]*}", RegexOptions.Compiled);

                                MatchCollection matches = rxDSPattern.Matches(StoreToValue);
                                foreach (Match match in matches)
                                {
                                    chkDataSource = GingerCore.General.CheckDataSource(match.Value, DSList);
                                    if (chkDataSource != "")
                                    {
                                        AnalyzeAction AA = CreateNewIssue(BusinessFlow, parentActivity, a);
                                        AA.Description = chkDataSource;
                                        AA.Details     = "Invalid '" + StoreToValue + "' StoreTo Value used In " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " '" + BusinessFlow.Name + "' => " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " '" + parentActivity.ActivityName + "' =>" + "Action '" + a.Description + "' ";
                                        AA.HowToFix    = "Remap Output Values";
                                        AA.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                                        AA.IssueType   = eType.Error;
                                        AA.Impact      = "Execution will fail in run time";
                                        AA.Severity    = eSeverity.Critical;
                                        IssuesList.Add(AA);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            //Disabling the below because there are many actions which shows Locate By/Value but it is not needed for most operation types
            //if (a.ObjectLocatorConfigsNeeded == true && a.ActionDescription != "Script Action" && a.ActionDescription != "File Operations")
            //{
            //    if (a.LocateBy.ToString() == "NA")
            //    {
            //        AnalyzeAction AA = CreateNewIssue(IssuesList, BusinessFlow, parentActivity, a);
            //        AA.Description = "Action is missing LocateBy value";
            //        AA.Details = "Action '" + a.Description + "' In " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " '" + parentActivity.ActivityName + "' is missing LocateBy value";
            //        AA.HowToFix = " Add LocateBy value to '" + a.Description + "'";
            //        AA.CanAutoFix = AnalyzerItemBase.eCanFix.No;    // yes if we have one target app, or just set the first
            //        AA.IssueType = eType.Warning;
            //        AA.Impact = GingerDicser.GetTermResValue(eTermResKey.Activity) + " will not be executed and will fail";
            //        AA.Severity = eSeverity.Medium;
            //    }
            //    if (a.LocateValue == null || a.LocateValue == "")
            //    {
            //        AnalyzeAction AA = CreateNewIssue(IssuesList, BusinessFlow, parentActivity, a);
            //        AA.Description = "Action is missing Locate Value ";
            //        AA.Details = "Action '" + a.Description + "' In " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " '" + parentActivity.ActivityName + "' is missing Locate value";
            //        AA.HowToFix = " Add Locate Value to '" + a.Description + "'";
            //        AA.CanAutoFix = AnalyzerItemBase.eCanFix.No;    // yes if we have one target app, or just set the first
            //        AA.IssueType = eType.Warning;
            //        AA.Impact = GingerDicser.GetTermResValue(eTermResKey.Activity) + " will not be executed and will fail";
            //        AA.Severity = eSeverity.Medium;
            //    }

            //}
            VariableBase.GetListOfUsedVariables(a, ref ActivityUsedVariables);
            if (ActivityUsedVariables.Count > 0)
            {
                foreach (string Var in ActivityUsedVariables)
                {
                    if (BusinessFlow.GetAllVariables(parentActivity).Where(x => x.Name == Var).Select(x => x.Name).FirstOrDefault() == null)
                    {
                        AnalyzeAction AA = CreateNewIssue(BusinessFlow, parentActivity, a);
                        AA.Description = "The " + GingerDicser.GetTermResValue(eTermResKey.Variable) + " '" + Var + "' is missing";
                        AA.Details     = "The " + GingerDicser.GetTermResValue(eTermResKey.Variable) + ": '" + Var + "' Does not exist In " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " '" + BusinessFlow.Name + "' => " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " '" + parentActivity.ActivityName + "' =>" + "Action '" + a.Description + "' ";
                        AA.HowToFix    = " Create new " + GingerDicser.GetTermResValue(eTermResKey.Variable) + " or Delete it from the action.";
                        AA.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                        AA.IssueType   = eType.Error;
                        AA.Impact      = GingerDicser.GetTermResValue(eTermResKey.Activity) + " will fail due to missing " + GingerDicser.GetTermResValue(eTermResKey.Variable);
                        AA.Severity    = eSeverity.High;

                        IssuesList.Add(AA);
                    }
                }
            }



            GlobalAppModelParameter.GetListOfUsedGlobalParameters(a, ref mUsedGlobalParameters);
            if (mUsedGlobalParameters.Count > 0)
            {
                foreach (string Param in mUsedGlobalParameters)
                {
                    GlobalAppModelParameter globalParam = mModelsGlobalParamsList.Where(x => x.PlaceHolder == Param).FirstOrDefault();
                    if (globalParam == null)
                    {
                        AnalyzeAction AA = CreateNewIssue(BusinessFlow, parentActivity, a);
                        AA.Description = "The Application Global Parameter " + Param + " is missing";
                        AA.Details     = "The Application Global Parameter: '" + Param + "' Does not exist in Models Global Parameters";
                        AA.HowToFix    = " Create new Application Global Parameter or Delete it from the action.";
                        AA.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                        AA.IssueType   = eType.Error;
                        AA.Impact      = GingerDicser.GetTermResValue(eTermResKey.Activity) + " will fail due to missing " + GingerDicser.GetTermResValue(eTermResKey.Variable);
                        AA.Severity    = eSeverity.High;
                        IssuesList.Add(AA);
                    }
                }
            }

            GetAllStoreToGlobalParameters(a, mModelsGlobalParamsList, ref mMissingStoreToGlobalParameters);
            if (mMissingStoreToGlobalParameters.Count > 0)
            {
                foreach (string Param in mMissingStoreToGlobalParameters)
                {
                    AnalyzeAction AA = CreateNewIssue(BusinessFlow, parentActivity, a);
                    AA.Description = "The Output Value with Parameter '" + Param + "' is having store to Parameter which doesn't exist anymore";
                    AA.Details     = "The Output Value with Parameter: '" + Param + "' can be found at " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " '" + BusinessFlow.Name + "' => " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " '" + parentActivity.ActivityName + "' =>" + "Action '" + a.Description + "' ";
                    AA.HowToFix    = " Create new Parameter and change to it in the 'Store to' dropdown under the above path";
                    AA.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                    AA.IssueType   = eType.Error;
                    AA.Impact      = GingerDicser.GetTermResValue(eTermResKey.Activity) + " will fail due to missing Parameter";
                    AA.Severity    = eSeverity.High;

                    IssuesList.Add(AA);
                }
            }
            // Put All Special Actions Analyze Here
            //actions combination
            if (a.GetType() == typeof(ActLaunchJavaWSApplication))//forbidden combination: Launch & (platform\agent manipulation action)
            {
                List <IAct> driverActs = parentActivity.Acts.Where(x => ((x is ActWithoutDriver && x.GetType() != typeof(ActAgentManipulation)) == false) && x.Active == true).ToList();
                if (driverActs.Count > 0)
                {
                    string        list = string.Join(",", driverActs.Select(x => x.ActionDescription).ToList().ToArray());
                    AnalyzeAction AA   = CreateNewIssue(BusinessFlow, parentActivity, a);
                    AA.Description = GingerDicser.GetTermResValue(eTermResKey.Activity) + " has forbidden combinations";
                    AA.Details     = GingerDicser.GetTermResValue(eTermResKey.Activity) + " has " + a.ActionDescription + " Action with the following platform actions: " + list + ".\nPlatform action inside this current " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " will try to activate the agent before the application is launch(will cause agent issue).";
                    AA.HowToFix    = "Open the " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " and put " + a.ActionDescription + " Action in a separate " + GingerDicser.GetTermResValue(eTermResKey.Activity);
                    AA.CanAutoFix  = AnalyzerItemBase.eCanFix.No;   // we can autofix by delete, but don't want to
                    AA.IssueType   = eType.Error;
                    AA.Impact      = GingerDicser.GetTermResValue(eTermResKey.Activity) + " will be executed and will fail due to java agent connection";
                    AA.Severity    = eSeverity.High;

                    IssuesList.Add(AA);
                }
            }

            if (a.LocateBy == eLocateBy.POMElement || ((a is ActUIElement) && ((ActUIElement)a).ElementLocateBy == eLocateBy.POMElement))
            {
                try
                {
                    string[]            pOMandElementGUIDs = ((ActUIElement)a).ElementLocateValue.Split('_');
                    Guid                selectedPOMGUID    = new Guid(pOMandElementGUIDs[0]);
                    ApplicationPOMModel POM = WorkSpace.Instance.SolutionRepository.GetRepositoryItemByGuid <ApplicationPOMModel>(selectedPOMGUID);
                    if (POM == null)
                    {
                        AnalyzeAction AA = CreateNewIssue(BusinessFlow, parentActivity, a);
                        AA.Description = "Action's mapped Page Objects Model is missing";
                        AA.Details     = "Action " + a.ActionDescription + " has mapped Page Objects Model which is missing, reason can be that the Page Objects Model has been deleted after mapping it to this action.";
                        AA.HowToFix    = "Open the " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " and the Action in order to map different Page Objects Model and Element";
                        AA.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                        AA.IssueType   = eType.Error;
                        AA.Impact      = "Action will fail during execution";
                        AA.Severity    = eSeverity.High;

                        IssuesList.Add(AA);
                    }
                    else
                    {
                        Guid        selectedPOMElementGUID = new Guid(pOMandElementGUIDs[1]);
                        ElementInfo selectedPOMElement     = (ElementInfo)POM.MappedUIElements.Where(z => z.Guid == selectedPOMElementGUID).FirstOrDefault();
                        if (selectedPOMElement == null)
                        {
                            AnalyzeAction AA = CreateNewIssue(BusinessFlow, parentActivity, a);
                            AA.Description = "Page Objects Model Element which mapped to this action is missing";
                            AA.Details     = "Action " + a.ActionDescription + " has mapped Page Objects Model Element which is missing, reason can be that the Element has been deleted after mapping it to this action.";
                            AA.HowToFix    = "Open the " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " and the Action in order to map different Element";
                            AA.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                            AA.IssueType   = eType.Error;
                            AA.Impact      = "Action will fail during execution";
                            AA.Severity    = eSeverity.High;

                            IssuesList.Add(AA);
                        }
                    }
                }
                catch (Exception ex)
                {
                    AnalyzeAction AA = CreateNewIssue(BusinessFlow, parentActivity, a);
                    AA.Description = "Action's mapped Page Objects Model or Element is invalid";
                    AA.Details     = "Action " + a.ActionDescription + " has invalid mapped Page Objects Model or Element.";
                    AA.HowToFix    = "Open the " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " " + GingerDicser.GetTermResValue(eTermResKey.Activity) + " and the Action in order to map different Page Objects Model and Element";
                    AA.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                    AA.IssueType   = eType.Error;
                    AA.Impact      = "Action will fail during execution";
                    AA.Severity    = eSeverity.High;

                    IssuesList.Add(AA);
                }
            }
            return(IssuesList);
        }
Пример #2
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);
        }