I'm trying to update the area of a test case programatically.
The code I have seems logical, but fails with:
An unhandled exception of type 'Microsoft.TeamFoundation.WorkItemTracking.Client.ValidationException' occurred in Microsoft.TeamFoundation.WorkItemTracking.Client.dll
Additional information: TF400276: You have tried to set a value for a field of a work item which is not opened or partial opened. You cannot set a value for a field of a work item which is not opened or partial opened.
Here is the code:
private static void Main(string[] args)
{
TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false);
tpp.ShowDialog();
var tc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(
tfsUri,
new UICredentialsProvider());
tc.EnsureAuthenticated();
var wiStore = tc.GetService<TestManagementService>();
var project = wiStore.GetTeamProject(tpp.SelectedProjects[0].Name);
SetAreaPathByTestSuiteID(project, 501);
}
private static void SetAreaPathByTestSuiteID(ITestManagementTeamProject project, int testSuiteID)
{
var testSuite = project.TestSuites.Find(testSuiteID).TestCases;
foreach (ITestSuiteEntry entry in testSuite)
{
ITestCase theCase = entry.TestCase;
theCase.Area = "NewAreaPath"; //Error thrown here
theCase.Save();
}
}