Exemplo n.º 1
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++;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        //Add variables to test case and keywords files
        public static void WriteVariablesToRobotFiles()
        {
            const FormType tag = FormType.Variable;

            foreach (var temp in Forms.RobotAutomationHelper.GlobalVariables)
            {
                if (temp.VariableNames != null && temp.VariableNames.Count > 0)
                {
                    var fileName = temp.OutputFilePath;
                    var index    = RobotFileHandler.HasTag(fileName, FormType.Test);
                    if (index == -1)
                    {
                        index = RobotFileHandler.HasTag(fileName, FormType.Keyword);
                    }
                    if (index == -1)
                    {
                        index = 0;
                    }
                    var tempTagIndex = RobotFileHandler.HasTag(fileName, tag);
                    if (tempTagIndex == -1)
                    {
                        RobotFileHandler.FileLineAdd("*** Variables ***", fileName, index);
                        index++;
                        RobotFileHandler.FileLineAdd("", fileName, index);
                    }
                    else
                    {
                        index = tempTagIndex + 1;
                    }

                    temp.VariableNames.Sort();
                    foreach (var variable in temp.VariableNames)
                    {
                        RobotFileHandler.FileLineAdd(variable, fileName, index);
                        index++;
                    }
                }
            }
        }
Exemplo n.º 3
0
        //Add test case / keyword name to robot file
        private static int AddName(string name, string fileName, int index, FormType tag)
        {
            var tempTagIndex = RobotFileHandler.HasTag(fileName, tag);

            if (tempTagIndex == -1)
            {
                if (tag.Equals(FormType.Keyword))
                {
                    RobotFileHandler.FileLineAdd("*** Keywords ***", fileName, index);
                }
                else
                {
                    if (tag.Equals(FormType.Test))
                    {
                        var tempKeywordsIndex = RobotFileHandler.HasTag(fileName, FormType.Keyword);
                        if (tempKeywordsIndex != -1)
                        {
                            RobotFileHandler.FileLineAdd("*** Test Cases ***", fileName, tempKeywordsIndex);
                            index = tempKeywordsIndex;
                        }
                        else
                        {
                            RobotFileHandler.FileLineAdd("*** Test Cases ***", fileName, index);
                        }
                    }
                }
                index++;
            }
            else
            if (tempTagIndex + 1 != index)
            {
                RobotFileHandler.FileLineAdd("", fileName, index);
                index++;
            }
            RobotFileHandler.FileLineAdd(name, fileName, index);
            return(index);
        }
Exemplo n.º 4
0
        // replaces tags and text when writing settings to the files
        private static void ReplaceInSettings(string replacementText, string tag, string outputFileName)
        {
            var location = RobotFileHandler.LocationInSettings(outputFileName, tag);

            //Add settings tag if not present in the file
            if (RobotFileHandler.HasTag(outputFileName, FormType.Settings) == -1)
            {
                RobotFileHandler.FileLineAdd("*** Settings ***", outputFileName, 0);
                RobotFileHandler.FileLineAdd("", outputFileName, 1);
            }

            if (location[0] == -1)
            {
                RobotFileHandler.FileLineAdd(replacementText
                                             , outputFileName
                                             , 1);
            }
            else
            {
                RobotFileHandler.FileLineReplace(replacementText
                                                 , outputFileName
                                                 , location);
            }
        }