Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to read my test cases from TFS server so that my framework would be connected to TFS. Also i want to version control of that documents.
Please provide me the right approach.
Any help is highly appreciated.

--
Thanks.
Posted

1 solution

You can get a version of a Work Item[^] and then look at the Attachments property that will get you a list of attachments associated with your WorkItem. You will require a reference to Microsoft.TeamFoundation.Client[^] and Microsoft.TeamFoundation.WorkItemTracking.Client[^]. A Code sample is below to get the Work Items.

C#
using (Microsoft.TeamFoundation.Client.TeamFoundationServer tfs = Microsoft.TeamFoundation.Client.TeamFoundationServerFactory.GetServer(uri))
{
    Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore wit = (Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore)tfs.GetService(typeof(Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore));

    Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemCollection result = wit.Query("SELECT * FROM WorkItems");
    foreach (Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem wi in result)
    {
        foreach (Microsoft.TeamFoundation.WorkItemTracking.Client.Attachment attachment in wi.Attachments)
        {
            //do something
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900