コード例 #1
0
        public static TCObjectPropertiesDefinition CreateIssuesProperties(String objectToCreateOn, String propertyName)
        {
            TCProject proj = TCAddOn.ActiveWorkspace.GetTCProject();
            TCObjectPropertiesDefinition issuesDef = proj.ObjectPropertiesDefinitions.FirstOrDefault(pd => pd.Name.ToLower() == objectToCreateOn.ToLower());

            if (issuesDef == null)
            {   // Create Issues property definition.
                TCComponentFolder tempFolder = (TCComponentFolder)proj.CreateComponentFolder();
                issuesDef = tempFolder.CreatePropertyDefinition("Issue");
                proj.Move(issuesDef);
                tempFolder.Delete(MsgBoxResult_OkCancel.Ok, MsgBoxResult_YesNo.Yes);
            }

            // Check if object exist
            if (issuesDef != null)
            {
                String[] props = issuesDef.GetPropertyNames();

                // Check if property already exists, create it otherwise
                if (!props.Contains(propertyName))
                {
                    TCObjectProperty newPrp = issuesDef.CreateProperty();
                    newPrp.Name = propertyName;
                }
            }

            return(issuesDef);
        }
コード例 #2
0
        /// <summary>
        /// This method contains the logic performed when the context menu is selected.
        /// </summary>
        /// <param name="objectToExecuteOn">TCObject on which the context menu task is performed.</param>
        /// <param name="taskContext">Task Context of the AddOn Task.</param>
        /// <returns>TCObject Instance</returns>
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            TCProject workspaceRoot = objectToExecuteOn as TCProject;
            //Opens the File Upload dialog.
            string filepath = taskContext.GetFilePath("Upload UFT Object archive");
            //Instantiation of this object is mandatory. This class contains the necessary methods for migration.
            ToscaObjectDefinition toscaObjects = new ToscaObjectDefinition();

            try
            {
                //Instantiates the MigrationTask class that contains the business logic of migration.
                MigrationTask migrationObjectImporter = new MigrationTask(toscaObjects, Engine.Html);
                //Entry point of MigrationTask class.
                migrationObjectImporter.ProcessArchive(filepath);

                //Calling this method is mandatory. It outputs the file containing the migrated object information.
                string outputFilePath = toscaObjects.FinishObjectDefinitionTask();
                //Imports the output file from MigrationTask.
                workspaceRoot?.ImportExternalObjects(outputFilePath);
                //Cleans the migration metafiles.
                Directory.Delete(toscaObjects.MigrationFolderPath, true);
            }
            catch (Exception e)
            {
                //Pops-up the error message in case of any error in Migration.
                taskContext.ShowErrorMessage("Exception occured", e.Message);
            }
            return(null);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            using (TCAPI tcapi = TCAPI.CreateInstance())
            {
                TCWorkspace     workspace      = tcapi.OpenWorkspace(@"C:\Users\estan\Desktop\trainings\TOSCA Customizations\Tosca Workspace\Training Customizations\Training Customizations.tws", "Admin", "");
                TCProject       project        = workspace.GetProject();
                List <TCObject> result         = project.Search($"=>SUBPARTS:TCFolder[UniqueId==\"{unique_id_test_case_folder}\"]");
                TCFolder        testCaseFolder = (TCFolder)result.First();
                testCaseFolder.Checkout();

                TestCase testCase = testCaseFolder.CreateTestCase();
                testCase.Name = "Test Creating Test Case";

                XModule tboxSetBuffer = (XModule)project.Search($"=>SUBPARTS:XModule[UniqueId==\"{unique_id_tbox_set_buffer}\"]").First();
                XModule tboxWait      = (XModule)project.Search($"=>SUBPARTS:XModule[UniqueId==\"{unique_id_tbox_wait}\"]").First();


                XTestStep      setBufferTestStep  = testCase.CreateXTestStepFromXModule(tboxSetBuffer);
                XTestStepValue setBUfferStepvalue = setBufferTestStep.CreateXTestStepValue(tboxSetBuffer.Attributes.First());
                setBUfferStepvalue.Name       = "Test Buffer Creation";
                setBUfferStepvalue.Value      = "42";
                setBUfferStepvalue.ActionMode = XTestStepActionMode.Input;

                XTestStep      tboxSetWaitTimeStep      = testCase.CreateXTestStepFromXModule(tboxWait);
                XTestStepValue tboxWaitSettimeStepValue = tboxSetWaitTimeStep.TestStepValues.First();
                tboxWaitSettimeStepValue.Value = "500";
            }
        }
