Exemple #1
0
        public void MongoDbUpdateDB()
        {
            ActDBValidation actDB = new ActDBValidation();

            actDB.DBValidationType = ActDBValidation.eDBValidationType.UpdateDB;

            actDB.AppName = "DB";
            actDB.DBName  = "MongoDb";
            actDB.SQL     = "db.inventory.updateOne({ item: \"paper\" },{$set: { \"size.uom\": \"cm\", status: \"P\" }})";

            mBF.CurrentActivity.Acts.Add(actDB);
            mBF.CurrentActivity.Acts.CurrentItem = actDB;

            ProjEnvironment projEnvironment = new ProjEnvironment();

            projEnvironment.Name = "MongoDbApp";

            EnvApplication envApplication = new EnvApplication();

            envApplication.Name = "DB";

            Database db = new Database();

            db.Name             = "MongoDb";
            db.DBType           = Database.eDBTypes.MongoDb;
            db.ConnectionString = ConfigurationManager.AppSettings["MongoDbConnectionString"];

            envApplication.Dbs.Add(db);
            projEnvironment.Applications.Add(envApplication);
            mGR.ProjEnvironment = projEnvironment;

            mGR.RunAction(actDB, false);

            Assert.AreEqual(eRunStatus.Passed, actDB.Status, "Action Status");
        }
Exemple #2
0
        public void MongoDbRecordCount()
        {
            ActDBValidation actDB = new ActDBValidation();

            actDB.DBValidationType = ActDBValidation.eDBValidationType.RecordCount;

            actDB.AppName = "DB";
            actDB.DBName  = "MongoDb";
            actDB.SQL     = "products";

            mBF.CurrentActivity.Acts.Add(actDB);
            mBF.CurrentActivity.Acts.CurrentItem = actDB;

            ProjEnvironment projEnvironment = new ProjEnvironment();

            projEnvironment.Name = "MongoDbApp";

            EnvApplication envApplication = new EnvApplication();

            envApplication.Name = "DB";

            Database db = new Database();

            db.Name             = "MongoDb";
            db.DBType           = Database.eDBTypes.MongoDb;
            db.ConnectionString = ConfigurationManager.AppSettings["MongoDbConnectionString"];

            envApplication.Dbs.Add(db);
            projEnvironment.Applications.Add(envApplication);
            mGR.ProjEnvironment = projEnvironment;

            mGR.RunAction(actDB, false);

            Assert.AreEqual(eRunStatus.Passed, actDB.Status, "Action Status");
        }
Exemple #3
0
        public ValidationDBPage(ActDBValidation validationDB)
        {
            InitializeComponent();

            this.mValidationDB = validationDB;

            if (String.IsNullOrEmpty(mValidationDB.GetInputParamValue("SQL")))
            {
                mValidationDB.AddOrUpdateInputParamValue("SQL", mValidationDB.GetInputParamValue("Value"));
            }

            FillAppComboBox();

            //New UI Controls:
            //Query Type selection radio button :
            QueryTypeRadioButton.Init(typeof(ActDBValidation.eQueryType), SqlSelection, mValidationDB.GetOrCreateInputParam(ActDBValidation.Fields.QueryTypeRadioButton, ActDBValidation.eQueryType.FreeSQL.ToString()), QueryType_SelectionChanged);
            checkQueryType();

            //Free SQL
            //needs to be unmarked when fixed VE issue
            SQLUCValueExpression.Init(mValidationDB.GetOrCreateInputParam(ActDBValidation.Fields.SQL));

            //Read from sql file
            QueryFile.Init(mValidationDB.GetOrCreateInputParam(ActDBValidation.Fields.QueryFile), true, true, UCValueExpression.eBrowserType.File, "sql", BrowseQueryFile_Click);

            QueryFile.ValueTextBox.TextChanged += ValueTextBox_TextChanged;

            //Import SQL file in to solution folder
            GingerCore.General.ActInputValueBinding(ImportFile, CheckBox.IsCheckedProperty, mValidationDB.GetOrCreateInputParam(ActDBValidation.Fields.ImportFile, "True"));

            //OLD binding and UI
            App.FillComboFromEnumVal(ValidationCfgComboBox, validationDB.DBValidationType);

            //TODO: fix hard coded
            App.ObjFieldBinding(ValidationCfgComboBox, ComboBox.SelectedValueProperty, validationDB, "DBValidationType");

            App.ObjFieldBinding(AppNameComboBox, ComboBox.TextProperty, validationDB, ActDBValidation.Fields.AppName);
            App.ObjFieldBinding(DBNameComboBox, ComboBox.TextProperty, validationDB, ActDBValidation.Fields.DBName);
            App.ObjFieldBinding(TablesComboBox, ComboBox.TextProperty, validationDB, ActDBValidation.Fields.Table);
            App.ObjFieldBinding(KeySpaceComboBox, ComboBox.TextProperty, validationDB, ActDBValidation.Fields.Keyspace);
            App.ObjFieldBinding(ColumnComboBox, ComboBox.TextProperty, validationDB, ActDBValidation.Fields.Column);
            App.ObjFieldBinding(txtWhere, TextBox.TextProperty, validationDB, ActDBValidation.Fields.Where);
            GingerCore.General.ActInputValueBinding(CommitDB, CheckBox.IsCheckedProperty, mValidationDB.GetOrCreateInputParam(ActDBValidation.Fields.CommitDB));

            KeySpaceComboBox.Items.Add(mValidationDB.Keyspace);
            ComboAutoSelectIfOneItemOnly(KeySpaceComboBox);
            TablesComboBox.Items.Add(mValidationDB.Table);
            ComboAutoSelectIfOneItemOnly(TablesComboBox);
            ColumnComboBox.Items.Add(mValidationDB.Column);
            ComboAutoSelectIfOneItemOnly(ColumnComboBox);
            SetVisibleControlsForAction();
            SetQueryParamsGrid();
        }
