Example #1
0
        public virtual IScriptGenerationParams Clone()
        {
            IScriptGenerationParams re;

            if (this is RanorexValidationUCScriptGenerationParams)
            {
                re = new RanorexValidationUCScriptGenerationParams();
                ((RanorexValidationUCScriptGenerationParams)re).CopyAttributesFrom(this as RanorexValidationUCScriptGenerationParams);
            }
            else if (this is RanorexWaitValidateScriptGenerationParams)
            {
                re = new RanorexWaitValidateScriptGenerationParams();
                ((RanorexWaitValidateScriptGenerationParams)re).CopyAttributesFrom(this as RanorexWaitValidateScriptGenerationParams);
            }
            else if (this is RanorexUCScriptGenerationParams)
            {
                re = new RanorexUCScriptGenerationParams();
                ((RanorexUCScriptGenerationParams)re).CopyAttributesFrom(this as RanorexUCScriptGenerationParams);
            }
            else if (this is RanorexScriptGenerationParams)
            {
                re = new RanorexScriptGenerationParams();
                ((RanorexUCScriptGenerationParams)re).CopyAttributesFrom(this as RanorexUCScriptGenerationParams);
            }
            else if (this is ValidationUCScriptGenerationParams)
            {
                re = new ValidationUCScriptGenerationParams();
                ((ValidationUCScriptGenerationParams)re).CopyAttributesFrom(this as ValidationUCScriptGenerationParams);
            }
            else if (this is WaitValidateScriptGenerationParams)
            {
                re = new WaitValidateScriptGenerationParams();
                ((WaitValidateScriptGenerationParams)re).CopyAttributesFrom(this as WaitValidateScriptGenerationParams);
            }
            else if (this is UserCodeScriptGenerationParams)
            {
                re = new UserCodeScriptGenerationParams();
                ((UserCodeScriptGenerationParams)re).CopyAttributesFrom(this as UserCodeScriptGenerationParams);
            }
            else
            {
                re = new ScriptGenerationParams();
                ((ScriptGenerationParams)re).CopyAttributesFrom(this as ScriptGenerationParams);
            }
            CopyAttributes(re, this);
            return(re);
        }
 public RanorexScriptGenerationParams(ScriptGenerationParams p) : this()
 {
     CopyAttributes(this, p);
 }
 private void DoExpand(SpecScreen screen, string pathToApp, MyLog myLog, List <ClassExpression> allClassesExp)
 {
     for (int fi = 0; fi < screen.Scenarios.Count; fi++)
     {
         IScenario tempScenario = screen.Scenarios[fi];
         if (tempScenario is SpecScenario)
         {
             SpecScenario  scenario      = tempScenario as SpecScenario;
             List <string> listActionExp = scenario.UserActionsInString;
             List <Color>  colors        = scenario.Colors;
             for (int se = 0; se < listActionExp.Count; se++)
             {
                 string actionExp = listActionExp[se];
                 if (actionExp == null)
                 {
                     myLog.Error("NULL at (" + (fi + 1) + "," + (se + 2) + ")");
                     continue;
                 }
                 SpecNode specNode = screen.ListSpecNodes[se];
                 ScriptGenerationParams _params        = null;
                 AbstractSpecUserAction specUserAction = null;
                 int lastInd = IsValidationUserCode(se, screen.ListValidationUserCode);
                 if (lastInd > se)
                 {
                     specUserAction = new ValidationUserCodeSpecUserAction();
                     _params        = new ValidationUCScriptGenerationParams();
                     List <string> listExp = new List <string>();
                     for (int th = se; th <= lastInd; th++)
                     {
                         String tempActionExp        = listActionExp[th];
                         AbstractSpecUserAction temp = handleUserActionExpression(
                             tempActionExp.Trim(), specNode, colors[th], myLog);
                         if (!(temp is ValidationSpecUserAction))
                         {
                             myLog.Warn("Expression: " + tempActionExp + " must be validation", logger);
                             screen = null;
                             return;
                         }
                         else
                         {
                             if (tempActionExp != null && !tempActionExp.Trim().Equals(""))
                             {
                                 listExp.Add(tempActionExp.Trim());
                             }
                         }
                     }
                     (specUserAction as ValidationUserCodeSpecUserAction).ListExps = listExp;
                     ((ValidationUCScriptGenerationParams)_params).ListExps        = listExp;
                     if (screen is TestSpecificationScreen)
                     {
                         ((ValidationUCScriptGenerationParams)_params).ClassExpressions = allClassesExp;
                     }
                     ((ValidationUCScriptGenerationParams)_params).ClassName =
                         AbstractSpecUserAction.GetFolderNameFromScreen(screen) + "_Validation";
                     ((ValidationUCScriptGenerationParams)_params).FunctionName = "Validate_" +
                                                                                  Regex.Replace(specNode.Expression, "[^A-Za-z0-9]", "_");
                     SetAttributes(scenario, specUserAction, specNode,
                                   screen, pathToApp, colors, _params, se, myLog);
                     se = lastInd;
                 }
                 else
                 {
                     string[] listActionsEpx = splitAction(actionExp, AbstractSpecUserAction.AND);
                     foreach (string action in listActionsEpx)
                     {
                         specUserAction = handleUserActionExpression(action.Trim(), specNode, colors[se], myLog);
                         if (specUserAction != null)
                         {
                             if (specUserAction is UserCodeSpecUserAction userCodeExpression)
                             {
                                 _params = new UserCodeScriptGenerationParams();
                                 ((UserCodeScriptGenerationParams)_params).MapAliasWithNode = screen.MappingAliasWithNode;
                                 if (screen is TestSpecificationScreen testSpecScreen)
                                 {
                                     ((UserCodeScriptGenerationParams)_params).ClassExpressions = allClassesExp;
                                 }
                             }
                             else if (specUserAction is WaitValidateSpecUserAction waitUserAction)
                             {
                                 _params = new WaitValidateScriptGenerationParams();
                             }
                             else
                             {
                                 _params = new ScriptGenerationParams();
                             }
                             SetAttributes(scenario, specUserAction, specNode,
                                           screen, pathToApp, colors, _params, se, myLog);
                         }
                     }
                 }
             }
         }
     }
 }
