use of com.orm.androrm.impl.Brand in project androrm by androrm.
the class OneToManyFieldTest method testReset.
public void testReset() {
Brand b = new Brand();
b.setName("Copcal");
b.save(getContext());
Branch b1 = new Branch();
b1.setName("test1");
b1.setBrand(b);
b1.save(getContext());
Branch b2 = new Branch();
b2.setName("test2");
b2.setBrand(b);
b2.save(getContext());
Product p = new Product();
p.addBranches(Arrays.asList(new Branch[] { b1, b2 }));
p.save(getContext());
assertEquals(2, p.getBranches(getContext()).count());
p.delete(getContext());
assertEquals(0, p.getBranches(getContext()).count());
}
use of com.orm.androrm.impl.Brand in project androrm by androrm.
the class OneToManyFieldTest method testCount.
public void testCount() {
Brand b = new Brand();
b.setName("Copcal");
b.save(getContext());
Branch b1 = new Branch();
b1.setName("test1");
b1.setBrand(b);
b1.save(getContext());
Branch b2 = new Branch();
b2.setName("test2");
b2.setBrand(b);
b2.save(getContext());
b = Brand.objects(getContext()).get(b.getId());
assertEquals(2, b.branchCount(getContext()));
}
use of com.orm.androrm.impl.Brand in project androrm by androrm.
the class QuerySetTest method setUp.
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(Product.class);
models.add(Branch.class);
models.add(Supplier.class);
models.add(Brand.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
Brand b = new Brand();
b.setName("Copcal");
b.save(getContext());
// ID 1
Branch b1 = new Branch();
b1.setName("Cashbuild Pretoria");
b1.setBrand(b);
b1.save(getContext());
// ID 2
Branch b2 = new Branch();
b2.setName("Plumblink Pretoria");
b2.setBrand(b);
b2.save(getContext());
// ID 3
Branch b3 = new Branch();
b3.setName("The third Branch");
b3.setBrand(b);
b3.save(getContext());
}
use of com.orm.androrm.impl.Brand in project androrm by androrm.
the class ForeignKeyFieldTest method testDoNotCascade.
public void testDoNotCascade() {
Brand b = new Brand();
b.setName("Copcal");
b.save(getContext());
Supplier s = new Supplier();
s.setName("test_supplier");
s.setBrand(b);
s.save(getContext());
b.delete(getContext());
assertEquals(1, Supplier.objects(getContext()).count());
}
use of com.orm.androrm.impl.Brand in project androrm by androrm.
the class ForeignKeyFieldTest method testDoCascade.
public void testDoCascade() {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ECLAIR_MR1) {
return;
}
Brand b = new Brand();
b.setName("Copcal");
b.save(getContext());
Branch br = new Branch();
br.setBrand(b);
br.setName("Pretoria");
br.save(getContext());
b.delete(getContext());
assertEquals(0, Branch.objects(getContext()).count());
}