Code example for MockContext

0
import com.google.android.testing.mocking.AndroidMock; 
 
public class CheckProxyImplTest extends AbstractTest { 
 
    public void testPostCheck() throws Exception { 
        CallbackAdapter handler = new CallbackAdapter(new MockContext());
        String key = "key1";
        String title = "title1";
        String primaryUrl = "primaryUrl1";
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("title", title);
        params.put("primaryUrl", primaryUrl);
         
        MixiContainer mixiContainer = AndroidMock.createMock(MixiContainer.class);
        mixiContainer.send(AndroidMock.eq("/share"), eqJSONObject(params), AndroidMock.same(handler));
        AndroidMock.replay(mixiContainer);
         
        CheckProxyImpl target = new CheckProxyImpl(mixiContainer);
        target.postCheck(key, title, primaryUrl, handler);