2010-10-07 103 views
1

在Quality Center OTA API中,如何從測試中刪除步驟。當我使用DesignStepFactory的RemoveItem方法刪除步驟,他們仍然 - 我已經試過雙方ID和步驟參考刪除:如何通過OTA API從質量中心的測試中刪除步驟

Test test = _qcAccess.AddTest(folderId); 
test.Name = "Test 1"; 
test.Post(); 

DesignStepFactory factory = (DesignStepFactory) test.DesignStepFactory; 
DesignStep step = (DesignStep)factory.AddItem(1); 
step.StepName = "Step1"; 
step.Post(); 

Test test2 = _qcAccess.FindExistingTest((int)test.ID); 
DesignStepFactory factory2 = (DesignStepFactory) test2.DesignStepFactory; 
Assert.Equal(1, test2.DesStepsNum); 

factory2.RemoveItem(factory2[0]); 
test2.Post(); 

Test test3= _qcAccess.FindExistingTest((int)test.ID); 
Assert.Equal(0, test3.DesStepsNum); // test fails here, DesStepsNumb is still 1 

按照OTA API文檔

RemoveItem方法

描述:從 數據庫中刪除項目。立即刪除 ,沒有帖子。

語法:

公用Sub的removeItem(BYVAL的ItemKey作爲變型)

的ItemKey:

的Step.ID(長),到 步驟對象或參考 Step.IDs.Step.IDs的變體數組。

所以它看起來應該工作。僅供參考,用於QC10。

有什麼想法?

回答

0

修復是使用List(「」)來檢索步驟列表,它使用工廠上的索引訪問器返回無效步驟實例,其中ID只是元素的索引,並且所有屬性都是空值。

Test test = _qcAccess.AddTest(folderId); 
test.Name = "Test 1"; 
test.Post(); 

DesignStepFactory factory = (DesignStepFactory) test.DesignStepFactory; 
DesignStep step = (DesignStep)factory.AddItem(1); 
step.StepName = "Step1"; 
step.Post(); 
test.Post(); 

Test test2 = _qcAccess.FindExistingTest((int)test.ID); 
DesignStepFactory factory2 = (DesignStepFactory)test2.DesignStepFactory; 
Assert.Equal(1, test2.DesStepsNum); 

var list = factory2.NewList(""); // get a list 
factory2.RemoveItem(list[1]); // note: list indexing starts at 1 (ugh!) 
test2.Post(); 

Test test3 = _qcAccess.FindExistingTest((int)test.ID); 
Assert.Equal(0, test3.DesStepsNum); 
相關問題