Ejemplo n.º 1
0
        public static void GetProjectCollection(TLSCmdletBase cmdlet)
        {
            try {
                cmdlet.WriteVerbose(cmdlet, "GetProjectCollection: getting list of projects");
                System.Collections.Generic.List <TestProject> listProjects =
                    TLAddinData.CurrentTestLinkConnection.GetProjects();

                cmdlet.WriteVerbose(cmdlet, "GetProjectCollection: outputting projects");
                cmdlet.WriteObject(cmdlet, listProjects);

                // 20130131
                if (null != listProjects && 0 < listProjects.Count)
                {
                    cmdlet.WriteVerbose(cmdlet, "GetProjectCollection: settiing the current test project");
                    TLAddinData.CurrentTestProject =
                        listProjects[listProjects.Count - 1];
                }
            }
            catch (Exception eProjectCollection) {
                cmdlet.WriteError(
                    cmdlet,
                    "Unable to get the list of projects. " +
                    eProjectCollection.Message,
                    "UnableToGetProjects",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
Ejemplo n.º 2
0
        public static void GetTestPlan(TLSCmdletBase cmdlet, TestProject[] testProjects, string[] testPlanNames)
        {
            string testPlanNameNow = string.Empty;

            try {
//                if (null == testProjects || 0 == testProjects.Length) {
//                    if (null != TLAddinData.CurrentTestProject) {
//                        testProjects = new Meyn.TestLink.TestProject[1];
//                        testProjects[0] = TLAddinData.CurrentTestProject;
//                    }
//                }

                if (null == testProjects || 0 == testProjects.Length)
                {
                    //cmdlet.WriteObject(cmdlet, null); // ??
                    return;
                }

                foreach (TestProject testProject in testProjects)
                {
                    foreach (string name in testPlanNames)
                    {
                        testPlanNameNow = name;

                        cmdlet.WriteVerbose(
                            cmdlet,
                            "Trying to get test plan '" +
                            testPlanNameNow +
                            "' from the project '" +
                            testProject.name +
                            "'.");

                        TestPlan testPlan =
                            TLAddinData.CurrentTestLinkConnection.getTestPlanByName(
                                testProject.name,
                                testPlanNameNow);

                        if (null != testPlan)
                        {
                            TLAddinData.CurrentTestPlan = testPlan;

                            cmdlet.WriteObject(cmdlet, testPlan);
                        }
                    }
                }
            }
            catch (Exception eGetTestPlan) {
                cmdlet.WriteError(
                    cmdlet,
                    "Couldn't get test plan '" +
                    testPlanNameNow +
                    "'. " +
                    eGetTestPlan.Message,
                    "" +
                    "CouldNotCreateTestPlan",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
Ejemplo n.º 3
0
        public static void GetTestPlans(TLSCmdletBase cmdlet, TestProject[] testProjects)
        {
            try {
                for (int i = 0; i < testProjects.Length; i++)
                {
                    if (null == testProjects[i])
                    {
                        if (null != TLAddinData.CurrentTestProject)
                        {
                            testProjects[i] = TLAddinData.CurrentTestProject;
                        }
                        else
                        {
                            cmdlet.WriteError(
                                cmdlet,
                                "You must specify a test project.",
                                "NoTestProjectSpecified",
                                ErrorCategory.InvalidArgument,
                                true);
                        }
                    }

                    System.Collections.Generic.List <TestPlan> listTestPlans =
                        TLAddinData.CurrentTestLinkConnection.GetProjectTestPlans(
                            testProjects[i].id);

                    foreach (TestPlan tplan in listTestPlans)
                    {
                        TLAddinData.CurrentTestPlan =
                            tplan;
                    }

                    cmdlet.WriteObject(cmdlet, listTestPlans);
                }
            }
            catch (Exception eGetTestPlans) {
                cmdlet.WriteError(
                    cmdlet,
                    "Couldn't get test plans. " +
                    eGetTestPlans.Message,
                    "" +
                    "CouldNotCreateTestPlan",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
Ejemplo n.º 4
0
        public static void GetBuild(
            TLSCmdletBase cmdlet,
            TestPlan[] testPlans,
            string[] buildNames)
        {
            string testPlanNameNow = string.Empty;

            WildcardOptions options =
                WildcardOptions.IgnoreCase |
                WildcardOptions.Compiled;

            try {
                foreach (TestPlan testPlan in testPlans)
                {
                    testPlanNameNow = testPlan.name;

                    System.Collections.Generic.List <Build> buildsList =
                        TLAddinData.CurrentTestLinkConnection.GetBuildsForTestPlan(testPlan.id);

                    if (null == buildNames || 0 == buildNames.Length)
                    {
                        cmdlet.WriteObject(
                            cmdlet,
                            buildsList);
                    }
                    else
                    {
                        foreach (Build build in buildsList)
                        {
                            foreach (string buildName in buildNames)
                            {
                                if ((new WildcardPattern(buildName, options)).IsMatch(build.name))
                                {
                                    cmdlet.WriteObject(
                                        cmdlet,
                                        build);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception eGetBuild) {
                cmdlet.WriteError(
                    cmdlet,
                    "Couldn't get builds from  '" +
                    testPlanNameNow +
                    "'. " +
                    eGetBuild.Message,
                    "" +
                    "CouldNotGetBuild",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
Ejemplo n.º 5
0
//        public static void OpenTestCase(TLSCmdletBase cmdlet, string name)
//        {
//            throw new NotImplementedException();
//        }

        public static void AddBuild(
            TLSCmdletBase cmdlet,
            TestPlan[] testPlans,
            string buildName,
            string buildNote)
        {
            try {
                for (int j = 0; j < testPlans.Length; j++)
                {
                    string description = string.Empty;

                    if (null != buildNote && string.Empty != buildNote)
                    {
                        description = buildNote;
                    }

                    GeneralResult result =
                        TLAddinData.CurrentTestLinkConnection.CreateBuild(
                            testPlans[j].id,
                            buildName,
                            description);

                    if (result.status)
                    {
                        cmdlet.WriteObject(
                            cmdlet,
                            TLAddinData.CurrentTestLinkConnection.GetLatestBuildForTestPlan(testPlans[j].id));
                    }
                }
            }
            catch (Exception eAddBuild) {
                cmdlet.WriteError(
                    cmdlet,
                    "Couldn't create a build '" +
                    buildName +
                    "'. " +
                    eAddBuild.Message,
                    "" +
                    "CouldNotCreateBuild",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
Ejemplo n.º 6
0
        public static void NewTestPlan(
            TLSCmdletBase cmdlet,
            string testPlanName,
            string testPlanNotes,
            bool active)
        {
            try {
                string description = string.Empty;
                if (null != testPlanNotes && string.Empty != testPlanNotes)
                {
                    description = testPlanNotes;
                }

                GeneralResult result =
                    TLAddinData.CurrentTestLinkConnection.CreateTestPlan(
                        testPlanName,
                        TLAddinData.CurrentTestProject.name,
                        description,
                        //activePlan);
                        active);

                if (result.status)
                {
                    TLAddinData.CurrentTestPlan =
                        TLAddinData.CurrentTestLinkConnection.getTestPlanByName(
                            TLAddinData.CurrentTestProject.name,
                            testPlanName);
                }
                cmdlet.WriteObject(cmdlet, TLAddinData.CurrentTestPlan);
            }
            catch (Exception eNewTestPlan) {
                cmdlet.WriteError(
                    cmdlet,
                    "Couldn't create a test plan '" +
                    testPlanName +
                    "'. " +
                    eNewTestPlan.Message,
                    "" +
                    "CouldNotCreateTestPlan",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
Ejemplo n.º 7
0
        internal static TestProject[] GetProjectsById(TLSCmdletBase cmdlet, string[] projectIds)
        {
            System.Collections.Generic.List <TestProject> resultList =
                new System.Collections.Generic.List <TestProject>();

            string projectIdNow = string.Empty;

            try {
                cmdlet.WriteVerbose(cmdlet, "collecting all projects");
                System.Collections.Generic.List <TestProject> projectsList =
                    TLAddinData.CurrentTestLinkConnection.GetProjects();

                cmdlet.WriteVerbose(cmdlet, "iterating through the project colection");
                foreach (TestProject testProject in projectsList)
                {
                    cmdlet.WriteVerbose(cmdlet, "iterating through the project ids colection");
                    foreach (string id in projectIds)
                    {
                        if (Convert.ToInt32(id) == testProject.id)
                        {
                            TLAddinData.CurrentTestProject = testProject;
                            cmdlet.WriteVerbose(cmdlet, "got the project '" + testProject.name + "'.");

                            resultList.Add(testProject);
                        }
                    }
                }
            }
            catch (Exception eProject) {
                cmdlet.WriteError(
                    cmdlet,
                    "Unable to get the project by id. " +
                    eProject.Message,
                    "UnableToGetProject",
                    ErrorCategory.InvalidResult,
                    true);
            }

            TestProject[] resultArray =
                resultList.ToArray();

            return(resultArray);
        }
Ejemplo n.º 8
0
        internal static TestProject[] GetProjectsByName(TLSCmdletBase cmdlet, string[] projectNames)
        {
            System.Collections.Generic.List <TestProject> resultList =
                new System.Collections.Generic.List <TestProject>();

            string projectNameNow = string.Empty;

            try {
                cmdlet.WriteVerbose(cmdlet, "iterating through the project names collection");
                foreach (string name in projectNames)
                {
                    cmdlet.WriteVerbose(cmdlet, name);
                    projectNameNow = name;

                    cmdlet.WriteVerbose(cmdlet, "getting project '" + projectNameNow + "'.");
                    TestProject testProject =
                        TLAddinData.CurrentTestLinkConnection.GetProject(projectNameNow);

                    if (null != testProject)
                    {
                        TLAddinData.CurrentTestProject = testProject;
                        cmdlet.WriteVerbose(cmdlet, "got the project '" + testProject.name + "'.");
                    }
                    resultList.Add(TLAddinData.CurrentTestProject);
                }
            }
            catch (Exception eProject) {
                cmdlet.WriteError(
                    cmdlet,
                    "Unable to get the project '" +
                    projectNameNow +
                    "'. " +
                    eProject.Message,
                    "UnableToGetProject",
                    ErrorCategory.InvalidResult,
                    true);
            }

            TestProject[] resultArray =
                resultList.ToArray();

            return(resultArray);
        }
Ejemplo n.º 9
0
        public static void GetBuild(
            TLSCmdletBase cmdlet,
            TestPlan[] testPlans,
            string[] buildNames)
        {
            string testPlanNameNow = string.Empty;
            
            WildcardOptions options =
                WildcardOptions.IgnoreCase |
                WildcardOptions.Compiled;
            
            try {

                foreach (Meyn.TestLink.TestPlan testPlan in testPlans) {
                    
                    testPlanNameNow = testPlan.name;
                    
                    System.Collections.Generic.List<Meyn.TestLink.Build> buildsList = 
                        TLAddinData.CurrentTestLinkConnection.GetBuildsForTestPlan(testPlan.id);
                    
                    if (null == buildNames || 0 == buildNames.Length) {
                        cmdlet.WriteObject(
                            cmdlet,
                            buildsList);
                    } else {
                        
                        foreach (Meyn.TestLink.Build build in buildsList) {
                            
                            foreach (string buildName in buildNames) {
                                
                                if ((new WildcardPattern(buildName, options)).IsMatch(build.name)) {
                                    
                                    cmdlet.WriteObject(
                                        cmdlet,
                                        build);
                                    
                                }
                            }
                            
                        }
                        
                    }
                }
                
            }
            catch (Exception eGetBuild) {
                cmdlet.WriteError(
                    cmdlet,
                    "Couldn't get builds from  '" +
                    testPlanNameNow +
                    "'. " +
                    eGetBuild.Message,
                    "" +
                    "CouldNotGetBuild",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
Ejemplo n.º 10
0
//        public static void OpenTestCase(TLSCmdletBase cmdlet, string name)
//        {
//            throw new NotImplementedException();
//        }

        public static void AddBuild(
            TLSCmdletBase cmdlet,
            TestPlan[] testPlans,
            string buildName,
            string buildNote)
        {
            
            try {
                
                for (int j = 0; j < testPlans.Length; j++) {

                    string description = string.Empty;

                    if (null != buildNote && string.Empty != buildNote) {

                        description = buildNote;
                    }

                    GeneralResult result = 
                        TLAddinData.CurrentTestLinkConnection.CreateBuild(
                            testPlans[j].id,
                            buildName,
                            description);
                    
                    if (result.status) {

                        cmdlet.WriteObject(
                            cmdlet,
                            TLAddinData.CurrentTestLinkConnection.GetLatestBuildForTestPlan(testPlans[j].id));

                    }
                    
                }
                
            }
            catch (Exception eAddBuild) {
                cmdlet.WriteError(
                    cmdlet,
                    "Couldn't create a build '" +
                    buildName +
                    "'. " +
                    eAddBuild.Message,
                    "" +
                    "CouldNotCreateBuild",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
Ejemplo n.º 11
0
        public static void GetTestPlan(TLSCmdletBase cmdlet, Meyn.TestLink.TestProject[] testProjects, string[] testPlanNames)
        {
            string testPlanNameNow = string.Empty;
            
            try {
                
//                if (null == testProjects || 0 == testProjects.Length) {
//                    if (null != TLAddinData.CurrentTestProject) {
//                        testProjects = new Meyn.TestLink.TestProject[1];
//                        testProjects[0] = TLAddinData.CurrentTestProject;
//                    }
//                }
                
                if (null == testProjects || 0 == testProjects.Length) {
                    //cmdlet.WriteObject(cmdlet, null); // ??
                    return;
                }
                
                foreach (Meyn.TestLink.TestProject testProject in testProjects) {
                    foreach (string name in testPlanNames) {
                        
                        testPlanNameNow = name;
                    
                        cmdlet.WriteVerbose(
                            cmdlet, 
                            "Trying to get test plan '" +
                            testPlanNameNow +
                            "' from the project '" + 
                            testProject.name +
                            "'.");
                        
                        TestPlan testPlan =
                            TLAddinData.CurrentTestLinkConnection.getTestPlanByName(
                                testProject.name,
                                testPlanNameNow);
                        
                        if (null != testPlan) {
                        
                            TLAddinData.CurrentTestPlan = testPlan;
        
                            cmdlet.WriteObject(cmdlet, testPlan);
                        }
                    
                    }
                }
            }
            catch (Exception eGetTestPlan) {
                cmdlet.WriteError(
                    cmdlet,
                    "Couldn't get test plan '" +
                    testPlanNameNow +
                    "'. " +
                    eGetTestPlan.Message,
                    "" +
                    "CouldNotCreateTestPlan",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
Ejemplo n.º 12
0
        public static void GetTestPlans(TLSCmdletBase cmdlet, Meyn.TestLink.TestProject[] testProjects)
        {
            try {
                
                for (int i = 0; i < testProjects.Length; i++) {
                    
                    if (null == testProjects[i]) {
                        if (null != TLAddinData.CurrentTestProject) {
                            testProjects[i] = TLAddinData.CurrentTestProject;
                        } else {
                            cmdlet.WriteError(
                                cmdlet,
                                "You must specify a test project.",
                                "NoTestProjectSpecified",
                                ErrorCategory.InvalidArgument,
                                true);
                        }
                    }
                    
                    System.Collections.Generic.List<TestPlan> listTestPlans =
                        TLAddinData.CurrentTestLinkConnection.GetProjectTestPlans(
                            testProjects[i].id);

                    foreach (TestPlan tplan in listTestPlans) {

                        TLAddinData.CurrentTestPlan =
                            tplan;

                    }

                    cmdlet.WriteObject(cmdlet, listTestPlans);
                
                }
                
            }
            catch (Exception eGetTestPlans) {
                cmdlet.WriteError(
                    cmdlet,
                    "Couldn't get test plans. " +
                    eGetTestPlans.Message,
                    "" +
                    "CouldNotCreateTestPlan",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
Ejemplo n.º 13
0
        public static void NewTestPlan(
            TLSCmdletBase cmdlet, 
            string testPlanName,
            string testPlanNotes,
            bool active)
        {
            try {

                string description = string.Empty;
                if (null != testPlanNotes && string.Empty != testPlanNotes) {
                    description = testPlanNotes;
                }
                
                GeneralResult result =
                    TLAddinData.CurrentTestLinkConnection.CreateTestPlan(
                        testPlanName,
                        TLAddinData.CurrentTestProject.name,
                        description,
                        //activePlan);
                        active);
                
                if (result.status) {
                    TLAddinData.CurrentTestPlan =
                        TLAddinData.CurrentTestLinkConnection.getTestPlanByName(
                            TLAddinData.CurrentTestProject.name,
                            testPlanName);
                }
                cmdlet.WriteObject(cmdlet, TLAddinData.CurrentTestPlan);
                
            }
            catch (Exception eNewTestPlan) {
                cmdlet.WriteError(
                    cmdlet,
                    "Couldn't create a test plan '" +
                    testPlanName +
                    "'. " +
                    eNewTestPlan.Message,
                    "" +
                    "CouldNotCreateTestPlan",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
Ejemplo n.º 14
0
        internal static Meyn.TestLink.TestProject[] GetProjectsById(TLSCmdletBase cmdlet, string[] projectIds)
        {
            System.Collections.Generic.List<Meyn.TestLink.TestProject> resultList =
                new System.Collections.Generic.List<Meyn.TestLink.TestProject>();

            string projectIdNow = string.Empty;
            
            try {

                cmdlet.WriteVerbose(cmdlet, "collecting all projects");
                System.Collections.Generic.List<Meyn.TestLink.TestProject> projectsList =
                    TLAddinData.CurrentTestLinkConnection.GetProjects();

                cmdlet.WriteVerbose(cmdlet, "iterating through the project colection");
                foreach (Meyn.TestLink.TestProject testProject in projectsList) {

                    cmdlet.WriteVerbose(cmdlet, "iterating through the project ids colection");
                    foreach (string id in projectIds) {

                        if (Convert.ToInt32(id) == testProject.id) {

                            TLAddinData.CurrentTestProject = testProject;
                            cmdlet.WriteVerbose(cmdlet, "got the project '" + testProject.name + "'.");

                            resultList.Add(testProject);
                        }
                    }
                }
                
            }
            catch (Exception eProject) {
                cmdlet.WriteError(
                    cmdlet,
                    "Unable to get the project by id. " +
                    eProject.Message,
                    "UnableToGetProject",
                    ErrorCategory.InvalidResult,
                    true);
            }

            Meyn.TestLink.TestProject[] resultArray =
                resultList.ToArray();

            return resultArray;
        }
Ejemplo n.º 15
0
        internal static Meyn.TestLink.TestProject[] GetProjectsByName(TLSCmdletBase cmdlet, string[] projectNames)
        {
            System.Collections.Generic.List<Meyn.TestLink.TestProject> resultList =
                new System.Collections.Generic.List<Meyn.TestLink.TestProject>();
            
            string projectNameNow = string.Empty;
            
            try {
                
                cmdlet.WriteVerbose(cmdlet, "iterating through the project names collection");
                foreach (string name in projectNames) {
                    
                    cmdlet.WriteVerbose(cmdlet, name);
                    projectNameNow = name;
                    
                    cmdlet.WriteVerbose(cmdlet, "getting project '" + projectNameNow + "'.");
                    TestProject testProject =
                        TLAddinData.CurrentTestLinkConnection.GetProject(projectNameNow);
                    
                    if (null != testProject) {
                        TLAddinData.CurrentTestProject = testProject;
                        cmdlet.WriteVerbose(cmdlet, "got the project '" + testProject.name + "'.");
                    }
                    resultList.Add(TLAddinData.CurrentTestProject);
                }
                
            }
            catch (Exception eProject) {
                cmdlet.WriteError(
                    cmdlet,
                    "Unable to get the project '" +
                    projectNameNow +
                    "'. " +
                    eProject.Message,
                    "UnableToGetProject",
                    ErrorCategory.InvalidResult,
                    true);
            }

            Meyn.TestLink.TestProject[] resultArray =
                resultList.ToArray();

            return resultArray;
        }
Ejemplo n.º 16
0
 public static void GetProjectCollection(TLSCmdletBase cmdlet)
 {
     try {
         
         cmdlet.WriteVerbose(cmdlet, "GetProjectCollection: getting list of projects");
         System.Collections.Generic.List<TestProject> listProjects =
             TLAddinData.CurrentTestLinkConnection.GetProjects();
         
         cmdlet.WriteVerbose(cmdlet, "GetProjectCollection: outputting projects");
         cmdlet.WriteObject(cmdlet, listProjects);
         
         // 20130131
         if (null != listProjects && 0 < listProjects.Count) {
             cmdlet.WriteVerbose(cmdlet, "GetProjectCollection: settiing the current test project");
             TLAddinData.CurrentTestProject =
                 listProjects[listProjects.Count -1];
         }
     }
     catch (Exception eProjectCollection) {
         cmdlet.WriteError(
             cmdlet,
             "Unable to get the list of projects. " +
             eProjectCollection.Message,
             "UnableToGetProjects",
             ErrorCategory.InvalidResult,
             true);
     }
 }