@Test
public void shouldShowToastMsgIfSyncIsInProgressAndNetworkLost() {

    RapidFtrActivity rapidFtrActivity = spy(new ViewAllChildrenActivity());
    BroadcastReceiver receiver = rapidFtrActivity.getBroadcastReceiver();
    Intent mockIntent = mock(Intent.class);
    NetworkInfo mockNetworkInfo = mock(NetworkInfo.class);
    doReturn(mockNetworkInfo).when(mockIntent).getParcelableExtra(EXTRA_NETWORK_INFO);
    doReturn(false).when(mockNetworkInfo).isConnected();
    RapidFtrApplication.getApplicationInstance().setAsyncTaskWithDialog(new AsyncTaskWithDialog() {
        @Override
        public void cancel() {
        }
        @Override
        protected Object doInBackground(Object... objects) {
            return null;
        }
    });
    receiver.onReceive(rapidFtrActivity, mockIntent);
    MatcherAssert.assertThat(ShadowToast.getTextOfLatestToast(), equalTo(rapidFtrActivity.getString(R.string.network_down)));
}