コード例 #4
0
        static void Main(string[] args)
        {
            TCAPI.CreateInstance(new Tricentis.TCAPIObjects.TCAPIConnectionInfo());
            Console.WriteLine("Enter the workspace path:");
            var path = Console.ReadLine();

            Console.WriteLine("Enter the username:"******"Enter the password:"******"Checkout succesful!");
            }
            else
            {
                Console.WriteLine("Workspace is already checked out!");
            }
            TCAPI.Instance.CloseWorkspace();
            TCAPI.CloseInstance();
        }
コード例 #5
0
        static void Main(string[] args)
        {
            using (TCAPI tcapi = TCAPI.CreateInstance())
            {
                TCWorkspace workspace = tcapi.OpenWorkspace(
                    twsPath: @"C:\Users\estan\Desktop\trainings\TOSCA Customizations\Tosca Workspace\Training Customizations\Training Customizations.tws",
                    loginName: "Admin", loginPassword: "");
                TCProject project = workspace.GetProject();
                TCFolder  folder  = project.CreateComponentFolder();
                folder.Name = "Created folder With Script";
                folder.EnsureUniqueName();
                // workspace.Save();

                List <TCObject> search_result = project.Search(tqlString: "=>SUBPARTS:TestCase[Name==\"Test\"]");
                TestCase        copyTestCase  = (TestCase)search_result.First();
                OwnedItem       parentFolder  = copyTestCase.ParentFolder;
                // parentFolder.CheckoutTree();

                for (int i = 0; i < 10; i++)
                {
                    parentFolder.Copy(copyTestCase);
                }
                //workspace.CheckInAll("");
                workspace.Save();

                Console.WriteLine(value: "Created folder and Test Cases Copied");
            }
        }
コード例 #6
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            TCAPI.CreateInstance(new Tricentis.TCAPIObjects.TCAPIConnectionInfo());

            TCWorkspace workspace = TCAPI.Instance.OpenWorkspace(txtPath.Text, txtUser.Text, txtPassword.Text);
            TCProject   project   = workspace.GetProject();

            TestCase testCase = (TestCase)project.Search($"=>SUBPARTS:TestCase[Name==\"{txtTestCase.Text}\"]").FirstOrDefault();

            if (testCase != null)
            {
                TCFolder executionListFolder = (TCFolder)project.Search("=>SUBPARTS:TCFolder[PossibleContent==\"Folder;ExecutionList\"]").First();
                if (executionListFolder.IsTaskApplicable(TCTasks.Checkout))
                {
                    executionListFolder.Checkout();
                }
                ExecutionList executionList = executionListFolder.CreateExecutionList();
                executionList.Name = txtTestCase.Text;
                executionList.CreateExecutionEntry(testCase);
                if (executionListFolder.CheckOutState.Equals(CheckOutState.CheckedOut))
                {
                    workspace.CheckInAll("Execution list created from code!");
                }
                workspace.Save();
                MessageBox.Show("Execution list created successfully");
            }
            else
            {
                MessageBox.Show("TestCase not found!");
            }
            TCAPI.Instance.CloseWorkspace();
            TCAPI.CloseInstance();
        }
コード例 #7
0
        public static bool TaskPossibleForProject(PersistableObject obj)
        {
            TCProject project = obj as TCProject;

            if (project == null)
            {
                return(false);
            }

            foreach (TCFolder fd in project.Items)
            {
                // if (fd.ContentPolicy.TestPlanningAllowed) {
                //     return false;
                // }
                return(true);
            }
            return(true);
        }
