Code example for MockContentResolver

Methods: query

0
        queryNumber = cursor.getCount();
        assertEquals(2, queryNumber);
    } 
     
    public void testcase04_QueryStationsUri() { 
        Cursor cursor = mMockResolver.query(Station.CONTENT_URI, columns, null, null, null);
        assertEquals(0, cursor.getCount());
        insertData(3); 
        cursor = mMockResolver.query(Station.CONTENT_URI, columns, null, null, null);
        assertEquals(3, cursor.getCount());
    } 
     
    public void testcase05_QueryStationIdUri() { 
        Uri uri = ContentUris.withAppendedId(Station.CONTENT_URI, 1);
        Cursor cursor = mMockResolver.query(uri, columns, null, null, null);
        assertEquals(0, cursor.getCount());
        insertData(3); 
        cursor = mMockResolver.query(uri, columns, null, null, null);
        assertEquals(1, cursor.getCount());
    }