Java 类org.robolectric.shadows.ShadowSQLiteDatabase 实例源码

项目:CatHandsGendroid    文件:AutoIncrementTest.java   
@Test
public void testPint() {
    SQLiteDatabase db = ShadowSQLiteDatabase.create(null);
    db.execSQL(PintKeyAiModelCatHands.SQL_CREATE_TABLE);

    PintKeyAiModel m1 = new PintKeyAiModel();
    PintKeyAiModel m2 = new PintKeyAiModel();

    PintKeyAiModelCatHands.insert(db, m1);
    PintKeyAiModelCatHands.insert(db, m2);

    assertEquals(1, m1.getKey());
    assertEquals(2, m2.getKey());
}
项目:CatHandsGendroid    文件:AutoIncrementTest.java   
@Test
public void testPlong() {
    SQLiteDatabase db = ShadowSQLiteDatabase.create(null);
    db.execSQL(PlongKeyAiModelCatHands.SQL_CREATE_TABLE);

    PlongKeyAiModel m1 = new PlongKeyAiModel();
    PlongKeyAiModel m2 = new PlongKeyAiModel();

    PlongKeyAiModelCatHands.insert(db, m1);
    PlongKeyAiModelCatHands.insert(db, m2);

    assertEquals(1, m1.getKey());
    assertEquals(2, m2.getKey());
}
项目:CatHandsGendroid    文件:AutoIncrementTest.java   
@Test
public void testInt() {
    SQLiteDatabase db = ShadowSQLiteDatabase.create(null);
    db.execSQL(IntKeyAiModelCatHands.SQL_CREATE_TABLE);

    IntKeyAiModel m1 = new IntKeyAiModel();
    IntKeyAiModel m2 = new IntKeyAiModel();

    IntKeyAiModelCatHands.insert(db, m1);
    IntKeyAiModelCatHands.insert(db, m2);

    assertEquals(Integer.valueOf(1), m1.getKey());
    assertEquals(Integer.valueOf(2), m2.getKey());
}
项目:CatHandsGendroid    文件:AutoIncrementTest.java   
@Test
public void testLong() {
    SQLiteDatabase db = ShadowSQLiteDatabase.create(null);
    db.execSQL(LongKeyAiModelCatHands.SQL_CREATE_TABLE);

    LongKeyAiModel m1 = new LongKeyAiModel();
    LongKeyAiModel m2 = new LongKeyAiModel();

    LongKeyAiModelCatHands.insert(db, m1);
    LongKeyAiModelCatHands.insert(db, m2);

    assertEquals(Long.valueOf(1), m1.getKey());
    assertEquals(Long.valueOf(2), m2.getKey());
}
项目:CatHandsGendroid    文件:StringKvModelTest.java   
@Test
   public void testRun() {
       SQLiteDatabase db = ShadowSQLiteDatabase.create(null);
       db.execSQL(StringKvModelCatHands.SQL_CREATE_TABLE);

       StringKvModelCatHands.insert(db, new StringKvModel("Cat","Fish"));
       StringKvModelCatHands.insert(db, new StringKvModel("Dog","Meat"));
       StringKvModelCatHands.insert(db, new StringKvModel("Frog","Bug"));

       {
        assertEquals("Fish", StringKvModelCatHands.findByKey(db, "Cat").getValue());
        assertEquals("Meat", StringKvModelCatHands.findByKey(db, "Dog").getValue());
        assertEquals("Bug", StringKvModelCatHands.findByKey(db, "Frog").getValue());
       }

       assertEquals(1, StringKvModelCatHands.delete(db, "Dog"));
       {
        assertEquals("Fish", StringKvModelCatHands.findByKey(db, "Cat").getValue());
        assertNull(StringKvModelCatHands.findByKey(db, "Dog"));
        assertEquals("Bug", StringKvModelCatHands.findByKey(db, "Frog").getValue());
       }

       assertEquals(1, StringKvModelCatHands.update(db, new StringKvModel("Frog", "Snake")));
       {
        assertEquals("Fish", StringKvModelCatHands.findByKey(db, "Cat").getValue());
        assertNull(StringKvModelCatHands.findByKey(db, "Dog"));
        assertEquals("Snake", StringKvModelCatHands.findByKey(db, "Frog").getValue());
       }

}
项目:CatHandsGendroid    文件:FullModelTest.java   
@Test
public void testDbFunc_null() {
    SQLiteDatabase db = ShadowSQLiteDatabase.create(null);
    db.execSQL(FullModelCatHands.SQL_CREATE_TABLE);
    FullModel model = new FullModel();
    { // Insert
        model.setKey(567);
        FullModelCatHands.insert(db, model);
    }
    {// compare
        FullModel t = FullModelCatHands.findByKey(db, model.getKey());
        assertEquals(model.getBlobValue(), t.getBlobValue());
        assertEquals(model.getBooleanValue(), t.getBooleanValue());
        assertEquals(model.getByteValue(), t.getByteValue());
        assertEquals(model.getCharacterValue(), t.getCharacterValue());
        assertEquals(model.getDateValue(), t.getDateValue());
        assertEquals(model.getDoubleValue(), t.getDoubleValue());
        assertEquals(model.getFloatValue(), t.getFloatValue());
        assertEquals(model.getIntegerValue(), t.getIntegerValue());
        assertEquals(model.getKey(), t.getKey());
        assertEquals(model.getLongValue(), t.getLongValue());
        assertEquals(model.getParcelableValue(), t.getParcelableValue());
        assertEquals(model.getPBooleanValue(), t.getPBooleanValue());
        assertEquals(model.getPByteValue(), t.getPByteValue());
        assertEquals(model.getPCharValue(), t.getPCharValue());
        assertEquals(model.getPDoubleValue(), t.getPDoubleValue(), 0);
        assertEquals(model.getPFloatValue(), t.getPFloatValue(), 0);
        assertEquals(model.getPIntValue(), t.getPIntValue());
        assertEquals(model.getPLongValue(), t.getPLongValue());
        assertEquals(model.getPShortValue(), t.getPShortValue());
        assertEquals(model.getSerializable(), t.getSerializable());
        assertEquals(model.getShortValue(), t.getShortValue());
        assertEquals(model.getStringValue(), t.getStringValue());
        assertEquals(model.getTinyEnum(), t.getTinyEnum());
        assertEquals(model.getSetSetStringValue(), t.getSetSetStringValue());
    }
}