@Before
 public void setUp() throws Exception {
   doReturn(LocationManager.GPS_PROVIDER)
       .when(locationManager)
       .getBestProvider(any(Criteria.class), anyBoolean());
   doReturn(locationManager).when(context).getSystemService(eq(Context.LOCATION_SERVICE));
   locator.prepare(context, settings);
 }
  @Test
  public void locator_should_disable_location_updates_when_a_provider_is_disabled()
      throws NoProviderAvailable {
    locator.startLocationUpdates();

    disableProvider();

    verify(locationManager, times(3)).removeUpdates(any(PendingIntent.class));
  }
  @Test
  public void locator_should_restart_location_updates_when_a_provider_is_disabled()
      throws NoProviderAvailable {
    locator.startLocationUpdates();

    disableProvider();

    verify(locationManager, times(2))
        .requestLocationUpdates(anyString(), anyLong(), anyFloat(), any(PendingIntent.class));
  }