public void DeleteBfsSubFolderWithAllItemsLoaded()
        {
            //Arrange
            ObservableList <MyRepositoryItem> MRIs = mSolutionRepository.GetAllRepositoryItems <MyRepositoryItem>();
            //add new sub folder with new bf's to be deleted
            RepositoryFolder <MyRepositoryItem> MRIRF          = mSolutionRepository.GetRepositoryItemRootFolder <MyRepositoryItem>();
            RepositoryFolder <MyRepositoryItem> folderToDelete = (RepositoryFolder <MyRepositoryItem>)MRIRF.AddSubFolder("DeleteSubFolder_FolderForDelete");
            MyRepositoryItem MRI1 = new MyRepositoryItem("DeleteSubFolder_MRI1");

            folderToDelete.AddRepositoryItem(MRI1);
            MyRepositoryItem MRI2 = new MyRepositoryItem("DeleteSubFolder_MRI2");

            folderToDelete.AddRepositoryItem(MRI2);
            //add new sub-sub folder with new MRI's to be deleted
            RepositoryFolder <MyRepositoryItem> subfolderToDelete = (RepositoryFolder <MyRepositoryItem>)folderToDelete.AddSubFolder("DeleteSubFolder_subfolderToDelete");
            MyRepositoryItem MRI3 = new MyRepositoryItem("DeleteSubFolder_MRI3");

            subfolderToDelete.AddRepositoryItem(MRI3);

            //Act
            mSolutionRepository.DeleteRepositoryItemFolder(folderToDelete);

            //Assert
            Assert.IsTrue(Directory.Exists(folderToDelete.FolderFullPath) == false);
            Assert.AreEqual((mSolutionRepository.GetRepositoryItemByGuid <MyRepositoryItem>(MRI1.Guid)), null, "make sure all deleted folder items were removed from cache");
            Assert.AreEqual((mSolutionRepository.GetRepositoryItemByGuid <MyRepositoryItem>(MRI3.Guid)), null, "make sure all deleted folder sub folder items were removed from cache");
        }
Beispiel #2
0
        private static void CreateTestSolution()
        {
            // First we create a basic solution with some sample items
            SolutionRepository SR = new SolutionRepository();

            //string TempRepositoryFolder = TestResources.getGingerUnitTesterTempFolder(@"Solutions\SRTestTemp");
            if (Directory.Exists(TempRepositoryFolder))
            {
                Directory.Delete(TempRepositoryFolder, true);
            }

            // Define the items types we want in our Repository
            SR.AddItemInfo <MyRepositoryItem>("*.Ginger.MyRepositoryItem.xml", @"~\MyRepositoryItems", true, "My Repository Item", PropertyNameForFileName: nameof(MyRepositoryItem.Name));


            SR.CreateRepository(TempRepositoryFolder);
            SR.Open(TempRepositoryFolder);

            MyRepositoryItem A1 = new MyRepositoryItem("A1");

            SR.AddRepositoryItem(A1);

            MyRepositoryItem A2 = new MyRepositoryItem("A2");

            SR.AddRepositoryItem(A2);

            MyRepositoryItem A3 = new MyRepositoryItem("A3");

            SR.AddRepositoryItem(A3);


            RepositoryFolder <MyRepositoryItem> MyRepoRF   = SR.GetRepositoryItemRootFolder <MyRepositoryItem>();
            RepositoryFolder <MyRepositoryItem> SubFolder1 = (RepositoryFolder <MyRepositoryItem>)MyRepoRF.AddSubFolder("SubFolder1");

            MyRepoRF.AddSubFolder("EmptySubFolder");

            MyRepositoryItem A4 = new MyRepositoryItem("A4");

            SubFolder1.AddRepositoryItem(A4);

            // Folder to delete later
            MyRepoRF.AddSubFolder("SubFolderForDelete");

            // Create folders tree
            RepositoryFolder <MyRepositoryItem> SF1 = (RepositoryFolder <MyRepositoryItem>)MyRepoRF.AddSubFolder("SF1");
            RepositoryFolder <MyRepositoryItem> SF2 = (RepositoryFolder <MyRepositoryItem>)SF1.AddSubFolder("SF1_SF2");
            RepositoryFolder <MyRepositoryItem> SF3 = (RepositoryFolder <MyRepositoryItem>)SF2.AddSubFolder("SF1_SF2_SF3");
            MyRepositoryItem BF5 = new MyRepositoryItem("A5");

            SubFolder1.AddRepositoryItem(BF5);

            MyRepositoryItem BF6 = new MyRepositoryItem("A6");

            SF3.AddRepositoryItem(BF6);

            //TODO: add more sample items for testing
            SR.Close();
        }
