看来您想获取测试用例工作项的历史记录。您可以查看此博客以了解如何获取工作项修订列表并显示特定修订的字段:
第 1 步:连接到 TFS 并获取工作项存储
private void btnConnect_Click(object sender, RoutedEventArgs e)
{
TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.NoProject, false);
if (tpp.ShowDialog() != System.Windows.Forms.DialogResult.OK || tpp.SelectedTeamProjectCollection == null)
{
btnFetch.IsEnabled = txtWitId.IsEnabled = false;
return;
}
tfs = tpp.SelectedTeamProjectCollection;
store = new WorkItemStore(tfs, WorkItemStoreFlags.BypassRules);
btnFetch.IsEnabled = txtWitId.IsEnabled = true;
}
第 2 步:获取工作项历史记录
使用 WorkItemStore 对象,您可以获得工作项,工作项对象包含一个修订集合,允许您在工作项历史记录中导航。
<span class="kwrd">private</span> <span class="kwrd">void</span> FetchWorkItemHistory()
{
<span class="kwrd">if</span> (<span class="kwrd">string</span>.IsNullOrEmpty(txtWitId.Text)) <span class="kwrd">return</span>;
<span class="kwrd">if</span> (!<span class="kwrd">int</span>.TryParse(txtWitId.Text, <span class="kwrd">out</span> _workitemId)) <span class="kwrd">return</span>;
WorkItem wit = store.GetWorkItem(_workitemId);
listRevs.ItemsSource = wit.Revisions;
}
您还可以从特定版本中获取工作项:
WorkItem wit = store.GetWorkItem(_workitemId, rev.Index);