// when save is pressed add all currently listed keywords to the Keywords List and then AddChangesToKeyword
 private void Save_Click(object sender, EventArgs e)
 {
     if (!IsKeywordPresentInFilesOrMemoryTree())
     {
         AddCurrentKeywordsToKeywordsList(sender, e);
         SaveChangesToKeyword();
         Close();
     }
     else
     {
         var result = MessageBox.Show(@"This action will affect other test cases / keywords that are using this one " + MemoryPath,
                                      @"Alert",
                                      MessageBoxButtons.YesNo);
         if (!result.Equals(DialogResult.Yes))
         {
             return;
         }
         AddCurrentKeywordsToKeywordsList(sender, e);
         SaveChangesToKeyword();
         TestCasesListOperations.OverwriteOccurrencesInKeywordTree(KeywordName.Text,
                                                                   FilesAndFolderStructure.ConcatFileNameToFolder(OutputFile.Text, FolderType.Resources),
                                                                   _parentKeywords[ImplementationIndexFromTheParent]);
         Close();
     }
 }
 public RobotFileDataGetter()
 {
     foreach (var fileName in FilesAndFolderStructure.GetFullSavedFiles(FolderType.Root))
     {
         RobotFiles.Add(new RobotFile(fileName));
     }
 }
 private void KeywordSave()
 {
     NameAndOutputToTestCaseFormCommunication.Save       = true;
     NameAndOutputToTestCaseFormCommunication.Name       = Controls["DynamicStep1Name"].Text;
     NameAndOutputToTestCaseFormCommunication.Value      = ((TextWithList)Controls["DynamicStep1Name"]).UpdateValue;
     NameAndOutputToTestCaseFormCommunication.OutputFile = FilesAndFolderStructure.ConcatFileNameToFolder(OutputFile.Text, FolderType.Resources);
     Close();
 }
 public void GetTheDataFromAllTheRobotFilesTest()
 {
     SuggestionsClass.PopulateSuggestionsList();
     FilesAndFolderStructure.SetFolder("C:\\Development\\robot-scripts\\jennyvegas_v005\\jennyvegas");
     FilesAndFolderStructure.FindAllRobotFilesAndAddToStructure();
     DataGetter = new RobotFileDataGetter();
     DataGetter.GetTheDataFromAllTheRobotFiles();
 }
        public void ShowKeywordContent(Keyword keyword, int keywordIndex)
        {
            //index variable gets the keyword index coming from the parent form
            ImplementationIndexFromTheParent = keywordIndex;

            if (keyword.Name != null)
            {
                KeywordName.Text = keyword.Name.Trim();
            }
            if (keyword.Documentation != null)
            {
                KeywordDocumentation.Text = keyword.Documentation.Replace("[Documentation]", "").Trim();
            }
            if (keyword.OutputFilePath != null)
            {
                if (!keyword.OutputFilePath.Equals(""))
                {
                    OutputFile.Text = keyword.OutputFilePath.Replace(FilesAndFolderStructure.GetFolder(FolderType.Resources), "\\");
                }
            }
            if (keyword.Arguments != null)
            {
                KeywordArguments.Text = keyword.Arguments.Replace("[Arguments]", "").Trim();
            }

            IsKeywordPresentInFilesOrMemoryTree();
            ThisFormKeywords = keyword.Keywords;

            NumberOfKeywordsInThisForm = 0;

            if (ThisFormKeywords != null && ThisFormKeywords.Count != 0)
            {
                // adds the keywords in the form
                foreach (var testStep in ThisFormKeywords)
                {
                    AddKeywordField(testStep, NumberOfKeywordsInThisForm + 1, false, true);
                    NumberOfKeywordsInThisForm++;
                }
            }
            else
            {
                // add a single keyword field if no keywords are available
                ThisFormKeywords = new List <Keyword>
                {
                    new Keyword("New Keyword", _parentKeywords[ImplementationIndexFromTheParent].OutputFilePath, keyword)
                };
                AddKeywordField(ThisFormKeywords[0], NumberOfKeywordsInThisForm + 1, true, true);
                NumberOfKeywordsInThisForm++;
                FilesAndFolderStructure.AddFileToSavedFiles(ThisFormKeywords[0].OutputFilePath);
            }

            UpdateNamesListAndUpdateStateOfSave();

            // show the form dialog
            StartPosition = FormStartPosition.Manual;
            ShowDialog();
        }
