I think the TFS API has a bug in it, here I'll try and demonstrate:
Using a team project object like this:
ITestManagementTeamProject project
I can get direct access to the test case like this:
var testCase = project.TestCases.Find(testCaseId);
If the test case is accessed in this way then:
testCase.ParentTestSuite // will always be null
BUT
If I access the test case from the test suite like this:
var testSuite = project.TestSuites.Find(testSuiteId);
foreach (var test in testSuite.TestCases)
{
var check = test.ParentTestSuite; // ParentTestSuite is populated
}
Is it just me, or is there a bug here?
EDIT: For clarification in both cases the same objects are being used and returned.