2010-10-07 62 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);