Beispiel #6
0
        private void SetupsVariablesAddForm()
        {
            UpdateOutputFileSuggestions(OutputFile, FormType);
            OutputFile.SelectedIndex = _selectedIndex;
            foreach (var fileName in FilesAndFolderStructure.GetShortSavedFiles(FolderType.Root))
            {
                var add = true;
                if (RobotAutomationHelper.GlobalVariables.Count != 0)
                {
                    foreach (var temp in RobotAutomationHelper.GlobalVariables)
                    {
                        if (!temp.ToString().Equals(FilesAndFolderStructure.ConcatFileNameToFolder(fileName, FolderType.Root)))
                        {
                            continue;
                        }
                        add = false;
                        break;
                    }
                }
                if (add)
                {
                    RobotAutomationHelper.GlobalVariables.Add(new Variables(new List <string>(), FilesAndFolderStructure.ConcatFileNameToFolder(fileName, FolderType.Root)));
                }
            }

            ActiveControl    = AddVariablesLabel;
            CurrentVariables = new Variables(new List <string>(), "");

            foreach (var temp in RobotAutomationHelper.GlobalVariables)
            {
                if (temp.ToString().Equals(FilesAndFolderStructure.ConcatFileNameToFolder(OutputFile.Items[OutputFile.SelectedIndex].ToString(), FolderType.Root)))
                {
                    CurrentVariables = temp.DeepClone();
                    break;
                }
            }

            _variablesCounter = 0;
            if (CurrentVariables.VariableNames.Count == 0)
            {
                FormControls.AddControl("Button", "DynamicStep" + _variablesCounter + "AddVariable",
                                        _variablesCounter,
                                        new Point(KeywordFieldConsts.LabelX - HorizontalScroll.Value, InitialYValue + (_variablesCounter - 1) * KeywordFieldConsts.VerticalDistanceBetweenKeywords - VerticalScroll.Value),
                                        new Size(KeywordFieldConsts.AddKeywordWidth, KeywordFieldConsts.FieldsHeight),
                                        "+",
                                        Color.Black,
                                        AddVariableToTheForm,
                                        this);
                return;
            }
            foreach (var unused in CurrentVariables.VariableNames)
            {
                _variablesCounter++;
                AddVariableField();
            }
        }
Beispiel #7
0
 public void AddTestCaseToProject(object sender, EventArgs e)
 {
     TestCases.Add(new TestCase(NameAndOutputToTestCaseFormCommunication.Name, NameAndOutputToTestCaseFormCommunication.OutputFile));
     _currentFilename = TestCases[TestCases.Count - 1].OutputFilePath.Replace(FilesAndFolderStructure.GetFolder(FolderType.Tests), "");
     _selectedIndex   = OutputFile.Items.IndexOf(_currentFilename);
     Console.WriteLine(@"After Name and output form: " + _currentFilename);
     TestCases.Sort();
     ClearDynamicElements();
     AddTestCaseToFormAndShow(false);
 }
Beispiel #8
0
        public void HasTagTest()
        {
            FilesAndFolderStructure.SetFolder("C:\\Development\\robot-scripts\\jennyvegas");
            FilesAndFolderStructure.FindAllRobotFilesAndAddToStructure();
            string FileName = "C:\\Development\\robot-scripts\\jennyvegas\\Resources\\RegisterForm.robot";

            ThisFile = new RobotFile(FileName);
            Assert.AreEqual(0, ThisFile.HasTag(Forms.FormType.Settings));
            Assert.AreEqual(6, ThisFile.HasTag(Forms.FormType.Variable));
            Assert.AreEqual(9, ThisFile.HasTag(Forms.FormType.Keyword));
        }
