krabcore krabcore - 3 months ago 18
C# Question

How to change the value of CustomFields in Test-Case TFS API 2013?

I'm trying to make a utility for working with TFS and I get some values from testcases:

entrie.TestCase.CustomFields["IsReference"].Value,
entrie.TestCase.CustomFields["Microsoft.VSTS.TCM.AutomationStatus"].Value,
entrie.TestCase.CustomFields["TestType"].Value
///...


i show this values to the user, and after that i want to change this values. I tried:

testCase.CustomFields["Microsoft.VSTS.TCM.AutomationStatus"] = item.Value; // Error: The indexer has no setter
testCase.Priority = item.Value; // OK


How to change
CustomFields
in test-case with tfs api?

Answer

CustomFields is a FieldCollection who's indexer has no setter, however the indexer return a Field who's property Value has one

Just change:

testCase.CustomFields["Microsoft.VSTS.TCM.AutomationStatus"] = item.Value;

to:

testCase.CustomFields["Microsoft.VSTS.TCM.AutomationStatus"].Value = item.Value;
Comments