2013-09-23 6 views

답변

2

Conection에 필터를 만들 수 있습니다. 아래 예는 이름으로 검색을 테스트하지만 'TS_TEST_ID'에서 'TS_TEST_NAME'을 (를) 변경하면 테스트 ID를 사용하여 검색 할 수 있습니다.

public int findTestCase(TDAPIOLELib.TDConnection connection, string testCaseName) 
     { 
      TestFactory tstF = connection.TestFactory as TestFactory; 
      TDFilter testCaseFilter = tstF.Filter as TDFilter; 
      testCaseFilter["TS_TEST_NAME"] = testCaseName; 
      List testsList = tstF.NewList(testCaseFilter.Text); 
      if(testsList != null && testsList.Count == 1) 
      { 
       log.log("Test case " +testCaseName+ " was found "); 
       Test tmp = testsList[0] as Test; 
       return (int)tmp.ID; 
      } 

     return -1; 
    } 
+0

감사합니다 .... 답장을 보내 – yogikam78

5

당신이 열려있는 연결을하고 ID와 테스트가 존재 (이전 쿼리의 예를 들어 결과를) 알고 가정하면, 다음과 같은 작업을 수행 할 수

int testId = 1234; 
TestFactory tf = connection.TestFactory; 
Test t = tf[id]; 

TestFactory 인덱서에 대한 호출 "Item does not exist."와 함께 COMException을 발생시킵니다. 해당 ID가있는 테스트가없는 경우 해당 ID와 테스트가 존재하는 경우는 확실히 알 수없는 경우

, 당신은 다음을 수행 할 수 있습니다 답장을

int testId = 1234; 
TestFactory tf = connection.TestFactory; 
TDFilter filter = tf.Filter; 
filter["TS_TEST_ID"] = id.ToString(); 
List tests = tf.NewList(filter.Text); // List collection is the ALM List, not .NET BCL List. 
Test t = (tests.Count > 0) ? tests[1] : null; // ALM List collection indexes are 1-based, and test ID is guaranteed to be unique and only return 1 result if it exists. 
+0

감사합니다 .... – yogikam78