Beispiel #9
0
 private void UpdateThisFormTestCaseAddFormClosing(object sender, FormClosingEventArgs e)
 {
     if (((TestCaseAddForm)sender).SkipForm)
     {
         return;
     }
     FilesAndFolderStructure.AddImplementedTestCasesFilesToSavedFiles(TestCases, _indexOfTheTestCaseToBeImplemented);
     _currentFilename = TestCases[_indexOfTheTestCaseToBeImplemented - 1].OutputFilePath.Replace(FilesAndFolderStructure.GetFolder(FolderType.Tests), "");
     _selectedIndex   = OutputFile.Items.IndexOf(TestCases[_indexOfTheTestCaseToBeImplemented - 1].OutputFilePath.Replace(FilesAndFolderStructure.GetFolder(FolderType.Tests), ""));
     ClearDynamicElements();
     AddTestCaseToFormAndShow(false);
 }
Beispiel #10
0
        public void ShowTestCaseContent(TestCase testCase, int testIndex)
        {
            if (RobotAutomationHelper.Log)
            {
                Console.WriteLine(@"ShowTestCaseContent " + testCase.Name + @" " + testIndex);
            }
            ImplementationIndexFromTheParent = testIndex;
            if (testCase.Name != null)
            {
            }
            TestCaseName.Text = testCase.Name;
            if (testCase.Documentation != null)
            {
                TestCaseDocumentation.Text = testCase.Documentation.Replace("[Documentation]", "").Trim();
            }
            if (testCase.Tags != null)
            {
                TestCaseTags.Text = testCase.Tags.Replace("[Tags]", "").Trim();
            }
            if (testCase.OutputFilePath != null)
            {
                OutputFile.Text = testCase.OutputFilePath.Replace(FilesAndFolderStructure.GetFolder(FolderType.Tests), "\\");
            }

            IsTestCasePresentInFilesOrMemoryTree();
            ThisFormKeywords = new List <Keyword>();
            ThisFormKeywords = testCase.Steps;

            NumberOfKeywordsInThisForm = 0;
            if (ThisFormKeywords != null && ThisFormKeywords.Count != 0)
            {
                foreach (var testStep in testCase.Steps)
                {
                    AddKeywordField(testStep, NumberOfKeywordsInThisForm + 1, false, true);
                    NumberOfKeywordsInThisForm++;
                }
            }
            else
            {
                // add a single keyword field if no keywords are available
                ThisFormKeywords = new List <Keyword>
                {
                    new Keyword("New Keyword", FilesAndFolderStructure.GetFolder(FolderType.Resources) + "Auto.robot", null)
                };
                AddKeywordField(ThisFormKeywords[0], NumberOfKeywordsInThisForm + 1, true, true);
                NumberOfKeywordsInThisForm++;
            }

            UpdateListNamesAndUpdateStateOfSave();
            StartPosition = FormStartPosition.Manual;
            ShowDialog();
        }
Beispiel #11
0
 private void Save_Click(object sender, EventArgs e)
 {
     TextFieldsToCurrentVariablesNames();
     foreach (var temp in RobotAutomationHelper.GlobalVariables)
     {
         if (!temp.ToString().Equals(FilesAndFolderStructure.ConcatFileNameToFolder(OutputFile.Text, FolderType.Root)))
         {
             continue;
         }
         temp.VariableNames = CurrentVariables.VariableNames;
         break;
     }
 }
Beispiel #12
0
 private static void AddTestCaseAndResetValues()
 {
     if (_outputFilePath.Equals(FilesAndFolderStructure.GetFolder(FolderType.Tests)))
     {
         _outputFilePath = FilesAndFolderStructure.GetFolder(FolderType.Tests) + "Auto.robot";
     }
     _testCases.Add(new TestCase(_currentTestCase, _currentTestCaseDocumentation, _currentTestCaseTags, _currentTestCaseTestSteps, _outputFilePath, false));
     _currentTestCaseTestSteps     = new List <Keyword>();
     _currentTestCaseDocumentation = null;
     _currentTestCase     = "";
     _currentTestCaseTags = null;
     _outputFilePath      = FilesAndFolderStructure.GetFolder(FolderType.Tests);
 }