Beispiel #3
0
        public void ApplicationAPIModelMultipleSoapAndRestSaveAndLoad()
        {
            // Arrange
            RepositoryFolder <ApplicationAPIModel> RFRoot    = SR.GetRepositoryItemRootFolder <ApplicationAPIModel>();
            RepositoryFolder <ApplicationAPIModel> subFolder = (RepositoryFolder <ApplicationAPIModel>)RFRoot.AddSubFolder("SecondFolder");

            //Act
            //add items to root folder
            ApplicationAPIModel AAMS1 = new ApplicationAPIModel()
            {
                Name = "Group1_Operation1"
            };

            SR.AddRepositoryItem(AAMS1);
            ApplicationAPIModel AAMS2 = new ApplicationAPIModel()
            {
                Name = "Group1_Operation2"
            };

            SR.AddRepositoryItem(AAMS2);
            ApplicationAPIModel AAMS3 = new ApplicationAPIModel()
            {
                Name = "Group1_Operation3"
            };

            SR.AddRepositoryItem(AAMS3);
            //add items to sub folder items
            ApplicationAPIModel AAMR1 = new ApplicationAPIModel()
            {
                Name = "Group2_Operation1"
            };

            subFolder.AddRepositoryItem(AAMR1);
            ApplicationAPIModel AAMR2 = new ApplicationAPIModel()
            {
                Name = "Group2_Operation2"
            };

            subFolder.AddRepositoryItem(AAMR2);
            ApplicationAPIModel AAMR3 = new ApplicationAPIModel()
            {
                Name = "Group2_Operation3"
            };

            subFolder.AddRepositoryItem(AAMR3);

            ObservableList <ApplicationAPIModel>   AAMBList          = SR.GetAllRepositoryItems <ApplicationAPIModel>();
            RepositoryFolder <ApplicationAPIModel> SecondFolder      = RFRoot.GetSubFolder("SecondFolder");
            ObservableList <ApplicationAPIModel>   AAMBListSubFolder = SecondFolder.GetFolderItems();


            //Assert
            // Assert.AreEqual(AAMBList.Count, 6, "All appllication models including sub folders"); - cannot compare since we run several tests in parallel
            Assert.AreEqual(AAMBListSubFolder.Count, 3, "Second Folder should have 3 files");
        }
Beispiel #4
0
 private void ImportSeleniumScript(object sender, System.Windows.RoutedEventArgs e)
 {
     if (General.SetupBrowseFile(new System.Windows.Forms.OpenFileDialog()
     {
         DefaultExt = ".html",
         Filter = "Recorded Selenium Scripts (*.html)|*.html"
     }, false) is string fileName)
     {
         BusinessFlow BF = SeleniumToGinger.ConvertSeleniumScript(fileName);
         mBusFlowsFolder.AddRepositoryItem(BF);
     }
 }
Beispiel #5
0
        private void ImportSeleniumScript(object sender, System.Windows.RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
            dlg.DefaultExt = ".html";
            dlg.Filter     = "Recorded Selenium Scripts (*.html)|*.html";

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                BusinessFlow BF = SeleniumToGinger.ConvertSeleniumScript(dlg.FileName);
                mBusFlowsFolder.AddRepositoryItem(BF);
            }
        }
Beispiel #6
0
        public static RunSetConfig CreateNewRunset(string runSetName = "", RepositoryFolder <RunSetConfig> runSetsFolder = null)
        {
            if (string.IsNullOrEmpty(runSetName))
            {
                if (!InputBoxWindow.GetInputWithValidation(string.Format("Add New {0}", GingerDicser.GetTermResValue(eTermResKey.RunSet)), string.Format("{0} Name:", GingerDicser.GetTermResValue(eTermResKey.RunSet)), ref runSetName, System.IO.Path.GetInvalidPathChars()))
                {
                    return(null);
                }
            }

            RunSetConfig runSetConfig = new RunSetConfig();

            runSetConfig.Name = runSetName;
            runSetConfig.GingerRunners.Add(new GingerRunner()
            {
                Name = "Runner 1"
            });

            if (runSetsFolder == null)
            {
                WorkSpace.Instance.SolutionRepository.AddRepositoryItem(runSetConfig);
            }
            else
            {
                runSetsFolder.AddRepositoryItem(runSetConfig);
            }

            return(runSetConfig);
        }
