Reputation: 2078
I am trying to set State
property value of Test Case Work item. I am creating using TFS API and C# code.
It throws an error while I save the test case using Save()
method. I have called the Validate()
method of a work item and the ArrayList
shows the value I am trying to assign is an invalid state.
testCase.State = TestPointState.Ready.ToString();
ArrayList result = testCase.WorkItem.Validate();
if (!testCase.WorkItem.IsValid())
{
//this block executes
}
When I manually opened the MTM to see what are the different STATE values for existing work items, then I found READY
and DESIGN
. That's why I tried t assign TestPointState.Ready
enum. I tried assiging READY
string directly in that statement, but still the same exception whlie saving the test case.
Any idea on how to fix this issue ?
Upvotes: 1
Views: 835
Reputation: 605
It is possible that when setting the state another field has then an invalid input. e.g.: when you change from Ready to Design it might require that you select who the AssignTo person is and so you'll need to populate these fields as well. You can use the Validate method to get a list of invalid fields after you set the state like below.
ArrayList invalidFields = newWI.Validate();
Upvotes: 1