Beispiel #13
0
        private bool IsTestCasePresentInFilesOrMemoryTree()
        {
            MemoryPath = TestCasesListOperations.IsPresentInTheTestCasesTree(TestCaseName.Text,
                                                                             FilesAndFolderStructure.ConcatFileNameToFolder(OutputFile.Text, FolderType.Tests),
                                                                             RobotAutomationHelper.TestCases[ImplementationIndexFromTheParent]);

            if (!MemoryPath.Equals(""))
            {
                TestCaseName.ForeColor = Color.Red;
                return(true);
            }
            return(false);
        }
        private bool IsTestCasePresentInFilesOrMemoryTree()
        {
            MemoryPath = TestCasesListOperations.IsPresentInTheTestCasesTree(ContentName.Text,
                                                                             FilesAndFolderStructure.ConcatFileNameToFolder(OutputFile.Text, FolderType.Tests),
                                                                             null);

            if (!MemoryPath.Equals(""))
            {
                ContentName.ForeColor = Color.Red;
                return(true);
            }
            return(false);
        }
Beispiel #15
0
 private void VariablesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (FilesAndFolderStructure.GetShortSavedFiles(FolderType.Root) != null && FilesAndFolderStructure.GetShortSavedFiles(FolderType.Root).Count > 0)
     {
         InstantiateVariablesAddForm(sender, e);
     }
     else
     {
         MessageBox.Show(@"You haven't saved any keywords or test cases to files yet.",
                         @"Alert",
                         MessageBoxButtons.OK);
     }
 }
        public void UpdateListNamesAndUpdateStateOfSave()
        {
            var namesList = new List <string>();

            for (var i = 1; i <= NumberOfKeywordsInThisForm; i++)
            {
                if (Controls.Find("DynamicStep" + i + "Name", false).Length > 0)
                {
                    namesList.Add(Controls["DynamicStep" + i + "Name"].Text);
                }
            }
            ((ButtonWithToolTip)Save).UpdateState(namesList, FilesAndFolderStructure.GetFolder(FolderType.Resources) + "Auto.robot");
        }
        private bool IsKeywordPresentInFilesOrMemoryTree()
        {
            MemoryPath = TestCasesListOperations.IsPresentInTheKeywordTree(KeywordName.Text,
                                                                           FilesAndFolderStructure.ConcatFileNameToFolder(OutputFile.Text, FolderType.Resources),
                                                                           _parentKeywords[ImplementationIndexFromTheParent]);

            if (MemoryPath.Equals(""))
            {
                return(false);
            }
            KeywordName.ForeColor = Color.DarkOrange;
            return(true);
        }
        protected void AddKeywordToThisKeyword(object sender, EventArgs e)
        {
            var keywordIndex = int.Parse(((Button)sender).Name.Replace("DynamicStep", "").Replace("AddKeyword", ""));

            AssignThisKeywordNamesFromTextFields();

            if (ThisFormKeywords == null)
            {
                var checkNull = AddCurrentKeywordsToKeywordsList(sender, e);
                if (checkNull == null)
                {
                    ThisFormKeywords = new List <Keyword>();
                }
            }

            var path = !FormType.Equals(FormType.Params) ? FilesAndFolderStructure.ConcatFileNameToFolder(Controls["OutputFile"].Text, FilesAndFolderStructure.ConvertFormTypeToFolderType(FormType)) : _formParent.ThisFormKeywords[ImplementationIndexFromTheParent].OutputFilePath;

            ThisFormKeywords.Add(_formParent.ThisFormKeywords != null
                ? new Keyword("New Keyword", path,
                              _formParent.ThisFormKeywords[ImplementationIndexFromTheParent].Parent)
                : new Keyword("New Keyword", path, null));

            for (var i = NumberOfKeywordsInThisForm; i > keywordIndex; i--)
            {
                ThisFormKeywords[i].CopyKeyword(ThisFormKeywords[i - 1]);
            }

            if (_formParent.ThisFormKeywords != null)
            {
                ThisFormKeywords[keywordIndex] = new Keyword(NameAndOutputToTestCaseFormCommunication.Name, NameAndOutputToTestCaseFormCommunication.OutputFile, _formParent.ThisFormKeywords[ImplementationIndexFromTheParent].Parent);
            }
            else
            {
                ThisFormKeywords[keywordIndex] = new Keyword(NameAndOutputToTestCaseFormCommunication.Name, NameAndOutputToTestCaseFormCommunication.OutputFile, null);
            }

            NumberOfKeywordsInThisForm++;
            AddKeywordField(ThisFormKeywords[NumberOfKeywordsInThisForm - 1], NumberOfKeywordsInThisForm, false, true);

            for (var i = 1; i < NumberOfKeywordsInThisForm; i++)
            {
                Controls["DynamicStep" + i + "Name"].Text = ThisFormKeywords[i - 1].Name.Trim();
            }

            for (var i = 1; i <= NumberOfKeywordsInThisForm; i++)
            {
                ((TextWithList)Controls["DynamicStep" + i + "Name"]).TriggerUpdate(ThisFormKeywords[i - 1].Name, ThisFormKeywords[i - 1].ToString());
                ((TextWithList)Controls["DynamicStep" + i + "Name"]).EnableKeywordFields();
            }
        }