Exemple #4
0
        public async Task UpdateDatabaseNameChange(Database db)
        {
            if (db == null)
            {
                return;
            }
            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                await Task.Run(() =>
                {
                    Reporter.ToStatus(eStatusMsgKey.RenameItem, null, db.NameBeforeEdit, db.Name);
                    ObservableList <BusinessFlow> allBF = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <BusinessFlow>();
                    Parallel.ForEach(allBF, new ParallelOptions {
                        MaxDegreeOfParallelism = 5
                    }, businessFlow =>
                    {
                        Parallel.ForEach(businessFlow.Activities, new ParallelOptions {
                            MaxDegreeOfParallelism = 5
                        }, activity =>
                        {
                            Parallel.ForEach(activity.Acts, new ParallelOptions {
                                MaxDegreeOfParallelism = 5
                            }, act =>
                            {
                                if (act.GetType() == typeof(ActDBValidation))
                                {
                                    ActDBValidation actDB = (ActDBValidation)act;
                                    if (actDB.DBName == db.NameBeforeEdit)
                                    {
                                        businessFlow.DirtyStatus = eDirtyStatus.Modified;
                                        actDB.DBName             = db.Name;
                                    }
                                }
                            });
                        });
                    });
                });

                db.NameBeforeEdit = db.Name;
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.DEBUG, "Error occurred while renaming DBName", ex);
            }
            finally
            {
                Reporter.HideStatusMessage();
                Mouse.OverrideCursor = null;
            }
        }