Example #4
0
 public void CopyAttributesFrom(ScriptGenerationParams source)
 {
     CopyAttributes(this, source);
 }
 private void SetAttributes(SpecScenario scenario, AbstractSpecUserAction specUserAction, SpecNode specNode,
                            IScreen screen, string pathToApp, List <Color> colors, ScriptGenerationParams _params, int se, MyLog myLog)
 {
     // importance: must create on the same thread with UI thread
     try
     {
         Application.Current.Dispatcher.Invoke((Action) delegate
         {
             specUserAction.BgColor = new System.Windows.Media.SolidColorBrush(
                 System.Windows.Media.Color.FromArgb(
                     255, colors[se].R, colors[se].G, colors[se].B));
         });
     }
     catch (Exception)
     {
         specUserAction.BgColor = new System.Windows.Media.SolidColorBrush(
             System.Windows.Media.Color.FromArgb(
                 255, colors[se].R, colors[se].G, colors[se].B));
     }
     _params.Color             = colors[se];
     _params.Id                = scenario.Id;
     _params.ListUIElements    = screen.AllUIElements;
     _params.MyLog             = myLog;
     _params.ScreenName        = screen.Name;
     _params.SpecNode          = specNode;
     _params.PathToApp         = pathToApp;
     specUserAction.Params     = _params;
     specUserAction.NodeAffect = specNode;
     if (scenario.UserActions == null)
     {
         scenario.UserActions = new List <IUserAction>();
     }
     scenario.UserActions.Add(specUserAction);
 }