### Question:
SyncingService extends IntentService { public static void startActionSingleSync(Context context, int numOfPages) { NightscoutPreferences preferences = new AndroidPreferences(context); if (!preferences.getIUnderstand()) { Toast.makeText(context, R.string.message_user_not_understand, Toast.LENGTH_LONG).show(); return; } Intent intent = new Intent(context, SyncingService.class); intent.setAction(ACTION_SYNC); intent.putExtra(SYNC_PERIOD, numOfPages); context.startService(intent); } SyncingService(); static void startActionSingleSync(Context context, int numOfPages); static boolean isG4Connected(Context c); static final String RESPONSE_SGV; static final String RESPONSE_TREND; static final String RESPONSE_TIMESTAMP; static final String RESPONSE_NEXT_UPLOAD_TIME; static final String RESPONSE_UPLOAD_STATUS; static final String RESPONSE_DISPLAY_TIME; static final String RESPONSE_JSON; static final String RESPONSE_BAT; static final int MIN_SYNC_PAGES; static final int GAP_SYNC_PAGES; }### Answer:
@Test public void test_NoDisclaimerShouldDisplayToastMessage() { SyncingService.startActionSingleSync(activity.getApplicationContext(), 2); assertThat(ShadowToast.getTextOfLatestToast(), is(activity.getApplicationContext().getString(R.string.message_user_not_understand))); }
@Test public void test_startActionSingleSyncWithIUnderstandShouldStartService() { prefs.setIUnderstand(true); SyncingService.startActionSingleSync(activity.getApplicationContext(), 2); Intent syncingService = shadowActivity.getNextStartedService(); assertThat(ShadowToast.shownToastCount(), is(0)); assertThat(syncingService.getAction(), is("com.nightscout.android.dexcom.action.SYNC")); assertThat(syncingService.getExtras() .getInt("com.nightscout.android.dexcom.extra.SYNC_PERIOD"), is(2)); }