コード例 #8
0
        public static string[] GetPropertyNames(string type)
        {
            TCProject proj = TCAddOn.ActiveWorkspace.GetTCProject();
            TCObjectPropertiesDefinition propDef = proj.ObjectPropertiesDefinitions.FirstOrDefault(pd => pd.Name.ToLower() == type.ToLower());
            List <string> properties             = new List <string>();

            if (propDef is Tricentis.TCAPIObjects.Objects.RequirementTypeDefinition)
            {
                var reqType = typeof(Requirement);
                properties.AddRange(GetAvailablePropertiesForType(reqType));
            }
            else if (type == "Issue")
            {
                var issType = typeof(Issue);
                properties.AddRange(GetAvailablePropertiesForType(issType));
            }
            properties.AddRange(propDef.GetPropertyNames());
            return(properties.ToArray());
        }
コード例 #9
0
        public override void Execute(TCAddOnTaskContext context)
        {
            StringBuilder summaryInfo        = new StringBuilder();
            TCProject     project            = TCAddOn.ActiveWorkspace.GetTCProject();
            List <string> totalTcObjectCount = new List <string>();

            totalTcObjectCount.Add(" Requirements: " + project.Search("=>SUBPARTS:Requirement").Count());
            totalTcObjectCount.Add(" TestSheet: " + project.Search("=>SUBPARTS:TestSheet").Count());
            totalTcObjectCount.Add(" XModule: " + project.Search("=>SUBPARTS:XModule").Count());
            totalTcObjectCount.Add(" TestCase: " + project.Search("=>SUBPARTS:TestCase").Count());
            totalTcObjectCount.Add(" ExecutionList: " + project.Search("=>SUBPARTS:ExecutionList").Count());

            foreach (var item in totalTcObjectCount)
            {
                summaryInfo.Append(item + Environment.NewLine);
            }

            context.ShowMessageBox($"Summary of {project.DisplayedName}", $"Count of Tosca objects at {DateTime.Now + Environment.NewLine + Environment.NewLine + summaryInfo}");
        }
コード例 #10
0
        private static TCFolder GetRootFolderForExecLists(TCWorkspace myWorkspace)
        {
            //Retrieve the project
            TCProject project = myWorkspace.GetProject();

            //SearchFor ExecutionListFolder
            TCFolder execListFolder = null;

            foreach (OwnedItem item in project.Items)
            {
                if (item.Name == EXLISTROOTNODE)
                {
                    execListFolder = item as TCFolder;
                    break;
                }
            }
            if (execListFolder == null)
            {
                Console.WriteLine("ExecutionList TopFolder was not found");
                return(null);
            }

            TCFolder execStartFolder = null;

            foreach (OwnedItem subfolder in execListFolder.Items)
            {
                if (String.Equals(ToscaReportGenerator.Default.mainExList, subfolder.Name, StringComparison.InvariantCultureIgnoreCase))
                {
                    execStartFolder = subfolder as TCFolder;
                    break;
                }
            }

            if (execStartFolder == null)
            {
                Console.WriteLine(String.Format("ExecutionFolder {0} was not found", ToscaReportGenerator.Default.mainExList));
                return(null);
            }

            return(execStartFolder);
        }
コード例 #11
0
        public static TCObjectPropertiesDefinition CreateCustomProperties(String objectToCreateOn, String propertyName)
        {
            TCProject proj = TCAddOn.ActiveWorkspace.GetTCProject();
            TCObjectPropertiesDefinition propDef = proj.ObjectPropertiesDefinitions.FirstOrDefault(pd => pd.Name.ToLower() == objectToCreateOn.ToLower());

            // Check if object exist
            if (propDef != null)
            {
                String[] props = propDef.GetPropertyNames();

                // Check if property already exists, create it otherwise
                if (!props.Contains(propertyName))
                {
                    TCObjectProperty newPrp = propDef.CreateProperty();
                    newPrp.Name = propertyName;
                }
            }
            else
            {
                throw new Exception("Invalid object to create property definition");
            }

            return(propDef);
        }
コード例 #12
0
 public TCProjectTaskInterceptor(TCProject obj)
 {
 }
コード例 #13
0
ファイル: ProjectSettings.cs プロジェクト: piatech/TCPlayer
 public ProjectSettings(TCProject Project)
 {
     InitializeComponent();
     _project = Project;
 }