Search in sources :

Example 6 with Product

use of com.litepaltest.model.Product in project LitePal by LitePalFramework.

the class SaveTest method testSaveFastWithConstructors.

public void testSaveFastWithConstructors() {
    Computer computer = new Computer("asus", 699.00);
    assertTrue(computer.saveFast());
    Assert.assertTrue(isDataExists(getTableName(computer), computer.getId()));
    Computer c = getComputer(computer.getId());
    assertEquals("asus", c.getBrand());
    assertEquals(699.00, c.getPrice());
    Computer cc = DataSupport.find(Computer.class, computer.getId());
    assertEquals("asus", cc.getBrand());
    assertEquals(699.00, cc.getPrice());
    Product p = new Product(null);
    p.setBrand("apple");
    p.setPrice(1222.33);
    p.saveFast();
    Product.find(Product.class, p.getId());
}
Also used : Computer(com.litepaltest.model.Computer) Product(com.litepaltest.model.Product)

Example 7 with Product

use of com.litepaltest.model.Product in project LitePal by LitePalFramework.

the class SaveTest method testSaveWithBlob.

public void testSaveWithBlob() {
    byte[] b = new byte[10];
    for (int i = 0; i < b.length; i++) {
        b[i] = (byte) i;
    }
    Product product = new Product();
    product.setBrand("Android");
    product.setPrice(2899.69);
    product.setPic(b);
    assertTrue(product.saveFast());
    Product p = DataSupport.find(Product.class, product.getId());
    byte[] pic = p.getPic();
    assertEquals(b.length, pic.length);
    for (int i = 0; i < b.length; i++) {
        assertEquals(i, pic[i]);
    }
}
Also used : Product(com.litepaltest.model.Product)

Aggregations

Product (com.litepaltest.model.Product)7 Computer (com.litepaltest.model.Computer)3 ContentValues (android.content.ContentValues)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 Classroom (com.litepaltest.model.Classroom)1 Headset (com.litepaltest.model.Headset)1 LitePalDB (org.litepal.LitePalDB)1