Code example for MockContentResolver

Methods: insertquery

0
        msg.put("sender", "Ananda");
        msg.put("msg", "Hi, what's up?");
        long now = System.currentTimeMillis();
        msg.put("time", now);
         
        mRes.insert(Uri.parse("content://foo.lounge/chat"), msg); // 1
        mRes.insert(Uri.parse("content://foo.lounge/chat"), msg); // 2
        mRes.insert(Uri.parse("content://foo.lounge/chat"), msg); // 3
         
        Cursor msges = mRes.query(Uri.parse("content://foo.lounge/chat"), null, null, null, null);
        assertEquals("There should be three chat messages", 3, msges.getCount());
        msges.moveToFirst();
        assertEquals("Ananda", msges.getString(1));
        assertEquals(now, msges.getLong(2));
        assertEquals("Hi, what's up?", msges.getString(3));
    }