1
votes

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 ?

1
What state is it in at the moment, and is there a transition from that state to Ready or Design. You shouldn't use TestPointState, it's not for this use.DaveShaw

1 Answers

1
votes

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();