示例#1
0
        public static void ConnectTFServer(TFSCmdletBase cmdlet, string url, ICredentials credentials)
        {
            try
            {
                Uri uri =
                    new Uri(url);
                
                TfsConfigurationServer tfsServer =
                    new TfsConfigurationServer(
                        uri,
                        credentials);
                
                cmdlet.WriteVerbose(
                    cmdlet,
                    "Connected, checking the connection");
                
                try {
                    tfsServer.EnsureAuthenticated();
                }
                catch (Exception eTfsServerConnected) {
                    
                    cmdlet.WriteError(
                        cmdlet,
                        "Failed to connect to server '" +
                        url +
                        "'." +
                        eTfsServerConnected.Message,
                        "FailedToConnect",
                        ErrorCategory.InvalidResult,
                        true);
                }
                
                CurrentData.CurrentServer = tfsServer;
                
                cmdlet.WriteVerbose(cmdlet,
                                    "Connected to: '" +
                                    url + 
                                    "'");
                
                cmdlet.WriteObject(cmdlet, tfsServer);
            }
//            catch (TeamFoundationServerUnauthorizedException ex)
//            {
//                // handle access denied
//            }
//            catch (TeamFoundationServiceUnavailableException ex)
//            {
//                // handle service unavailable
//            }
            catch (WebException ex)
            {
                // handle other web exception
            }
        }