Beispiel #19
0
        private static void SetStructureFolder(string outputFolder)
        {
            if (!outputFolder.EndsWith("\\"))
            {
                outputFolder = outputFolder + "\\";
            }
            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }

            FilesAndFolderStructure.SetFolder(outputFolder);

            FilesAndFolderStructure.FindAllRobotFilesAndAddToStructure();
        }
        //adds the list of keywords ( + unimplemented ones ) to a Keyword and returns it
        protected Keyword AddCurrentKeywordsToKeywordsList(object sender, EventArgs e)
        {
            var path = !FormType.Equals(FormType.Params) ? FilesAndFolderStructure.ConcatFileNameToFolder(Controls["OutputFile"].Text, FilesAndFolderStructure.ConvertFormTypeToFolderType(FormType)) : _formParent.ThisFormKeywords[ImplementationIndexFromTheParent].OutputFilePath;

            // if AddImplementation is pressed a new form should be opened which requires the keyword that it represents
            var keywordIndex = 0;

            if (((Button)sender).Name.Contains("DynamicStep") &&
                !((Button)sender).Name.Contains("Params") &&
                !((Button)sender).Name.Contains("AddKeyword") &&
                !((Button)sender).Name.Contains("RemoveKeyword"))
            {
                keywordIndex = int.Parse(((Button)sender).Name.Replace("AddImplementation", "").Replace("DynamicStep", ""));
            }
            else
            if (((Button)sender).Name.Contains("DynamicStep") &&
                ((Button)sender).Name.Contains("Params"))
            {
                keywordIndex = int.Parse(((Button)sender).Name.Replace("Params", "").Replace("DynamicStep", ""));
            }

            // add to the global variable for the form that matches the index of the keyword to implement
            IndexOfTheKeywordToBeImplemented = keywordIndex;
            if (keywordIndex <= 0)
            {
                keywordIndex = 1;
            }

            if (ThisFormKeywords == null)
            {
                ThisFormKeywords = new List <Keyword>();
                for (var i = 1; i <= NumberOfKeywordsInThisForm; i++)
                {
                    ThisFormKeywords.Add(new Keyword(Controls["DynamicStep" + i + "Name"].Text, path, _formParent.ThisFormKeywords[ImplementationIndexFromTheParent].Parent));
                }
            }
            else
            {
                for (var i = ThisFormKeywords.Count + 1; i <= NumberOfKeywordsInThisForm; i++)
                {
                    ThisFormKeywords.Add(new Keyword(Controls["DynamicStep" + i + "Name"].Text, path, _formParent.ThisFormKeywords[ImplementationIndexFromTheParent].Parent));
                }
            }

            AssignThisKeywordNamesFromTextFields();

            return(ThisFormKeywords[keywordIndex - 1]);
        }
 private void TestCaseSave()
 {
     if (!IsTestCasePresentInFilesOrMemoryTree())
     {
         NameAndOutputToTestCaseFormCommunication.Save       = true;
         NameAndOutputToTestCaseFormCommunication.Name       = ContentName.Text;
         NameAndOutputToTestCaseFormCommunication.OutputFile = FilesAndFolderStructure.ConcatFileNameToFolder(OutputFile.Text, FolderType.Tests);
         Close();
     }
     else
     {
         MessageBox.Show(@"Test case with this name has already been implemented in the output file.",
                         @"Alert",
                         MessageBoxButtons.OK);
     }
 }
