Search in sources :

Example 16 with From

use of com.activeandroid.query.From in project ActiveAndroid by pardom.

the class CountTest method testCountOrderBy.

/**
     * Should not change the result if order by is used.
     */
public void testCountOrderBy() {
    cleanTable();
    populateTable();
    From from = new Select().from(MockModel.class).where("intField = ?", 1).orderBy("intField ASC");
    final List<MockModel> list = from.execute();
    final int count = from.count();
    assertEquals(2, count);
    assertEquals(list.size(), count);
}
Also used : MockModel(com.activeandroid.test.MockModel) Select(com.activeandroid.query.Select) From(com.activeandroid.query.From)

Example 17 with From

use of com.activeandroid.query.From in project ActiveAndroid by pardom.

the class CountTest method testCountWhereClause.

/**
     * Should return the same count as there are entries in the result set if the where-clause
     * matches several entries.
     */
public void testCountWhereClause() {
    cleanTable();
    populateTable();
    From from = new Select().from(MockModel.class).where("intField = ?", 1);
    final List<MockModel> list = from.execute();
    final int count = from.count();
    assertEquals(2, count);
    assertEquals(list.size(), count);
}
Also used : MockModel(com.activeandroid.test.MockModel) Select(com.activeandroid.query.Select) From(com.activeandroid.query.From)

Example 18 with From

use of com.activeandroid.query.From in project ActiveAndroid by pardom.

the class CountTest method testCountTable.

/**
     * Should return the same count as there are entries in the result set/table.
     */
public void testCountTable() {
    cleanTable();
    populateTable();
    From from = new Select().from(MockModel.class);
    final List<MockModel> list = from.execute();
    final int count = from.count();
    assertEquals(3, count);
    assertEquals(list.size(), count);
}
Also used : MockModel(com.activeandroid.test.MockModel) Select(com.activeandroid.query.Select) From(com.activeandroid.query.From)

Aggregations

From (com.activeandroid.query.From)18 Select (com.activeandroid.query.Select)11 MockModel (com.activeandroid.test.MockModel)11