示例#2
0
        public static void OpenProject(TFSCmdletBase cmdlet, string[] projectNames)
        {
            string currentProjectName = string.Empty;

            try {
                if (null != projectNames && 0 < projectNames.Length)
                {
                    foreach (string projectName in projectNames)
                    {
                        currentProjectName = projectName;

                        ITestManagementService testMgmtSvc =
                            (ITestManagementService)CurrentData.CurrentCollection.GetService(typeof(ITestManagementService));

                        WorkItemStore store =
                            (WorkItemStore)CurrentData.CurrentCollection.GetService(typeof(WorkItemStore));

                        ITestManagementTeamProject project =
                            testMgmtSvc.GetTeamProject(projectName);

                        cmdlet.WriteVerbose(
                            cmdlet,
                            "Connected to the project '" +
                            projectNames +
                            "'");

                        CurrentData.CurrentProject = project;

                        cmdlet.WriteObject(cmdlet, project);
                    }
                }
                else
                {
                    cmdlet.WriteError(
                        cmdlet,
                        "A wrong name or names were provided for project search",
                        "WrongProjectName",
                        ErrorCategory.InvalidArgument,
                        true);
                }
            }
            catch (Exception eOpenProject) {
                cmdlet.WriteError(
                    cmdlet,
                    "Failed to connect to project '" +
                    currentProjectName +
                    "'." +
                    eOpenProject.Message,
                    "FailedToConnect",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
示例#3
0
        public static void ConnectTFServer(TFSCmdletBase cmdlet, string url, ICredentials credentials)
        {
            try
            {
                Uri uri =
                    new Uri(url);

                TfsConfigurationServer tfsServer =
                    new TfsConfigurationServer(
                        uri,
                        credentials);

                cmdlet.WriteVerbose(
                    cmdlet,
                    "Connected, checking the connection");

                try {
                    tfsServer.EnsureAuthenticated();
                }
                catch (Exception eTfsServerConnected) {
                    cmdlet.WriteError(
                        cmdlet,
                        "Failed to connect to server '" +
                        url +
                        "'." +
                        eTfsServerConnected.Message,
                        "FailedToConnect",
                        ErrorCategory.InvalidResult,
                        true);
                }

                CurrentData.CurrentServer = tfsServer;

                cmdlet.WriteVerbose(cmdlet,
                                    "Connected to: '" +
                                    url +
                                    "'");

                cmdlet.WriteObject(cmdlet, tfsServer);
            }
//            catch (TeamFoundationServerUnauthorizedException ex)
//            {
//                // handle access denied
//            }
//            catch (TeamFoundationServiceUnavailableException ex)
//            {
//                // handle service unavailable
//            }
            catch (WebException ex)
            {
                // handle other web exception
            }
        }
示例#4
0
        public static void NewTestPlan(TFSCmdletBase cmdlet, string name)
        {
            try {
                ITestPlan testPlan =
                    CurrentData.CurrentProject.TestPlans.Create();
                testPlan.Name = name;
                testPlan.Save();

                CurrentData.CurrentTestPlan = testPlan;

                cmdlet.WriteObject(cmdlet, testPlan);
            }
            catch (Exception eNewTestPlan) {
                Console.WriteLine(eNewTestPlan.Message);
            }
        }
示例#5
0
        public static void NewBuild(TFSCmdletBase cmdlet, string name)
        {
            try {
                // 20131102
                // ReSharper warning
                //IBuildDefinition buildDefinition;

                BuildTypeInfo buildInfo = new Microsoft.TeamFoundation.Build.Common.BuildTypeInfo("1.2.3");

//                IBuildDefinition buildDefinition =
//                    CurrentData.CurrentServer.
//                //var buildDefinition = (IBuildDefinition)listAddDefinitionBuildDefinitions.SelectedItem;
//                IBuildDetail buildDetail = buildDefinition.CreateManualBuild(txtBuildName.Text);
//                IBuildProjectNode buildProjectNode = buildDetail.Information.AddBuildProjectNode(
//                DateTime.Now.AddSeconds(10),            // Finish Time = The time at which the project finished building.
//                comboFlavor.SelectedValue.ToString(),   //Flavor = The flavor (configuration) the project was built for.
//                txtLocalPath.Text,                      //Local Path = The local path of the project file.
//                comboPlatform.SelectedValue.ToString(), //Platform = The platform the project was built for.
//                txtServerPath.Text,                     // Server Path = The server path of the project file.
//                DateTime.Now,                           //Start Time = The time at which the project was built.
//                "default");                             //Target Name = The targets for which the project was built.
//                buildProjectNode.Save();
//                buildDetail.FinalizeStatus((BuildStatus)comboBuildStatus.SelectedItem);
//                ClearAddBuildForm();
//
//                ITestPlan testPlan =
//                    CurrentData.CurrentProject.TestPlans.Create();
//                testPlan.Name = name;
//                testPlan.Save();
//
//                CurrentData.CurrentTestPlan = testPlan;
//
//                cmdlet.WriteObject(cmdlet, testPlan);
            }
            catch (Exception eNewTestPlan) {
                Console.WriteLine(eNewTestPlan.Message);
            }
        }
示例#6
0
 public static void OpenTestCase(TFSCmdletBase cmdlet, string name)
 {
     throw new NotImplementedException();
 }
示例#7
0
 internal TFSrvNewTestPlanCommand(TFSCmdletBase cmdlet) : base(cmdlet)
 {
 }
示例#8
0
 internal TFSrvAddTestSuiteCommand(TFSCmdletBase cmdlet) : base(cmdlet)
 {
 }
 internal TFSrvGetTestSuiteCommand(TFSCmdletBase cmdlet) : base (cmdlet)
 {
 }
示例#10
0
 internal TFSrvConnectCommand(TFSCmdletBase cmdlet) : base(cmdlet)
 {
 }
示例#11
0
 internal TFSrvConnectCommand(TFSCmdletBase cmdlet) : base (cmdlet)
 {
 }
示例#12
0
 internal TFSrvGetTestCaseCommand(TFSCmdletBase cmdlet) : base(cmdlet)
 {
 }
示例#13
0
 public static ITestPlan OpenTestPlan(TFSCmdletBase cmdlet, string name)
 {
     throw new NotImplementedException();
 }
示例#14
0
        public static void OpenProjectCollection(TFSCmdletBase cmdlet, string[] collectionNames)
        {
            try
            {
                if (null != collectionNames && 0 < collectionNames.Length) {
                    
                    foreach (string collectionName in collectionNames) {
                        
                        var projectCollectionUri =
                            new Uri(
                                CurrentData.CurrentServer.Uri.OriginalString +
                                "/" +
                                collectionName);
                        
                        cmdlet.WriteVerbose(
                            cmdlet,
                            "connecing to the collection: '" +
                            projectCollectionUri.ToString() +
                            "'");
                        
                        var projectCollection =
                            TfsTeamProjectCollectionFactory.GetTeamProjectCollection(projectCollectionUri);
                        
                        cmdlet.WriteVerbose(
                            cmdlet,
                            "Collection is connected, checking the connection");
                        
                        try {
                            projectCollection.EnsureAuthenticated();
                        }
                        catch (Exception eTfsCollectionConnected) {
                            
                            cmdlet.WriteError(
                                cmdlet,
                                "Failed to connect to collection '" +
                                projectCollectionUri.ToString() +
                                "'." +
                                eTfsCollectionConnected.Message,
                                "FailedToConnect",
                                ErrorCategory.InvalidResult,
                                true);
                        }
                        
                        cmdlet.WriteVerbose(cmdlet, "connected to the collection");
                        
                        CurrentData.CurrentCollection = projectCollection;
                        
                        cmdlet.WriteObject(cmdlet, projectCollection);
                    }
                
                } else {
                    
                    cmdlet.WriteError(
                        cmdlet,
                        "A wrong name or names were provided for collection search",
                        "WrongCollectionName",
                        ErrorCategory.InvalidArgument,
                        true);
                    
                }
            }
//            catch (TeamFoundationServerUnauthorizedException ex)
//            {
//                // handle access denied
//            }
//            catch (TeamFoundationServiceUnavailableException ex)
//            {
//                // handle service unavailable
//            }
            catch (WebException ex)
            {
                // handle other web exception
            }
            
        }
示例#15
0
 public static IStaticTestSuite OpenTesSuite(TFSCmdletBase cmdlet, string name)
 {
     throw new NotImplementedException();
 }
示例#16
0
 public static void OpenTestCase(TFSCmdletBase cmdlet, string name)
 {
     throw new NotImplementedException();
 }
示例#17
0
 public static void GetTestSubSuite(TFSCmdletBase cmdlet, string name)
 {
     throw new NotImplementedException();
 }
示例#18
0
 public static IStaticTestSuite OpenTesSuite(TFSCmdletBase cmdlet, string name)
 {
     throw new NotImplementedException();
 }
示例#19
0
        public static void AddTestSuite(TFSCmdletBase cmdlet, string name)
        {
            //throw new NotImplementedException();
            try {
                //CurrentData.CurrentProject.TestPlans.
                //ITestSuiteEntry testSuite =
//                ITestSuiteBase testSuite =
//                    new stat
//                    CurrentData.CurrentTestPlan.RootSuite.Entries.Add("asdf");

//                string[] areas = full_area.Split('\\');
//                string full_path = string.Empty;
                IStaticTestSuite suite =// null;
                                         CurrentData.CurrentProject.TestSuites.CreateStatic();
//                string current_area = string.Empty;

                suite.Title = name;
                //CurrentData.CurrentTestPlan.RootSuite.Entries.Add(suite);
                //ITestSuiteEntryCollection suites =
                //var suites =

                //CurrentData.CurrentTestPlan.RootSuite.Entries.Add(suite);


//                for (int i = 0; i < areas.Length; i++)
//                {
//                    if (!string.IsNullOrEmpty(areas[i]))
//                    {
//                        string area = areas[i].RemoveBadChars();
//                        current_area += area;
//
//                        //The first item, find it and assigned to suite object.
//                        if (i == 1)
//                        {
//                            ITestSuiteEntryCollection collection = CurrentData.CurrentTestPlan.RootSuite.Entries;
//                            suite = TestHelper.FindSuite(collection, area);
//                            if (suite.Id == 0)
//                            {
//                                suite.Title = area;
//                                TestHelper.AddTests(suite, current_area);
//                                CurrentData.CurrentTestPlan.RootSuite.Entries.Add(suite);
//                            }
//                        }
//                        else
//                        {
//                            ITestSuiteEntryCollection collection = suite.Entries;
//                            //* collection - Perform search only under the suite.Entries  - Duplicate items allowed.
//                            IStaticTestSuite subSuite = TestHelper.FindSuite(collection, area);
//
//                            if (subSuite.Id == 0)
//                            {//Cannot find Test Suite
//                                subSuite.Title = area;
//                                suite.Entries.Add(subSuite);
//                                //After creating the Test Suite - Add the related TestCases based on the Area Path.
//                                TestHelper.AddTests(subSuite, current_area);
//                            }
//
//                            suite = subSuite;
//                        }
//                        current_area += "\\";
//                        CurrentData.CurrentTestPlan.Save();
//                    }
//                }
                CurrentData.CurrentTestPlan.Save();
            }
            catch (Exception eAddTestSuite) {
                Console.WriteLine(eAddTestSuite.Message);
            }
        }
示例#20
0
 public static void GetTestSubSuite(TFSCmdletBase cmdlet, string name)
 {
     throw new NotImplementedException();
 }
示例#21
0
        public static void OpenProjectCollection(TFSCmdletBase cmdlet, string[] collectionNames)
        {
            try
            {
                if (null != collectionNames && 0 < collectionNames.Length)
                {
                    foreach (string collectionName in collectionNames)
                    {
                        var projectCollectionUri =
                            new Uri(
                                CurrentData.CurrentServer.Uri.OriginalString +
                                "/" +
                                collectionName);

                        cmdlet.WriteVerbose(
                            cmdlet,
                            "connecing to the collection: '" +
                            projectCollectionUri.ToString() +
                            "'");

                        var projectCollection =
                            TfsTeamProjectCollectionFactory.GetTeamProjectCollection(projectCollectionUri);

                        cmdlet.WriteVerbose(
                            cmdlet,
                            "Collection is connected, checking the connection");

                        try {
                            projectCollection.EnsureAuthenticated();
                        }
                        catch (Exception eTfsCollectionConnected) {
                            cmdlet.WriteError(
                                cmdlet,
                                "Failed to connect to collection '" +
                                projectCollectionUri.ToString() +
                                "'." +
                                eTfsCollectionConnected.Message,
                                "FailedToConnect",
                                ErrorCategory.InvalidResult,
                                true);
                        }

                        cmdlet.WriteVerbose(cmdlet, "connected to the collection");

                        CurrentData.CurrentCollection = projectCollection;

                        cmdlet.WriteObject(cmdlet, projectCollection);
                    }
                }
                else
                {
                    cmdlet.WriteError(
                        cmdlet,
                        "A wrong name or names were provided for collection search",
                        "WrongCollectionName",
                        ErrorCategory.InvalidArgument,
                        true);
                }
            }
//            catch (TeamFoundationServerUnauthorizedException ex)
//            {
//                // handle access denied
//            }
//            catch (TeamFoundationServiceUnavailableException ex)
//            {
//                // handle service unavailable
//            }
            catch (WebException ex)
            {
                // handle other web exception
            }
        }
示例#22
0
        public static void NewBuild(TFSCmdletBase cmdlet, string name)
        {
            try {

                // 20131102
                // ReSharper warning
                //IBuildDefinition buildDefinition;

                BuildTypeInfo buildInfo = new Microsoft.TeamFoundation.Build.Common.BuildTypeInfo("1.2.3");
                
//                IBuildDefinition buildDefinition =
//                    CurrentData.CurrentServer.
//                //var buildDefinition = (IBuildDefinition)listAddDefinitionBuildDefinitions.SelectedItem;    
//                IBuildDetail buildDetail = buildDefinition.CreateManualBuild(txtBuildName.Text); 
//                IBuildProjectNode buildProjectNode = buildDetail.Information.AddBuildProjectNode(   
//                DateTime.Now.AddSeconds(10),            // Finish Time = The time at which the project finished building.  
//                comboFlavor.SelectedValue.ToString(),   //Flavor = The flavor (configuration) the project was built for.  
//                txtLocalPath.Text,                      //Local Path = The local path of the project file.            
//                comboPlatform.SelectedValue.ToString(), //Platform = The platform the project was built for.           
//                txtServerPath.Text,                     // Server Path = The server path of the project file.            
//                DateTime.Now,                           //Start Time = The time at which the project was built.          
//                "default");                             //Target Name = The targets for which the project was built.    
//                buildProjectNode.Save();        
//                buildDetail.FinalizeStatus((BuildStatus)comboBuildStatus.SelectedItem); 
//                ClearAddBuildForm();  
//                
//                ITestPlan testPlan =
//                    CurrentData.CurrentProject.TestPlans.Create();
//                testPlan.Name = name;
//                testPlan.Save();
//                
//                CurrentData.CurrentTestPlan = testPlan;
//                
//                cmdlet.WriteObject(cmdlet, testPlan);
                
            }
            catch (Exception eNewTestPlan) {
                Console.WriteLine(eNewTestPlan.Message);
            }
        }
示例#23
0
 internal TFSrvGetProjectCommand(TFSCmdletBase cmdlet) : base (cmdlet)
 {
 }
 internal TFSrvAddTestSubSuiteCommand(TFSCmdletBase cmdlet) : base (cmdlet)
 {
 }
示例#25
0
 internal TFSrvCommand(TFSCmdletBase cmdlet)
 {
     this.Cmdlet = cmdlet;
 }
 internal TFSrvGetCollectionCommand(TFSCmdletBase cmdlet) : base (cmdlet)
 {
 }
 internal TFSrvGetCollectionCommand(TFSCmdletBase cmdlet) : base(cmdlet)
 {
 }
示例#28
0
 internal TFSrvCommand(TFSCmdletBase cmdlet)
 {
     this.Cmdlet = cmdlet;
 }
示例#29
0
        public static void OpenProject(TFSCmdletBase cmdlet, string[] projectNames)
        {

            string currentProjectName = string.Empty;
            
            try {
                
                if (null != projectNames && 0 < projectNames.Length) {
                    
                    foreach (string projectName in projectNames) {
                        
                        currentProjectName = projectName;
                        
                        ITestManagementService testMgmtSvc =
                            (ITestManagementService)CurrentData.CurrentCollection.GetService(typeof(ITestManagementService));
        
                        WorkItemStore store =
                            (WorkItemStore)CurrentData.CurrentCollection.GetService(typeof(WorkItemStore));
        
                        ITestManagementTeamProject project =
                            testMgmtSvc.GetTeamProject(projectName);
                        
                        cmdlet.WriteVerbose(
                            cmdlet,
                            "Connected to the project '" +
                            projectNames +
                            "'");
                        
                        CurrentData.CurrentProject = project;
                        
                        cmdlet.WriteObject(cmdlet, project);
                        
                    }
                    
                } else {
                    
                    cmdlet.WriteError(
                        cmdlet,
                        "A wrong name or names were provided for project search",
                        "WrongProjectName",
                        ErrorCategory.InvalidArgument,
                        true);
                        
                    
                }
            }
            catch (Exception eOpenProject) {
                
                cmdlet.WriteError(
                    cmdlet,
                    "Failed to connect to project '" +
                    currentProjectName +
                    "'." +
                    eOpenProject.Message,
                    "FailedToConnect",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
示例#30
0
 internal TFSrvGetProjectCommand(TFSCmdletBase cmdlet) : base(cmdlet)
 {
 }
示例#31
0
 public static void NewTestPlan(TFSCmdletBase cmdlet, string name)
 {
     try {
         ITestPlan testPlan =
             CurrentData.CurrentProject.TestPlans.Create();
         testPlan.Name = name;
         testPlan.Save();
         
         CurrentData.CurrentTestPlan = testPlan;
         
         cmdlet.WriteObject(cmdlet, testPlan);
         
     }
     catch (Exception eNewTestPlan) {
         Console.WriteLine(eNewTestPlan.Message);
     }
 }
示例#32
0
 internal TFSrvNewBuildCommand(TFSCmdletBase cmdlet) : base (cmdlet)
 {
 }
示例#33
0
 public static ITestPlan OpenTestPlan(TFSCmdletBase cmdlet, string name)
 {
     throw new NotImplementedException();
 }
 internal TFSrvNewTestPlanCommand(TFSCmdletBase cmdlet) : base (cmdlet)
 {
 }
示例#35
0
        public static void AddTestSuite(TFSCmdletBase cmdlet, string name)
        {
            //throw new NotImplementedException();
            try {
                //CurrentData.CurrentProject.TestPlans.
                //ITestSuiteEntry testSuite =
//                ITestSuiteBase testSuite =
//                    new stat
//                    CurrentData.CurrentTestPlan.RootSuite.Entries.Add("asdf");

//                string[] areas = full_area.Split('\\');
//                string full_path = string.Empty;
                IStaticTestSuite suite =// null;
                    CurrentData.CurrentProject.TestSuites.CreateStatic();
//                string current_area = string.Empty;
                
                suite.Title = name;
                //CurrentData.CurrentTestPlan.RootSuite.Entries.Add(suite);
                //ITestSuiteEntryCollection suites =
                //var suites =
                
                //CurrentData.CurrentTestPlan.RootSuite.Entries.Add(suite);
                

//                for (int i = 0; i < areas.Length; i++)
//                {
//                    if (!string.IsNullOrEmpty(areas[i]))
//                    {
//                        string area = areas[i].RemoveBadChars();
//                        current_area += area;
//
//                        //The first item, find it and assigned to suite object.
//                        if (i == 1)
//                        {
//                            ITestSuiteEntryCollection collection = CurrentData.CurrentTestPlan.RootSuite.Entries;
//                            suite = TestHelper.FindSuite(collection, area);
//                            if (suite.Id == 0)
//                            {
//                                suite.Title = area;
//                                TestHelper.AddTests(suite, current_area);
//                                CurrentData.CurrentTestPlan.RootSuite.Entries.Add(suite);
//                            }
//                        }
//                        else
//                        {
//                            ITestSuiteEntryCollection collection = suite.Entries;
//                            //* collection - Perform search only under the suite.Entries  - Duplicate items allowed. 
//                            IStaticTestSuite subSuite = TestHelper.FindSuite(collection, area);
//
//                            if (subSuite.Id == 0)
//                            {//Cannot find Test Suite
//                                subSuite.Title = area;
//                                suite.Entries.Add(subSuite);
//                                //After creating the Test Suite - Add the related TestCases based on the Area Path.
//                                TestHelper.AddTests(subSuite, current_area);
//                            }
//
//                            suite = subSuite;
//                        }
//                        current_area += "\\";
//                        CurrentData.CurrentTestPlan.Save();
//                    }
//                }
                CurrentData.CurrentTestPlan.Save();
                    
            }
            catch (Exception eAddTestSuite) {
                Console.WriteLine(eAddTestSuite.Message);
            }
        }
示例#36
0
 internal TFSrvNewBuildCommand(TFSCmdletBase cmdlet) : base(cmdlet)
 {
 }
 internal TFSrvAddTestCaseCommand(TFSCmdletBase cmdlet) : base (cmdlet)
 {
 }