Beispiel #22
0
        public void ReadVariablesFromFile()
        {
            FilesAndFolderStructure.SetFolder("C:\\Development\\robot-scripts\\jennyvegas");
            FilesAndFolderStructure.FindAllRobotFilesAndAddToStructure();
            string FileName = "C:\\Development\\robot-scripts\\jennyvegas\\Resources\\RegisterForm.robot";

            ThisFile = new RobotFile(FileName);
            List <Variables> VariablesList = new List <Variables>();

            VariablesList = ThisFile.ReadVariablesFromFile();
            Assert.AreEqual(1, VariablesList[0].VariableNames.Count);

            FileName      = "C:\\Development\\robot-scripts\\jennyvegas\\Data\\DepositLocators.robot";
            ThisFile      = new RobotFile(FileName);
            VariablesList = ThisFile.ReadVariablesFromFile();
            Assert.AreEqual(35, VariablesList[0].VariableNames.Count);
        }
Beispiel #23
0
        //Add includes to test case and keywords files
        public static void WriteIncludesToRobotFiles()
        {
            const FormType tag = FormType.Settings;

            foreach (var temp in Includes)
            {
                if (temp.FilesToInclude.Count > 0)
                {
                    var index        = 0;
                    var fileName     = temp.FileName;
                    var tempTagIndex = RobotFileHandler.HasTag(fileName, tag);
                    if (tempTagIndex == -1)
                    {
                        RobotFileHandler.FileLineAdd("*** Settings ***", fileName, index);
                        index++;
                        RobotFileHandler.FileLineAdd("", fileName, index);
                    }
                    else
                    {
                        index = tempTagIndex + 1;
                    }

                    temp.FilesToInclude.Sort();
                    foreach (var path in temp.FilesToInclude)
                    {
                        if (!path.Contains("\\"))
                        {
                            if (!RobotFileHandler.OccurenceInSettings(fileName, "Library  " + path).Equals(""))
                            {
                                continue;
                            }
                            RobotFileHandler.FileLineAdd("Library  " + path, fileName, index);
                            index++;
                        }
                        else
                        if (RobotFileHandler.OccurenceInSettings(fileName, "Resource  " + path.Replace(FilesAndFolderStructure.GetFolder(FolderType.Root), "").Replace('\\', '/')).Equals(""))
                        {
                            RobotFileHandler.FileLineAdd("Resource  " + path.Replace(FilesAndFolderStructure.GetFolder(FolderType.Root), "").Replace('\\', '/'), fileName, index);
                            index++;
                        }
                    }
                }
            }
        }