Exemple #5
0
        public ValidationDBPage(ActDBValidation act)
        {
            InitializeComponent();

            this.mAct = act;

            if (String.IsNullOrEmpty(mAct.GetInputParamValue("SQL")))
            {
                mAct.AddOrUpdateInputParamValue("SQL", mAct.GetInputParamValue("Value"));
            }

            FillAppComboBox();

            //New UI Controls:
            //Query Type selection radio button :
            QueryTypeRadioButton.Init(typeof(ActDBValidation.eQueryType), SqlSelection, mAct.GetOrCreateInputParam(ActDBValidation.Fields.QueryTypeRadioButton, ActDBValidation.eQueryType.FreeSQL.ToString()), QueryType_SelectionChanged);
            checkQueryType();

            //Free SQL
            //needs to be unmarked when fixed VE issue
            SQLUCValueExpression.Init(Context.GetAsContext(mAct.Context), mAct.GetOrCreateInputParam(ActDBValidation.Fields.SQL));

            //Read from sql file
            QueryFile.Init(Context.GetAsContext(mAct.Context), mAct.GetOrCreateInputParam(ActDBValidation.Fields.QueryFile), true, true, UCValueExpression.eBrowserType.File, "sql", BrowseQueryFile_Click, WorkSpace.Instance.SolutionRepository.SolutionFolder);

            QueryFile.ValueTextBox.TextChanged += ValueTextBox_TextChanged;

            //OLD binding and UI
            GingerCore.General.FillComboFromEnumObj(ValidationCfgComboBox, act.DBValidationType);

            //TODO: fix hard coded
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(ValidationCfgComboBox, ComboBox.SelectedValueProperty, act, "DBValidationType");

            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(AppNameComboBox, ComboBox.TextProperty, act, ActDBValidation.Fields.AppName);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(DBNameComboBox, ComboBox.TextProperty, act, ActDBValidation.Fields.DBName);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(TablesComboBox, ComboBox.TextProperty, act, ActDBValidation.Fields.Table);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(KeySpaceComboBox, ComboBox.TextProperty, act, ActDBValidation.Fields.Keyspace);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(ColumnComboBox, ComboBox.TextProperty, act, ActDBValidation.Fields.Column);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(txtWhere, TextBox.TextProperty, act, ActDBValidation.Fields.Where);
            GingerCore.GeneralLib.BindingHandler.ActInputValueBinding(CommitDB, CheckBox.IsCheckedProperty, mAct.GetOrCreateInputParam(ActDBValidation.Fields.CommitDB));

            KeySpaceComboBox.Items.Add(mAct.Keyspace);
            ComboAutoSelectIfOneItemOnly(KeySpaceComboBox);
            TablesComboBox.Items.Add(mAct.Table);
            ComboAutoSelectIfOneItemOnly(TablesComboBox);
            ColumnComboBox.Items.Add(mAct.Column);
            ComboAutoSelectIfOneItemOnly(ColumnComboBox);
            SetVisibleControlsForAction();
            SetQueryParamsGrid();
        }
Exemple #6
0
        public void RenameDBName()
        {
            //Arrange
            ProjEnvironment projEnvironment = new ProjEnvironment();

            projEnvironment.Name = "MongoDbApp";

            EnvApplication envApplication = new EnvApplication();

            envApplication.Name = "DB";

            Database           db = new Database();
            DatabaseOperations databaseOperations = new DatabaseOperations(db);

            db.DatabaseOperations = databaseOperations;
            db.Name   = "MongoDb";
            db.DBType = Database.eDBTypes.MongoDb;

            envApplication.Dbs.Add(db);
            projEnvironment.Applications.Add(envApplication);
            mGR.ProjEnvironment = projEnvironment;

            ActDBValidation actDB = new ActDBValidation();

            actDB.DBValidationType = ActDBValidation.eDBValidationType.UpdateDB;

            actDB.AppName = "DB";
            actDB.DBName  = "MongoDb";

            mBF.CurrentActivity.Acts.Add(actDB);
            mBF.CurrentActivity.Acts.CurrentItem = actDB;

            //Act
            ((DatabaseOperations)db.DatabaseOperations).NameBeforeEdit = actDB.DBName;
            db.Name = "MongoDBNew";
            //Database.UpdateDatabaseNameChangeInItem(actDB, db.NameBeforeEdit, db.Name);

            //Assert
            Assert.AreEqual(actDB.DBName, db.Name, "Names");
        }
Exemple #7
0
 public GingerCouchbase(ActDBValidation.eDBValidationType DBValidationtype, Environments.Database mDB, ActDBValidation mact)
 {
     Action  = DBValidationtype;
     this.Db = mDB;
     Act     = mact;
 }
