Источник:
http://gatesasbait.spaces.live.com/B...B9F5!203.entry
==============
Good afternoon,
I use the following code when coding test cases. It allows me to create records, and delete them without having to manage every one separately. Inside my *test methods, I put the following set declaration and nested methods (I make sure to call deleteAll() even if an error was thrown during code execution):
X++:
public void aTestMethodTest()
{
Set recSet = new Set(Types::Container);
void insert(Common _common)
{
_common.doInsert();
recSet.add([_common.TableId, _common.RecId]);
}
void deleteAll()
{
SetEnumerator setEnum = recSet.getEnumerator();
SysDictTable sysDictTable;
Common temp;
RecId recId;
TableId tableId;
while (setEnum.moveNext())
{
[tableId, recId] = setEnum.current();
sysDictTable = new SysDictTable(tableId);
temp = sysDictTable.makeRecord();
select firstonly forupdate RecId
from temp
where temp.RecId == recId;
ttsbegin;
temp.doDelete();
ttscommit;
}
}
;
//(...) actual test case test code here
}
Источник:
http://gatesasbait.spaces.live.com/B...B9F5!203.entry