Beispiel #24
0
        // returns the index of the specific tag - keyword / test cases / settings / variables
        public static List <Variables> ReadAllVariables()
        {
            var listOfVariables = new List <Variables>();

            foreach (var fileName in FilesAndFolderStructure.GetFullSavedFiles(FolderType.Root))
            {
                if (!File.Exists(fileName))
                {
                    continue;
                }
                var arrLine = File.ReadAllLines(fileName);

                var index = RobotFileHandler.HasTag(fileName, FormType.Variable);
                if (index == -1)
                {
                    continue;
                }

                var names = new List <string>();
                for (int i = index + 1; i < arrLine.Length; i++)
                {
                    if (arrLine[i].StartsWith("***"))
                    {
                        break;
                    }
                    if (arrLine[i].Trim().Length == 0)
                    {
                        continue;
                    }
                    if (StringAndListOperations.StartsWithVariable(arrLine[i].Trim()))
                    {
                        names.Add(arrLine[i].Trim());
                    }
                }

                if (names.Count == 0)
                {
                    continue;
                }
                var currentSuiteSettings = new Variables(names, fileName);
                listOfVariables.Add(currentSuiteSettings);
            }
            return(listOfVariables);
        }
        public static void UpdateOutputFileSuggestions(ComboBox comboBox, FormType formType)
        {
            var folderType = FilesAndFolderStructure.ConvertFormTypeToFolderType(formType);

            if (RobotAutomationHelper.Log)
            {
                Console.WriteLine(@"UpdateOutputFileSuggestions " + comboBox.Name);
            }
            comboBox.Items.Clear();
            comboBox.AutoCompleteCustomSource.Clear();
            // ReSharper disable once CoVariantArrayConversion
            comboBox.Items.AddRange(FilesAndFolderStructure.GetShortSavedFiles(folderType).ToArray());
            comboBox.AutoCompleteCustomSource.AddRange(FilesAndFolderStructure.GetShortSavedFiles(folderType).ToArray());
            comboBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
            if (comboBox.DropDownStyle != ComboBoxStyle.DropDownList)
            {
                comboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            }
        }
        // returns the index of the specific tag - keyword / test cases / settings / variables
        public List <SuiteSettings> ReadSettingsFromFile()
        {
            var suiteSettings = new List <SuiteSettings>();

            foreach (var fileName in FilesAndFolderStructure.GetFullSavedFiles(FolderType.Tests))
            {
                var currentSuiteSettings = new SuiteSettings(fileName.Replace(FilesAndFolderStructure.GetFolder(FolderType.Root), ""))
                {
                    Documentation = RobotFileHandler.OccurenceInSettings(fileName, "Documentation").Replace("Documentation", "").Trim(),
                    TestSetup     = new Keyword(RobotFileHandler.OccurenceInSettings(fileName, "Test Setup").Replace("Test Setup", "").Trim(), fileName, libraries, null)
                };
                currentSuiteSettings.TestTeardown  = new Keyword(RobotFileHandler.OccurenceInSettings(fileName, "Test Teardown").Replace("Test Teardown", "").Trim(), fileName, libraries, null);
                currentSuiteSettings.SuiteSetup    = new Keyword(RobotFileHandler.OccurenceInSettings(fileName, "Suite Setup").Replace("Suite Setup", "").Trim(), fileName, libraries, null);
                currentSuiteSettings.SuiteTeardown = new Keyword(RobotFileHandler.OccurenceInSettings(fileName, "Suite Teardown").Replace("Suite Teardown", "").Trim(), fileName, libraries, null);
                currentSuiteSettings.Overwrite     = true;
                suiteSettings.Add(currentSuiteSettings);
            }
            return(suiteSettings);
        }
Beispiel #27
0
        private void SaveChangesToTestCases()
        {
            if (RobotAutomationHelper.Log)
            {
                Console.WriteLine(@"SaveChangesToTestCases");
            }
            if (RobotAutomationHelper.TestCases[ImplementationIndexFromTheParent].Steps != null && RobotAutomationHelper.TestCases[ImplementationIndexFromTheParent].Steps.Count > 0)
            {
                for (var counter = 1; counter <= RobotAutomationHelper.TestCases[ImplementationIndexFromTheParent].Steps.Count; counter++)
                {
                    ThisFormKeywords[counter - 1].Name = ((TextWithList)Controls["DynamicStep" + counter + "Name"]).Text.Trim();
                }
            }

            var finalPath = FilesAndFolderStructure.ConcatFileNameToFolder(OutputFile.Text, FolderType.Tests);

            RobotAutomationHelper.TestCases[ImplementationIndexFromTheParent] = new TestCase(TestCaseName.Text.Trim(),
                                                                                             "[Documentation]  " + TestCaseDocumentation.Text.Trim(),
                                                                                             "[Tags]  " + TestCaseTags.Text.Trim(),
                                                                                             ThisFormKeywords,
                                                                                             finalPath,
                                                                                             true);
        }
