// Path: app/src/main/java/net/kb/test/bean/UserModel.java
// @Table(database = DBFlowDatabase.class)
// public class UserModel extends BaseModel {
//     //自增ID
//     @Column
//     @PrimaryKey(autoincrement = true)
//     public Long   id;
//     @Column
//     public String name;
//     @Column
//     public int    sex;
// 
//     public String getName() {
//         return name;
//     }
// 
//     public int getSex() {
//         return sex;
//     }
// }
// 
// Path: library/src/main/java/net/kb/test/library/testCase/DbFlowCase.java
// public class DbFlowCase extends KBCase {
// 
//     @Rule
//     public ExternalResource innerRule = new ExternalResource() {
//         @Override
//         protected void before() throws Throwable {
//             DbFlowUtils.destroy();
//         }
// 
//         @Override
//         protected void after() {
//             DbFlowUtils.destroy();
//         }
//     };
// }


import com.raizlabs.android.dbflow.config.FlowConfig;
import com.raizlabs.android.dbflow.config.FlowManager;
import com.raizlabs.android.dbflow.sql.language.Delete;
import com.raizlabs.android.dbflow.sql.language.Method;
import com.raizlabs.android.dbflow.sql.language.SQLite;
import com.raizlabs.android.dbflow.sql.language.Select;
import net.kb.test.bean.UserModel;
import net.kb.test.bean.UserModel_Table;
import net.kb.test.library.testCase.DbFlowCase;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.Random;
package net.kb.test.dbflow;





/**
 * Created by kkmike999 on 2017/06/12.
 */
public class DbFlowTest extends DbFlowCase {

    @Before
    public void setUp() throws Exception {
        FlowManager.init(new FlowConfig.Builder(getApplication()).build());

        Assert.assertEquals(0, new Select(Method.count()).from(UserModel.class).count());
    }

    @Test
    public void onInsert() {
        UserModel people = new UserModel();

        people.name = "张三";
        people.sex = 1;
        people.save();// 添加对象，一条一条保存

        Assert.assertEquals(1, new Select(Method.count()).from(UserModel.class).count());
    }

    @Test
    public void onDelete() {
        save("张三");

        new Delete().from(UserModel.class)
                    .where(UserModel_Table.name.eq("张三"))
                    .execute();

// Path: app/src/main/java/net/kb/test/bean/UserModel.java
// @Table(database = DBFlowDatabase.class)
// public class UserModel extends BaseModel {
//     //自增ID
//     @Column
//     @PrimaryKey(autoincrement = true)
//     public Long   id;
//     @Column
//     public String name;
//     @Column
//     public int    sex;
// 
//     public String getName() {
//         return name;
//     }
// 
//     public int getSex() {
//         return sex;
//     }
// }
// 
// Path: library/src/main/java/net/kb/test/library/testCase/DbFlowCase.java
// public class DbFlowCase extends KBCase {
// 
//     @Rule
//     public ExternalResource innerRule = new ExternalResource() {
//         @Override
//         protected void before() throws Throwable {
//             DbFlowUtils.destroy();
//         }
// 
//         @Override
//         protected void after() {
//             DbFlowUtils.destroy();
//         }
//     };
// }


// Path: app/src/test/java/net/kb/test/dbflow/DbFlowTest.java
import com.raizlabs.android.dbflow.config.FlowConfig;
import com.raizlabs.android.dbflow.config.FlowManager;
import com.raizlabs.android.dbflow.sql.language.Delete;
import com.raizlabs.android.dbflow.sql.language.Method;
import com.raizlabs.android.dbflow.sql.language.SQLite;
import com.raizlabs.android.dbflow.sql.language.Select;
import net.kb.test.bean.UserModel;
import net.kb.test.bean.UserModel_Table;
import net.kb.test.library.testCase.DbFlowCase;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.Random;

package net.kb.test.dbflow;





/**
 * Created by kkmike999 on 2017/06/12.
 */
public class DbFlowTest extends DbFlowCase {

    @Before
    public void setUp() throws Exception {
        FlowManager.init(new FlowConfig.Builder(getApplication()).build());

        Assert.assertEquals(0, new Select(Method.count()).from(UserModel.class).count());
    }

    @Test
    public void onInsert() {
        UserModel people = new UserModel();

        people.name = "张三";
        people.sex = 1;
        people.save();// 添加对象，一条一条保存

        Assert.assertEquals(1, new Select(Method.count()).from(UserModel.class).count());
    }

    @Test
    public void onDelete() {
        save("张三");

        new Delete().from(UserModel.class)
                    .where(UserModel_Table.name.eq("张三"))
                    .execute();

        Assert.assertEquals(0, new Select(Method.count()).from(UserModel.class).count());