Beispiel #7
0
        private void ExportAPIFiles(ObservableList <ApplicationAPIModel> SelectedAAMList)
        {
            foreach (ApplicationAPIModel AAM in SelectedAAMList)
            {
                Dictionary <System.Tuple <string, string>, List <string> > OptionalValuesPerParameterDict = new Dictionary <Tuple <string, string>, List <string> >();

                ImportOptionalValuesForParameters ImportOptionalValues = new ImportOptionalValuesForParameters();
                ImportOptionalValues.GetAllOptionalValuesFromExamplesFiles(AAM, OptionalValuesPerParameterDict);
                ImportOptionalValues.PopulateOptionalValuesForAPIParameters(AAM, OptionalValuesPerParameterDict);

                AAM.ContainingFolder = APIModelFolder.FolderFullPath;
                if (TargetApplicationKey != null)
                {
                    AAM.TargetApplicationKey = TargetApplicationKey;
                }
                if (TagsKeys != null)
                {
                    foreach (RepositoryItemKey tagKey in TagsKeys)
                    {
                        AAM.TagsKeys.Add(tagKey);
                    }
                }
                APIModelFolder.AddRepositoryItem(AAM);
            }
        }
        /// <summary>
        /// This method will convert the Activity Actions
        /// </summary>
        /// <param name="parameterizeRequestBody"></param>
        /// <param name="pullValidations"></param>
        /// <param name="activity"></param>
        /// <param name="ta"></param>
        private int ConvertActivity(bool parameterizeRequestBody, bool pullValidations, Activity activity, RepositoryItemKey ta, RepositoryFolder <ApplicationAPIModel> apiModelFolder)
        {
            int convertionConter = 0;

            for (int actionIndex = 0; actionIndex < activity.Acts.Count; actionIndex++)
            {
                try
                {
                    Act act = (Act)activity.Acts[actionIndex];
                    if (act.Active && (act.GetType() == typeof(ActWebAPIRest) || act.GetType() == typeof(ActWebAPISoap)))
                    {
                        // get the index of the action that is being converted
                        int selectedActIndex = activity.Acts.IndexOf(act);

                        //Create/Update API Model
                        bool isModelExists = true;
                        ApplicationAPIModel applicationModel = GetAPIModelIfExists(act);

                        if (applicationModel == null)
                        {
                            isModelExists    = false;
                            applicationModel = new ApplicationAPIModel();
                            applicationModel.TargetApplicationKey = ta;
                            CreateAPIModelFromWebserviceAction(ref applicationModel, act, pullValidations, parameterizeRequestBody);
                        }

                        //Parse optional values
                        Dictionary <System.Tuple <string, string>, List <string> > optionalValuesPulledFromConvertedAction = new Dictionary <Tuple <string, string>, List <string> >();
                        if (applicationModel.AppModelParameters != null && applicationModel.AppModelParameters.Count > 0)
                        {
                            optionalValuesPulledFromConvertedAction = ParseParametersOptionalValues(applicationModel, (ActWebAPIBase)act);
                        }

                        //Create WebAPIModel action
                        ActWebAPIModel actApiModel = GetNewAPIModelAction(applicationModel, act, optionalValuesPulledFromConvertedAction);

                        activity.Acts.Insert(selectedActIndex + 1, actApiModel);
                        actionIndex++;
                        act.Active = false;
                        if (!isModelExists)
                        {
                            apiModelFolder.AddRepositoryItem(applicationModel);
                        }
                        else
                        {
                            WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(applicationModel);
                        }

                        convertionConter++;
                    }
                }
                catch (Exception ex)
                {
                    Reporter.ToLog(eLogLevel.ERROR, "Error occurred while trying to convert the action", ex);
                }
            }

            return(convertionConter);
        }
Beispiel #9
0
        private void AddBftoSubFolderButton_Click(object sender, RoutedEventArgs e)
        {
            RepositoryFolder <BusinessFlow> root      = mSolutionRepository.GetRepositoryItemRootFolder <BusinessFlow>();
            RepositoryFolder <BusinessFlow> subfolder = root.GetSubFolders()[0];
            BusinessFlow BF = new BusinessFlow("BFSF BF " + DateTime.Now);

            subfolder.AddRepositoryItem(BF);
        }
