class MarshmallowNetworkObservingStrategy extends Api21BaseNetworkObservingStrategy {

  @Override
  public Observable<RxNetworkInfo> observe() {
    Observable.create(new MarshmallowOnSubscribe()).subscribeWith(networkChange);
    return networkChange.distinctUntilChanged().doOnDispose(new OnDisposeAction());
  }

}

class MarshmallowNetworkObservingStrategyTest {

  private final TestObserver<RxNetworkInfo> testObserver;
  private final RxNetworkInfo defaultRxNetworkInfo;
  @Rule public MockitoRule rule;
  @Mock private PowerManager powerManager;
  private Context context;
  private BaseNetworkObservingStrategy sut;

  @Test
  public void shouldGetValue_whenIdleModeChanged_andDeviceIdled() {

    setUpDeviceIdleMode(true);
    doReturn(false).when(powerManager).isIgnoringBatteryOptimizations(anyString());

    sut.observe().subscribeWith(testObserver);
    testObserver.assertSubscribed().assertEmpty();

    RuntimeEnvironment.application.sendBroadcast(new Intent(ACTION_DEVICE_IDLE_MODE_CHANGED));

    testObserver.assertSubscribed().assertValue(defaultRxNetworkInfo);
  }

}