Exemple #1
0
        //Gherkin BDD functions
        private void ImportGherkinFeatureFile(object sender, RoutedEventArgs e)
        {
            string FeatureFolder = Folder;

            if (this.Path.IndexOf("Documents\\Features\\") > 0)
            {
                FeatureFolder = this.Path.Substring(this.Path.IndexOf("Documents\\Features\\") + 19);
            }
            ImportGherkinFeatureFilePage IFP = new ImportGherkinFeatureFilePage(FeatureFolder, ImportGherkinFeatureFilePage.eImportGherkinFileContext.DocumentsFolder);

            IFP.ShowAsWindow();
            string featureFile = IFP.mFeatureFile;

            if (!String.IsNullOrEmpty(featureFile))
            {
                if (Folder == "Documents")
                {
                    DocumentsFolderTreeItem DFTI = new DocumentsFolderTreeItem();
                    DFTI.Path   = App.UserProfile.Solution.Folder + "Documents" + @"\" + "Features";
                    DFTI.Folder = "Features";
                    mTreeView.Tree.RefreshSelectedTreeNodeChildrens();
                    mTreeView.Tree.GetChildItembyNameandSelect("Features", this);
                }
                mTreeView.Tree.RefreshSelectedTreeNodeChildrens();
                mTreeView.Tree.GetChildItembyNameandSelect(System.IO.Path.GetFileName(featureFile), mTreeView.Tree.CurrentSelectedTreeViewItem);
            }
        }
Exemple #2
0
        private void CreateGherkinFeatureFile(object sender, RoutedEventArgs e)
        {
            string FileName = string.Empty;

            if (GingerCore.General.GetInputWithValidation("New Feature File", "File Name:", ref FileName, System.IO.Path.GetInvalidFileNameChars()))
            {
                string FullDirectoryPath     = "";
                DocumentsFolderTreeItem DFTI = null;
                if (this.Folder == "Documents")
                {
                    FullDirectoryPath = App.UserProfile.Solution.Folder + "Documents" + @"\" + "Features";

                    if (!System.IO.Directory.Exists(FullDirectoryPath))
                    {
                        System.IO.Directory.CreateDirectory(FullDirectoryPath);
                        DFTI        = new DocumentsFolderTreeItem();
                        DFTI.Path   = FullDirectoryPath;
                        DFTI.Folder = "Features";
                        mTreeView.Tree.AddChildItemAndSelect(this, DFTI);
                        mTreeView.Tree.RefreshSelectedTreeNodeChildrens();
                    }
                    else
                    {
                        DFTI = (DocumentsFolderTreeItem)mTreeView.Tree.GetChildItembyNameandSelect("Features", this);
                    }
                }
                else
                {
                    FullDirectoryPath = this.Path;
                }

                string FullFilePath = FullDirectoryPath + @"\" + FileName + ".feature";
                if (!System.IO.File.Exists(FullFilePath))
                {
                    string FileContent = "Feature: Description\r\n\r\n@Tag1 @Tag2\r\n\r\nScenario: Scenario1 Description\r\n       Given \r\n       And \r\n       And \r\n       When \r\n       Then \r\n\r\n\r\n@Tag1 @Tag2\r\n\r\nScenario: Scenario2 Description\r\n       Given \r\n       And \r\n       And \r\n       When \r\n       Then \r\n\r\n@Tag1 @Tag2\r\n\r\n\r\nScenario Outline: eating\r\n  Given there are <start> cucumbers\r\n  When I eat <eat> cucumbers\r\n  Then I should have <left> cucumbers\r\n\r\n  Examples:\r\n    | start | eat | left |\r\n    |  12   |  5  |  7   |\r\n    |  20   |  5  |  15  |";
                    using (Stream fileStream = File.Create(FullFilePath))
                    {
                        fileStream.Close();
                    }
                    File.WriteAllText(FullFilePath, FileContent);

                    mTreeView.Tree.RefreshSelectedTreeNodeChildrens();
                    mTreeView.Tree.GetChildItembyNameandSelect(FileName + ".feature", mTreeView.Tree.CurrentSelectedTreeViewItem);
                }
                else
                {
                    Reporter.ToUser(eUserMsgKeys.GherkinNotifyFeatureFileExists, FullFilePath);
                }
            }
        }
