Android Open Source - FruitBasket Generated Dao Test






From Project

Back to project page FruitBasket.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project FruitBasket listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package jp.co.icomsys.it21.fruitbasket;
// w ww.  j a v a 2s . c om
import android.app.Activity;
import android.database.sqlite.SQLiteDatabase;

import junit.framework.Assert;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import jp.co.icomsys.it21.fruitbasket.dao.BookTitlesDao;
import jp.co.icomsys.it21.fruitbasket.dao.DaoMaster;
import jp.co.icomsys.it21.fruitbasket.dao.DaoSession;

/**
 * ?????Dao?????????????
 *
 * Created by masaharu on 14/12/17.
 */

@Config(emulateSdk = 18, manifest = "src/main/AndroidManifest.xml")
@RunWith(RobolectricTestRunner.class)
public class GeneratedDaoTest {

    Activity activity;
    DaoMaster.DevOpenHelper helper;
    SQLiteDatabase db;

    @Before
    public void setup() {
        activity = Robolectric.buildActivity(FBBookListActivity.class).create().get();
        helper = new DaoMaster.DevOpenHelper(activity, "fruitbasket-db", null);
        db = helper.getWritableDatabase();
    }

    @After
    public void teardrop() {
        if( db!=null ) db.close();
    }

    @Test
    public void daoTest1() {
        Assert.assertTrue(Boolean.TRUE);

        DaoMaster master = new DaoMaster(db);
        DaoSession session = master.newSession();
        BookTitlesDao bookTitleDao = session.getBookTitlesDao();
        Assert.assertEquals(bookTitleDao.count(), 0);
        System.out.println(bookTitleDao.count());
    }
}




Java Source Code List

jp.co.icomsys.it21.fruitbasket.ApplicationTest.java
jp.co.icomsys.it21.fruitbasket.FBBookListActivity.java
jp.co.icomsys.it21.fruitbasket.GeneratedDaoTest.java
jp.co.icomsys.it21.fruitbasket.NavigationDrawerFragment.java