Exemple #8
0
        private void ProcessActions(ConvertedCodeLine CCL)
        {
            string CodeLine         = CCL.CodeLine;
            string value            = "";
            string SetValueinObject = "";
            string varName          = "";
            string xpath            = "";
            string type             = "";

            if (CodeLine.Contains("WebEdit"))
            {
                if (CodeLine.Contains("WebEditTxtChange"))
                {
                    type             = "Edit Box";
                    SetValueinObject = GetStringBetween(CodeLine, ".WebEdit(\"", "\")");

                    varName = CodeLine.Substring(CodeLine.IndexOf("GlobalDictionary")).Replace("GlobalDictionary", "").Trim();
                    varName = varName.Replace("(", "").Replace(")", "");
                    value   = "{Var Name=" + varName + "}";

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }

                // Add Action to biz flow
                ActGenElement act = new ActGenElement();
                act.Value            = value.Replace("\"", "").Replace("\"", "");
                act.GenElementAction = ActGenElement.eGenElementAction.SetValue;
                act.LocateBy         = eLocateBy.ByXPath;
                act.LocateValue      = xpath;
                act.Description      = "Set value in " + SetValueinObject + " " + type;
                mBusinessFlow.AddAct(act);
                CCL.Converted = "New Action - ActGenElement.SetValue : LocateValue=" + act.LocateValue + ", Value=" + act.Value;
                CCL.Status    = ConvertedCodeLine.eStatus.ConvertedToScript;
            }

            // Extract the WebEdit/WebCheckBox
            else if (CodeLine.Contains(".Set") || CodeLine.Contains(".set"))
            {
                if (CodeLine.Contains("WebEdit"))
                {
                    type             = "Edit Box";
                    SetValueinObject = GetStringBetween(CodeLine, ".WebEdit(\"", "\")");

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }
                else if (CodeLine.Contains("WebCheckBox"))
                {
                    type             = "Check Box";
                    SetValueinObject = GetStringBetween(CodeLine, ".WebCheckBox(\"", "\")");

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }

                // for Values to Set
                if (CodeLine.Contains("Set \""))  // For hard coded values
                {
                    value = GetStringBetween(CodeLine, "Set \"", CodeLine[CodeLine.Length - 1].ToString());
                }
                else if (CodeLine.Contains("GlobalDictionary"))
                {
                    varName = CodeLine.Substring(CodeLine.IndexOf("GlobalDictionary")).Replace("GlobalDictionary", "").Trim();
                    varName = varName.Replace("(", "").Replace(")", "");
                    value   = "{Var Name=" + varName + "}";
                }
                else if (CodeLine.Contains("Globaldictionary"))
                {
                    varName = CodeLine.Substring(CodeLine.IndexOf("Globaldictionary")).Replace("Globaldictionary", "").Trim();
                    varName = varName.Replace("(", "").Replace(")", "");
                    value   = "{Var Name=" + varName + "}";
                }
                else if (!CodeLine.Contains("GlobalDictionary") && !CodeLine.Contains("Globaldictionary"))  // for variables declared using Dim
                {
                    varName = CodeLine.Substring(CodeLine.IndexOf("Set")).Replace("Set", "").Trim();
                    value   = "{Var Name=" + varName + "}";
                    VariableString v = new VariableString();
                    v.Description = GingerDicser.GetTermResValue(eTermResKey.Variable) + " added by UFT Script";
                    v.Name        = varName;
                    v.Value       = value;
                    mBusinessFlow.AddVariable(v);
                }

                // Add Action to biz flow
                ActGenElement act = new ActGenElement();
                act.Value            = value.Replace("\"", "").Replace("\"", "");
                act.GenElementAction = ActGenElement.eGenElementAction.SetValue;
                act.LocateBy         = eLocateBy.ByXPath;
                act.LocateValue      = xpath;
                act.Description      = "Set value in " + SetValueinObject + " " + type;
                mBusinessFlow.AddAct(act);
                CCL.Converted = "New Action - ActGenElement.SetValue : LocateValue=" + act.LocateValue + ", Value=" + act.Value;
                CCL.Status    = ConvertedCodeLine.eStatus.ConvertedToScript;
            }

            // Extract the WebButton/Link/Image/WebELemnt
            else if (CodeLine.Contains(".Click") || CodeLine.Contains(".click"))
            {
                if (CodeLine.Contains("WebButton"))
                {
                    type             = "Button";
                    SetValueinObject = GetStringBetween(CodeLine, ".WebButton(\"", "\")");

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }
                else if (CodeLine.Contains("Link"))
                {
                    type             = "Link";
                    SetValueinObject = GetStringBetween(CodeLine, ".Link(\"", "\")");

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }
                else if (CodeLine.Contains("WebElement"))
                {
                    type             = "Web Element";
                    SetValueinObject = GetStringBetween(CodeLine, ".WebElement(\"", "\")");

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }
                else if (CodeLine.Contains("Image"))
                {
                    type             = "Image";
                    SetValueinObject = GetStringBetween(CodeLine, ".Image(\"", "\")");

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }

                // Add Action to biz flow
                ActGenElement act = new ActGenElement();
                act.Value            = "";
                act.LocateBy         = eLocateBy.ByXPath;
                act.LocateValue      = xpath;
                act.GenElementAction = ActGenElement.eGenElementAction.Click;
                act.Description      = "Click on " + SetValueinObject + " " + type;
                mBusinessFlow.AddAct(act);

                CCL.Converted = "New Action - ActGenElement.Click : LocateValue=" + act.LocateValue; // +", Value=" + act.Value;
                CCL.Status    = ConvertedCodeLine.eStatus.ConvertedToScript;
            }

            // Extract the WeBlist/WebRadiogroup
            else if (CodeLine.Contains(".Select") || CodeLine.Contains(".select"))
            {
                if (CodeLine.Contains("WebList"))
                {
                    type             = "List";
                    SetValueinObject = GetStringBetween(CodeLine, ".WebList(\"", "\")");

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }
                else if (CodeLine.Contains("WebRadiogroup"))
                {
                    type             = "Radio Group";
                    SetValueinObject = GetStringBetween(CodeLine, ".WebRadiogroup(\"", "\")");

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }

                //For Values to Set
                if (CodeLine.Contains("Select \""))  // For hard coded values
                {
                    value = GetStringBetween(CodeLine, "Select \"", CodeLine[CodeLine.Length - 1].ToString());
                }
                else if (CodeLine.Contains("GlobalDictionary"))
                {
                    varName = CodeLine.Substring(CodeLine.IndexOf("GlobalDictionary")).Replace("GlobalDictionary", "").Trim();
                    varName = varName.Replace("(", "").Replace(")", "");
                    value   = "{Var Name=" + varName + "}";
                }
                else if (CodeLine.Contains("Globaldictionary"))
                {
                    varName = CodeLine.Substring(CodeLine.IndexOf("Globaldictionary")).Replace("Globaldictionary", "").Trim();
                    varName = varName.Replace("(", "").Replace(")", "");
                    value   = "{Var Name=" + varName + "}";
                }
                else
                {
                    varName = CodeLine.Substring(CodeLine.IndexOf("Select ")).Replace("Select ", "").Trim();
                    value   = "{Var Name=" + varName + "}";
                    VariableString v = new VariableString();
                    v.Description = GingerDicser.GetTermResValue(eTermResKey.Variable) + " added by UFT Script";
                    v.Name        = varName;
                    v.Value       = value;
                    mBusinessFlow.AddVariable(v);
                }

                // Add Action to biz flow
                ActGenElement act = new ActGenElement();
                act.Value            = value;
                act.LocateBy         = eLocateBy.ByXPath;
                act.LocateValue      = xpath;
                act.GenElementAction = ActGenElement.eGenElementAction.SetValue;
                act.Description      = "Select value from " + SetValueinObject + " " + type;
                mBusinessFlow.AddAct(act);
                CCL.Converted = "New Action - ActGenElement.SetValue : LocateValue=" + act.LocateValue + ", Value=" + act.Value;
                CCL.Status    = ConvertedCodeLine.eStatus.ConvertedToScript;
            }

            // Extract the URL to Navigate to
            else if (CodeLine.Contains("Navigate"))
            {
                // Extract the URL
                string URL = GetStringBetween(CodeLine, ".Navigate(\"", "\")");

                // Add Action to biz flow
                ActGotoURL act = new ActGotoURL();
                act.Value       = URL;
                act.Description = "Navigate to URL";
                mBusinessFlow.AddAct(act);
                CCL.Converted = "New Action - ActGotoURL : " + URL;
                CCL.Status    = ConvertedCodeLine.eStatus.ConvertedToScript;
            }

            // Extract the URL launched using SystemUtil.Run
            else if (CodeLine.Contains("SystemUtil.Run") && CodeLine.Contains("iexplore.exe"))
            {
                // Extract the URL
                string URL = GetStringBetween(CodeLine, "iexplore.exe\",\"", "\"");

                // Add Action to biz flow
                ActGotoURL act = new ActGotoURL();
                act.Value       = URL;
                act.Description = "Navigate to URL";
                mBusinessFlow.AddAct(act);
                CCL.Converted = "New Action - ActGotoURL : " + URL;
                CCL.Status    = ConvertedCodeLine.eStatus.ConvertedToScript;
            }
            else if (CodeLine.Contains("fDBCheck") || CodeLine.Contains("fDBActivities")) //ASAP function
            {
                // Temp until we read the SQL from common.xls
                ActDBValidation act = new ActDBValidation();
                act.Description = "DB Action-Configure Manually";
                mBusinessFlow.AddAct(act);
                CCL.Converted = "New Action - DB Action ";
                CCL.Status    = ConvertedCodeLine.eStatus.ConvertedToScript;
            }
        }