Beispiel #10
0
        void AddDefaultDataSource()
        {
            byte[] obj = Properties.Resources.GingerDataSource;

            if (!File.Exists(System.IO.Path.Combine(mSolution.Folder, @"DataSources\GingerDataSource.mdb")))
            {
                Directory.CreateDirectory(System.IO.Path.Combine(mSolution.Folder, "DataSources"));
                System.IO.FileStream fs = new System.IO.FileStream(System.IO.Path.Combine(mSolution.Folder, @"DataSources\GingerDataSource.mdb"), System.IO.FileMode.Create, System.IO.FileAccess.Write);
                fs.Write(obj, 0, obj.Count());
                fs.Close();
                fs.Dispose();
            }

            DataSourceBase a = new AccessDataSource();

            a.Name     = "GingerDataSource";
            a.FilePath = @"~\DataSources\GingerDataSource.mdb";
            a.DSType   = DataSourceBase.eDSType.MSAccess;
            RepositoryFolder <DataSourceBase> dsTargetFolder = WorkSpace.Instance.SolutionRepository.GetRepositoryItemRootFolder <DataSourceBase>();

            dsTargetFolder.AddRepositoryItem(a);

            // TODO: Try not to use resources, we can put the file in folder and copy
            // adding LiteDB while adding solution
            byte[] litedbobj = Properties.Resources.LiteDB;

            if (!File.Exists(System.IO.Path.Combine(mSolution.Folder, @"DataSources\LiteDB.db")))
            {
                Directory.CreateDirectory(System.IO.Path.Combine(mSolution.Folder, "DataSources"));
                System.IO.FileStream fs = new System.IO.FileStream(System.IO.Path.Combine(mSolution.Folder, @"DataSources\LiteDB.db"), System.IO.FileMode.Create, System.IO.FileAccess.Write);
                fs.Write(litedbobj, 0, litedbobj.Count());
                fs.Close();
                fs.Dispose();
            }

            DataSourceBase lite = new GingerCoreNET.DataSource.GingerLiteDB();

            lite.Name     = "LiteDB";
            lite.FilePath = @"~\DataSources\LiteDB.db";
            lite.DSType   = DataSourceBase.eDSType.LiteDataBase;

            RepositoryFolder <DataSourceBase> dsTargetFolder1 = WorkSpace.Instance.SolutionRepository.GetRepositoryItemRootFolder <DataSourceBase>();

            dsTargetFolder.AddRepositoryItem(lite);
        }
        public void RenameBfsSubFolder()
        {
            //Arrange
            //add new sub folder with new bf's to be deleted
            RepositoryFolder <MyRepositoryItem> BFRF           = mSolutionRepository.GetRepositoryItemRootFolder <MyRepositoryItem>();
            RepositoryFolder <MyRepositoryItem> folderToRename = (RepositoryFolder <MyRepositoryItem>)BFRF.AddSubFolder("RenameBfsSubFolder_FolderToRename");
            MyRepositoryItem bf1 = new MyRepositoryItem("FolderToRename_bf1");

            folderToRename.AddRepositoryItem(bf1);
            MyRepositoryItem bf2 = new MyRepositoryItem("FolderToRename_bf2");

            folderToRename.AddRepositoryItem(bf2);
            //add new sub-sub folder with new bf's under the folder which will be renamed
            RepositoryFolder <MyRepositoryItem> subfolderUnderRenamedFolder = (RepositoryFolder <MyRepositoryItem>)folderToRename.AddSubFolder("RenameBfsSubFolder_subfolderUnderRenamedFolder");
            MyRepositoryItem bf3 = new MyRepositoryItem("FolderToRename_bf3");

            subfolderUnderRenamedFolder.AddRepositoryItem(bf3);

            //Act
            string newName = "RenameBfsSubFolder_NewName";

            folderToRename.RenameFolder(newName);
            ObservableList <MyRepositoryItem> bfs = mSolutionRepository.GetAllRepositoryItems <MyRepositoryItem>();

            //Assert
            Assert.IsTrue(folderToRename.FolderRelativePath.Contains(newName), "Validate folder relative path was updated");
            Assert.IsTrue(folderToRename.FolderFullPath.Contains(newName), "Validate folder full path was updated");
            Assert.IsTrue(Directory.Exists(folderToRename.FolderFullPath), "Validate folder full path is valid");
            Assert.AreEqual(folderToRename.DisplayName, newName, "Validate folder Display Name is correct");
            Assert.AreEqual(folderToRename.FolderName, newName, "Validate Folder Name is correct");
            Assert.IsTrue(subfolderUnderRenamedFolder.FolderRelativePath.Contains(newName), "Validate sub folder relative path was updated");
            Assert.IsTrue(subfolderUnderRenamedFolder.FolderFullPath.Contains(newName), "Validate sub folder full path was updated");
            Assert.IsTrue(Directory.Exists(subfolderUnderRenamedFolder.FolderFullPath), "Validate sub folder full path is valid");
            Assert.IsTrue(bf1.ContainingFolder.Contains(newName), "Validate level 1 BF ContainingFolder was updated");
            Assert.IsTrue(bf1.ContainingFolderFullPath.Contains(newName), "Validate level 1 BF ContainingFolderFullPath was updated");
            Assert.IsTrue(bf1.FilePath.Contains(newName), "Validate level 1 BF FilePath was updated");
            Assert.IsTrue(File.Exists(bf1.FilePath), "Validate level 1 BF FilePath is valid");
            Assert.IsTrue(bf3.ContainingFolder.Contains(newName), "Validate level 2 BF ContainingFolder was updated");
            Assert.IsTrue(bf3.ContainingFolderFullPath.Contains(newName), "Validate level 2 BF ContainingFolderFullPath was updated");
            Assert.IsTrue(bf3.FilePath.Contains(newName), "Validate level 2 BF FilePath was updated");
            Assert.IsTrue(File.Exists(bf3.FilePath), "Validate level 2 BF FilePath is valid");
            Assert.AreEqual(bfs.Where(x => x.Guid == bf1.Guid).ToList().Count, 1, "Make sure level 1 item is not loaded to cache more than once");
            Assert.AreEqual(bfs.Where(x => x.Guid == bf3.Guid).ToList().Count, 1, "Make sure level 2 item is not loaded to cache more than once");
        }
        public static RunSetConfig CreateNewRunset(string runSetName = "", RepositoryFolder <RunSetConfig> runSetsFolder = null)
        {
            if (string.IsNullOrEmpty(runSetName))
            {
                do
                {
                    if (!string.IsNullOrEmpty(runSetName.Trim()))
                    {
                        Reporter.ToUser(eUserMsgKey.DuplicateRunsetName, runSetName);
                    }

                    bool returnWindow = InputBoxWindow.OpenDialog(string.Format("Add New {0}", GingerDicser.GetTermResValue(eTermResKey.RunSet)),
                                                                  string.Format("{0} Name:", GingerDicser.GetTermResValue(eTermResKey.RunSet)),
                                                                  ref runSetName);

                    if (returnWindow)
                    {
                        if (string.IsNullOrEmpty(runSetName.Trim()))
                        {
                            Reporter.ToUser(eUserMsgKey.ValueIssue, "Value cannot be empty");
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }while (string.IsNullOrEmpty(runSetName.Trim()) || WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <RunSetConfig>().Where(r => r.ItemName.ToLower() == runSetName.ToLower()).FirstOrDefault() != null);
            }

            RunSetConfig runSetConfig = new RunSetConfig();

            runSetConfig.Name = runSetName;

            GingerRunner gingerRunner = new GingerRunner {
                Name = "Runner 1"
            };
            GingerExecutionEngine gingerExecutionEngine = new GingerExecutionEngine(gingerRunner);

            gingerRunner.Executor = gingerExecutionEngine;

            runSetConfig.GingerRunners.Add(gingerRunner);
            runSetConfig.AddCategories();

            if (runSetsFolder == null)
            {
                WorkSpace.Instance.SolutionRepository.AddRepositoryItem(runSetConfig);
            }
            else
            {
                runSetsFolder.AddRepositoryItem(runSetConfig);
            }

            return(runSetConfig);
        }
 private void AddSingleAPIModel(ApplicationAPIUtils.eWebApiType type)
 {
     string apiName = string.Empty; ;
     if (InputBoxWindow.GetInputWithValidation(string.Format("Add {0} API",type.ToString()), "API Name:", ref apiName, System.IO.Path.GetInvalidPathChars()))
     {
         ApplicationAPIModel newApi = new ApplicationAPIModel();
         newApi.APIType = type;
         newApi.Name = apiName;
         newApi.ContainingFolder = mAPIModelFolder.FolderFullPath;              
         mAPIModelFolder.AddRepositoryItem(newApi);                            
     }
 }
Beispiel #14
0
        public override void Finish()
        {
            // TODO: do it in the page where user select the type
            if (((AgentOperations)Agent.AgentOperations).DriverInfo.isDriverPlugin)
            {
                Agent.AgentType = Agent.eAgentType.Service;
            }
            else
            {
                Agent.AgentType = Agent.eAgentType.Driver;
            }

            AgentsFolder.AddRepositoryItem(Agent);
        }
Beispiel #15
0
        public override void Finish()
        {
            //add selected apps
            foreach (EnvApplication app in apps)
            {
                if (app.Active)
                {
                    NewEnvironment.Applications.Add(app);
                }
            }

            //Save the Environment
            EnvsFolder.AddRepositoryItem(NewEnvironment);
        }
Beispiel #16
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            //validate details
            if (FilePathTextBox.Text.Trim() == string.Empty)
            {
                Reporter.ToUser(eUserMsgKey.MissingNewDSDetails, "File Path"); return;
            }
            else if (DSTypeComboBox.SelectedItem == null)
            {
                Reporter.ToUser(eUserMsgKey.MissingNewDSDetails, "DB type"); return;
            }

            mDSDetails.FileFullPath = mDSDetails.FilePath.Replace("~", WorkSpace.UserProfile.Solution.Folder);

            if (!Directory.Exists(Path.GetDirectoryName(mDSDetails.FileFullPath)))
            {
                Reporter.ToUser(eUserMsgKey.InvalidDSPath, Path.GetDirectoryName(mDSDetails.FileFullPath)); return;
            }

            mDSDetails.FilePath = mDSDetails.FilePath.Replace(WorkSpace.UserProfile.Solution.Folder, "~"); //Pending



            ObservableList <DataSourceBase> DSList = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <DataSourceBase>();

            foreach (DataSourceBase ds in DSList)
            {
                if (ds.FilePath == mDSDetails.FilePath)
                {
                    Reporter.ToUser(eUserMsgKey.DuplicateDSDetails, FilePathTextBox.Text.Trim()); return;
                }
            }

            okClicked = true;

            if (File.Exists(mDSDetails.FileFullPath.Replace("~", WorkSpace.UserProfile.Solution.Folder)) == false)
            {
                byte[] obj = Properties.Resources.GingerDataSource;
                System.IO.FileStream fs = new System.IO.FileStream(mDSDetails.FileFullPath.Replace("~", WorkSpace.UserProfile.Solution.Folder), System.IO.FileMode.Create, System.IO.FileAccess.Write);
                fs.Write(obj, 0, obj.Count());
                fs.Close();
                fs.Dispose();
            }

            mTargetFolder.AddRepositoryItem(mDSDetails);


            _pageGenericWin.Close();
        }
Beispiel #17
0
        public void AddMyRepositoryItemToSubFolder()
        {
            //Arrange
            string           MRIName = "AddMyRepositoryItemToSubFolder_New MRI";
            MyRepositoryItem MRI     = new MyRepositoryItem(MRIName);
            RepositoryFolder <MyRepositoryItem> subfolder = (from x in mSolutionRepository.GetRepositoryItemRootFolder <MyRepositoryItem>().GetSubFolders() where x.DisplayName == "EmptySubFolder" select x).FirstOrDefault();

            //Act
            subfolder.AddRepositoryItem(MRI);
            MyRepositoryItem MRI2 = (from x in mSolutionRepository.GetAllRepositoryItems <MyRepositoryItem>() where x.Name == MRIName select x).FirstOrDefault();

            //Assert
            Assert.AreEqual(MRI, MRI2);
            Assert.AreEqual(MRI.ContainingFolder, subfolder.FolderRelativePath);
        }
        /// <summary>
        /// This method is used to get the new POM object for new creation while recording
        /// </summary>
        /// <param name="pageTitle"></param>
        /// <param name="pageURL"></param>
        /// <param name="screenShot"></param>
        /// <returns></returns>
        private POMObjectRecordingHelper GetNewPOM(string pageTitle, string pageURL, string screenShot)
        {
            POMObjectRecordingHelper recordingHelper = new POMObjectRecordingHelper();

            try
            {
                ApplicationPOMModel newPOM = new ApplicationPOMModel();
                string uniquTitle          = GetUniquePOMName(pageTitle);
                newPOM.Name             = uniquTitle;
                newPOM.PageURL          = pageURL;
                newPOM.ScreenShotImage  = screenShot;
                newPOM.MappedUIElements = new ObservableList <ElementInfo>();
                if (WorkSpace.Instance.Solution != null)//check for unit tests
                {
                    RepositoryItemKey tAppkey = WorkSpace.Instance.Solution.ApplicationPlatforms.Where(x => x.AppName == Context.Target.Name).Select(x => x.Key).FirstOrDefault();
                    if (tAppkey != null)
                    {
                        newPOM.TargetApplicationKey = tAppkey;
                    }
                    else
                    {
                        newPOM.TargetApplicationKey = Context.Target.Key;
                    }
                }

                //Save new POM
                if (WorkSpace.Instance.SolutionRepository != null)//check for unit tests
                {
                    RepositoryFolder <ApplicationPOMModel> repositoryFolder = WorkSpace.Instance.SolutionRepository.GetRepositoryItemRootFolder <ApplicationPOMModel>();
                    repositoryFolder.AddRepositoryItem(newPOM);
                }

                if (mApplicationPOMList != null)
                {
                    mApplicationPOMList.Add(newPOM);//adding so user will notice it was added during recording
                }

                recordingHelper.PageTitle      = pageTitle;
                recordingHelper.PageURL        = pageURL;
                recordingHelper.ApplicationPOM = newPOM;
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Error in creating Recording object", ex);
            }
            return(recordingHelper);
        }
Beispiel #19
0
 public void SaveLearnedPOM()
 {
     if (ScreenShot != null)
     {
         using (var ms = new MemoryStream())
         {
             POM.ScreenShotImage = BitmapToBase64(ScreenShot);
         }
     }
     if (mPomModelsFolder != null)
     {
         mPomModelsFolder.AddRepositoryItem(POM);
     }
     else
     {
         WorkSpace.Instance.SolutionRepository.AddRepositoryItem(POM);
     }
 }
Beispiel #20
0
 public override void Finish()
 {
     if (ScreenShot != null)
     {
         using (var ms = new MemoryStream())
         {
             POM.ScreenShotImage = Ginger.General.BitmapToBase64(ScreenShot);
         }
     }
     if (mPomModelsFolder != null)
     {
         mPomModelsFolder.AddRepositoryItem(POM);
     }
     else
     {
         WorkSpace.Instance.SolutionRepository.AddRepositoryItem(POM);
     }
     //close all Agents raised in Wizard
     CloseStartedAgents();
 }
Beispiel #21
0
        void AddDefaultDataSource()
        {
            byte[] obj = Properties.Resources.GingerDataSource;

            if (!File.Exists(System.IO.Path.Combine(mSolution.Folder, @"DataSources\GingerDataSource.mdb")))
            {
                Directory.CreateDirectory(System.IO.Path.Combine(mSolution.Folder, "DataSources"));
                System.IO.FileStream fs = new System.IO.FileStream(System.IO.Path.Combine(mSolution.Folder, @"DataSources\GingerDataSource.mdb"), System.IO.FileMode.Create, System.IO.FileAccess.Write);
                fs.Write(obj, 0, obj.Count());
                fs.Close();
                fs.Dispose();
            }

            DataSourceBase a = new AccessDataSource();

            a.Name     = "GingerDataSource";
            a.FilePath = @"~\DataSources\GingerDataSource.mdb";
            a.DSType   = DataSourceBase.eDSType.MSAccess;
            RepositoryFolder <DataSourceBase> dsTargetFolder = WorkSpace.Instance.SolutionRepository.GetRepositoryItemRootFolder <DataSourceBase>();

            dsTargetFolder.AddRepositoryItem(a);
        }
        private void ImportAPIModels(ObservableList <ApplicationAPIModel> SelectedAAMList)
        {
            foreach (ApplicationAPIModel apiModel in SelectedAAMList)
            {
                Dictionary <System.Tuple <string, string>, List <string> > OptionalValuesPerParameterDict = new Dictionary <Tuple <string, string>, List <string> >();

                ImportOptionalValuesForParameters ImportOptionalValues = new ImportOptionalValuesForParameters();
                ImportOptionalValues.GetAllOptionalValuesFromExamplesFiles(apiModel, OptionalValuesPerParameterDict);
                ImportOptionalValues.PopulateOptionalValuesForAPIParameters(apiModel, OptionalValuesPerParameterDict);

                if (string.IsNullOrEmpty(apiModel.ContainingFolder))
                {
                    apiModel.ContainingFolder = APIModelFolder.FolderFullPath;
                }

                if (apiModel.TargetApplicationKey == null && TargetApplicationKey != null)
                {
                    apiModel.TargetApplicationKey = TargetApplicationKey;
                }

                if (apiModel.TagsKeys != null && TagsKeys != null)
                {
                    foreach (RepositoryItemKey tagKey in TagsKeys)
                    {
                        apiModel.TagsKeys.Add(tagKey);
                    }
                }

                if (APIModelFolder.FolderFullPath == apiModel.ContainingFolder)
                {
                    APIModelFolder.AddRepositoryItem(apiModel);
                }
                else
                {
                    RepositoryFolderBase rfFolderBase = amdocs.ginger.GingerCoreNET.WorkSpace.Instance.SolutionRepository.GetRepositoryFolderByPath(apiModel.ContainingFolder);
                    rfFolderBase.AddRepositoryItem(apiModel);
                }
            }
        }
Beispiel #23
0
        private void CreateSolutionItems()
        {
            //Business Flows
            BusinessFlow BF1 = new BusinessFlow("BF1");

            mSolutionRepository.AddRepositoryItem(BF1);


            BusinessFlow BF2 = new BusinessFlow("BF2");

            mSolutionRepository.AddRepositoryItem(BF2);

            BusinessFlow BF3 = new BusinessFlow("BF3");

            mSolutionRepository.AddRepositoryItem(BF3);

            RepositoryFolder <BusinessFlow> BFRF       = mSolutionRepository.GetRepositoryItemRootFolder <BusinessFlow>();
            RepositoryFolder <BusinessFlow> SubFolder1 = (RepositoryFolder <BusinessFlow>)BFRF.AddSubFolder("SubFolder1");

            BusinessFlow BF4 = new BusinessFlow("BF4");

            SubFolder1.AddRepositoryItem(BF4);

            // Folder to delete later
            BFRF.AddSubFolder("SubFolderForDelete");

            //Environments
            ProjEnvironment env1 = new ProjEnvironment();

            env1.Name = "Env1";
            mSolutionRepository.AddRepositoryItem(env1);

            ProjEnvironment env2 = new ProjEnvironment();

            env2.Name = "Env2";
            mSolutionRepository.AddRepositoryItem(env2);
            //TODO: add more sample items for testing
        }
Beispiel #24
0
        public void CreateNewBF(string BizFlowName, string fileName = null, RepositoryFolder <BusinessFlow> targetFolder = null)
        {
            if (GherkinTextEditor.FileName == null && fileName != null)
            {
                GherkinTextEditor.FileName = fileName;
            }


            if (targetFolder == null)
            {
                targetFolder = targetBFFolder;
            }

            mBizFlow            = App.GetNewBusinessFlow(BizFlowName);
            mBizFlow.Source     = BusinessFlow.eSource.Gherkin;
            mBizFlow.ExternalID = GherkinTextEditor.FileName.Replace(WorkSpace.UserProfile.Solution.Folder, "~");
            mBizFlow.Name       = BizFlowName;
            mBizFlow.Activities.Clear();

            mBizFlow.ContainingFolder         = targetFolder.FolderFullPath.Replace(WorkSpace.UserProfile.Solution.Folder, "~");
            mBizFlow.ContainingFolderFullPath = targetFolder.FolderFullPath;
            targetFolder.AddRepositoryItem(mBizFlow);
            targetFolder.RefreshFolderAndChildElementsSourceControlStatus();
        }
Beispiel #25
0
 public override void Finish()
 {
     AgentsFolder.AddRepositoryItem(Agent);
 }
        private static void CreateTestSolution()
        {
            // First we create a basic solution with some sample items
            SolutionRepository SR = new SolutionRepository();

            if (Directory.Exists(TempRepositoryFolder))
            {
                Directory.Delete(TempRepositoryFolder, true);
            }

            // Define the items types we want in our Repository
            //SR.AddItemInfo<MyRepositoryItem>("*.Ginger.MyRepositoryItem.xml", @"~\MyRepositoryItems", true, "My Repository Item", addToRootFolders: true, PropertyNameForFileName: nameof(MyRepositoryItem.Name));
            SR.AddItemInfo <MyRepositoryItem>(pattern: "*.Ginger.MyRepositoryItem.xml",   // Need to use for file name
                                              rootFolder: SolutionRepository.cSolutionRootFolderSign + "MyRepositoryItems",
                                              containRepositoryItems: true,
                                              displayName: "My Repository Item",
                                              PropertyNameForFileName: nameof(MyRepositoryItem.Name)
                                              );


            SR.CreateRepository(TempRepositoryFolder);
            SR.Open(TempRepositoryFolder);

            MyRepositoryItem A1 = new MyRepositoryItem("A1");

            SR.AddRepositoryItem(A1);

            MyRepositoryItem A2 = new MyRepositoryItem("A2");

            SR.AddRepositoryItem(A2);

            MyRepositoryItem A3 = new MyRepositoryItem("A3");

            SR.AddRepositoryItem(A3);


            RepositoryFolder <MyRepositoryItem> MyRepoRF   = SR.GetRepositoryItemRootFolder <MyRepositoryItem>();
            RepositoryFolder <MyRepositoryItem> SubFolder1 = (RepositoryFolder <MyRepositoryItem>)MyRepoRF.AddSubFolder("SubFolder1");

            MyRepoRF.AddSubFolder("EmptySubFolder");

            MyRepositoryItem A4 = new MyRepositoryItem("A4");

            SubFolder1.AddRepositoryItem(A4);

            // Folder to delete later
            MyRepoRF.AddSubFolder("SubFolderForDelete");

            // Create folders tree
            RepositoryFolder <MyRepositoryItem> SF1 = (RepositoryFolder <MyRepositoryItem>)MyRepoRF.AddSubFolder("SF1");
            RepositoryFolder <MyRepositoryItem> SF2 = (RepositoryFolder <MyRepositoryItem>)SF1.AddSubFolder("SF1_SF2");
            RepositoryFolder <MyRepositoryItem> SF3 = (RepositoryFolder <MyRepositoryItem>)SF2.AddSubFolder("SF1_SF2_SF3");
            MyRepositoryItem BF5 = new MyRepositoryItem("A5");

            SubFolder1.AddRepositoryItem(BF5);

            MyRepositoryItem BF6 = new MyRepositoryItem("A6");

            SF3.AddRepositoryItem(BF6);

            //TODO: add more sample items for testing
            SR.Close();
        }
Beispiel #27
0
        private static void CreateTestSolution()
        {
            // First we create a basic solution with some sample items
            SolutionRepository SR = new SolutionRepository();

            if (Directory.Exists(TempRepositoryFolder))
            {
                Directory.Delete(TempRepositoryFolder, true);
            }

            // Define the items types we want in our Repository
            SR.AddItemInfo <MyRepositoryItem>(pattern: "*.Ginger.MyRepositoryItem.xml",   // Need to use for file name
                                              rootFolder: SolutionRepository.cSolutionRootFolderSign + "MyRepositoryItems",
                                              containRepositoryItems: true,
                                              displayName: "My Repository Item",
                                              PropertyNameForFileName: nameof(MyRepositoryItem.Name)
                                              );


            SR.CreateRepository(TempRepositoryFolder);
            SR.Open(TempRepositoryFolder);

            MyRepositoryItem A1 = new MyRepositoryItem("A1");

            SR.AddRepositoryItem(A1);

            MyRepositoryItem A2 = new MyRepositoryItem("A2");

            SR.AddRepositoryItem(A2);

            MyRepositoryItem A3 = new MyRepositoryItem("A3");

            SR.AddRepositoryItem(A3);


            RepositoryFolder <MyRepositoryItem> MyRepoRF   = SR.GetRepositoryItemRootFolder <MyRepositoryItem>();
            RepositoryFolder <MyRepositoryItem> SubFolder1 = (RepositoryFolder <MyRepositoryItem>)MyRepoRF.AddSubFolder("SubFolder1");

            MyRepoRF.AddSubFolder("EmptySubFolder");

            MyRepositoryItem A4 = new MyRepositoryItem("A4");

            SubFolder1.AddRepositoryItem(A4);

            // Folder to delete later
            MyRepoRF.AddSubFolder("SubFolderForDelete");

            // Create folders tree
            RepositoryFolder <MyRepositoryItem> SF1 = (RepositoryFolder <MyRepositoryItem>)MyRepoRF.AddSubFolder("SF1");
            RepositoryFolder <MyRepositoryItem> SF2 = (RepositoryFolder <MyRepositoryItem>)SF1.AddSubFolder("SF1_SF2");
            RepositoryFolder <MyRepositoryItem> SF3 = (RepositoryFolder <MyRepositoryItem>)SF2.AddSubFolder("SF1_SF2_SF3");
            MyRepositoryItem BF5 = new MyRepositoryItem("A5");

            SubFolder1.AddRepositoryItem(BF5);

            MyRepositoryItem BF6 = new MyRepositoryItem("A6");

            SF3.AddRepositoryItem(BF6);

            RepositoryFolder <MyRepositoryItem> bigFolder = (RepositoryFolder <MyRepositoryItem>)MyRepoRF.AddSubFolder("BigfolderWith100Items");


            // Add another 100 big item so it will take time loading and we can check multi thread access while load in progress
            for (int i = 0; i < 100; i++)
            {
                MyRepositoryItem bigItem = new MyRepositoryItem("Big Item #" + i);
                bigItem.BigStringHolderSlowSet = new string('a', 150000);
                bigFolder.AddRepositoryItem(bigItem);
            }

            //TODO: add more sample items for testing
            SR.Close();
        }