Beispiel #28
0
        private void AddTestCasesToMainForm(string fileName)
        {
            Console.WriteLine(@"AddTestCasesToMainForm: " + fileName);
            UpdateOutputFileSuggestions(OutputFile, FormType.Test);
            if (OutputFile.Items.Count != 0)
            {
                OutputFile.SelectedIndex = _selectedIndex;
            }
            var testCasesCounter = 1;

            _numberOfTestCases = 0;
            if (TestCases != null && TestCases.Count != 0)
            {
                for (var i = 0; i < TestCases.Count; i++)
                {
                    if (!FilesAndFolderStructure.ConcatFileNameToFolder(fileName, FolderType.Tests).ToLower().Equals(TestCases[i].OutputFilePath.ToLower()))
                    {
                        continue;
                    }
                    AddTestCaseField(TestCases[i], testCasesCounter, i + 1);
                    testCasesCounter++;
                    _numberOfTestCases++;
                }
            }
            else
            {
                if (TestCases == null)
                {
                    return;
                }
                TestCases.Add(new TestCase("New Test Case",
                                           FilesAndFolderStructure.GetFolder(FolderType.Tests) + "Auto.robot"));
                AddTestCaseField(TestCases[0], testCasesCounter, 1);
                _numberOfTestCases = 1;
                FilesAndFolderStructure.AddFileToSavedFiles(TestCases[0].OutputFilePath);
            }
        }
Beispiel #29
0
        private void SaveToRobotToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WriteToRobot.Includes = new List <Includes>();
            //Cleanup
            FilesAndFolderStructure.DeleteAllFiles();

            TestCases.Sort();
            foreach (var testCase in TestCases)
            {
                WriteToRobot.AddTestCaseToRobot(testCase);
            }

            Console.WriteLine(@"WriteSuiteSettingsListToRobot ===============================");
            WriteToRobot.WriteSuiteSettingsListToRobot();
            Console.WriteLine(@"WriteIncludesToRobotFiles ===================================");
            WriteToRobot.WriteIncludesToRobotFiles();
            Console.WriteLine(@"WriteVariablesToRobotFiles ===================================");
            WriteToRobot.WriteVariablesToRobotFiles();

            foreach (var fileName in FilesAndFolderStructure.GetShortSavedFiles(FolderType.Root))
            {
                RobotFileHandler.TrimFile(FilesAndFolderStructure.ConcatFileNameToFolder(fileName, FolderType.Root));
            }
        }
        // add newText on new line to file fileName after specified line
        public static void FileLineAdd(string newText, string fileName, int lineToAddAfter)
        {
            string[] arrLine;
            if (File.Exists(fileName))
            {
                arrLine = File.ReadAllLines(fileName);
            }
            else
            {
                var directory = fileName.Replace(fileName.Split('\\')[fileName.Split('\\').Length - 1], "");
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }
                var myFile = File.Create(fileName);
                myFile.Close();
                arrLine = File.ReadAllLines(fileName);
            }

            var temp = new List <string>();

            temp.AddRange(arrLine);
            if (!(lineToAddAfter > arrLine.Length))
            {
                temp.Insert(lineToAddAfter, newText);
            }
            else
            {
                temp.Add(newText);
            }
            File.WriteAllLines(fileName, temp);
            if (!newText.Equals(""))
            {
                Console.WriteLine(@"Line added: " + newText + @"	"+ fileName.Replace(FilesAndFolderStructure.GetFolder(FolderType.Root), ""));
            }
        }