More tests and some fixes

This commit is contained in:
hns 2009-09-18 19:09:52 +00:00
parent e68e058e6a
commit 98aff5cd1a
5 changed files with 118 additions and 9 deletions

View file

@ -1,5 +1,9 @@
tests = [
'testSize'
'testSize',
'testContent',
'testGroupContent',
'testRemove',
'testAdd'
];
var org;
@ -38,6 +42,48 @@ function testSize() {
assertEqual(org.generic.size(), size);
}
function testContent() {
var list = org.generic.list();
assertEqual(list.length, size);
for (var i = 0; i < list.length; i++) {
assertEqual(list[i].name, "GenericPerson " + i.format("00"));
}
}
function testGroupContent() {
var list = org.groupedGeneric.list();
assertEqual(list.length, size);
for (var i = 0; i < list.length; i++) {
assertEqual(list[i].groupname, "GenericPerson " + i.format("00"));
assertEqual(list[i].size(), 1);
assertEqual(list[i].get(0).name, "GenericPerson " + i.format("00"));
}
}
function testRemove() {
var person = org.generic.get(size/2);
org.generic.removeChild(person);
assertEqual(org.generic.size(), size - 1);
res.rollback();
// note: removeChild does not remove the node, nor does it
// unset the constraints between parent and child, so after a rollback
// the object is back in place. While this behaviour is disputable,
// until this is so we test for it.
assertEqual(org.generic.size(), size);
}
function testAdd() {
var person = new Person();
org.generic.add(person);
assertEqual(org.generic.size(), size + 1);
assertEqual(org.groupedGeneric.size(), size);
res.commit();
// note: even after commit the grouped collection must not grow
// since we added a person without a name
assertEqual(org.generic.size(), size + 1);
assertEqual(org.groupedGeneric.size(), size);
}
function cleanup() {
var persons = org.generic.list();
for each (var person in persons) {