Exemple #3
0
        public override ITreeViewItem AddSubFolder(Type typeOfFolder, string newFolderName, string newFolderPath)
        {
            try
            {
                mTreeView.Tree.ExpandTreeItem((ITreeViewItem)this);

                System.IO.Directory.CreateDirectory(newFolderPath);
                DocumentsFolderTreeItem FolderItem = new DocumentsFolderTreeItem();
                FolderItem.Folder = newFolderName;
                FolderItem.Path   = newFolderPath;
                mTreeView.Tree.AddChildItemAndSelect((ITreeViewItem)this, (ITreeViewItem)FolderItem);
                return(FolderItem);
            }
            catch (Exception ex)
            {
                Reporter.ToUser(eUserMsgKey.StaticErrorMessage, "Add sub folder failed, error: " + ex.Message);
                return(null);
            }
        }
Exemple #4
0
        private void AddSubFolders(string sDir, List <ITreeViewItem> Childrens)
        {
            try
            {
                foreach (string d in Directory.GetDirectories(Path))
                {
                    DocumentsFolderTreeItem FolderItem = new DocumentsFolderTreeItem();
                    string FolderName = System.IO.Path.GetFileName(d);

                    FolderItem.Folder = FolderName;
                    FolderItem.Path   = d;

                    Childrens.Add(FolderItem);
                }
            }
            catch (System.Exception excpt)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed to add Document Folder to tree", excpt);
            }
        }
        private void AddsubFolders(string sDir, List <ITreeViewItem> Childrens)
        {
            try
            {
                foreach (string d in Directory.GetDirectories(Path))
                {
                    DocumentsFolderTreeItem FolderItem = new DocumentsFolderTreeItem();
                    string FolderName = System.IO.Path.GetFileName(d);

                    FolderItem.Folder = FolderName;
                    FolderItem.Path   = d;

                    Childrens.Add(FolderItem);
                }
            }
            catch (System.Exception excpt)
            {
                Console.WriteLine(excpt.Message);
            }
        }
Exemple #6
0
        private void ImportGherkinFeature(object sender, RoutedEventArgs e)
        {
            BusinessFlow BF = null;

            if (WorkSpace.Instance.BetaFeatures.ImportGherkinFeatureWizrd)
            {
                WizardWindow.ShowWizard(new ImportGherkinFeatureWizard(mBusFlowsFolder.FolderFullPath));
            }
            else
            {
                // TODO: check test me
                string FeatureFolder = mBusFlowsFolder.FolderFullPath;
                if (!mBusFlowsFolder.FolderFullPath.EndsWith("BusinessFlows"))
                {
                    FeatureFolder = mBusFlowsFolder.FolderFullPath.Substring(mBusFlowsFolder.FolderFullPath.IndexOf("BusinessFlows\\") + 14);
                }
                ImportGherkinFeatureFilePage IFP = new ImportGherkinFeatureFilePage(FeatureFolder, ImportGherkinFeatureFilePage.eImportGherkinFileContext.BusinessFlowFolder);
                IFP.ShowAsWindow();
                BF = IFP.BizFlow;

                if (BF != null)
                {
                    //Refresh and select Faetures Folder
                    DocumentsFolderTreeItem DFTI = (DocumentsFolderTreeItem)mTreeView.Tree.GetChildItembyNameandSelect("Documents");
                    DFTI = (DocumentsFolderTreeItem)mTreeView.Tree.GetChildItembyNameandSelect("Features", DFTI);
                    if (mBusFlowsFolder.FolderFullPath != "Business Flows")
                    {
                        mTreeView.Tree.GetChildItembyNameandSelect(mBusFlowsFolder.FolderFullPath, DFTI);
                    }
                    mTreeView.Tree.RefreshSelectedTreeNodeChildrens();

                    //Select Business Folder
                    mTreeView.Tree.SelectItem(this);
                    mTreeView.Tree.RefreshSelectedTreeNodeChildrens();
                    BusinessFlowTreeItem BFTI = new BusinessFlowTreeItem(BF);

                    mTreeView.Tree.GetChildItembyNameandSelect(BF.Name, this);
                }
            }
        }