@Before
  public void setup() {
    bestLocationDelegate = new BestLocationDelegate(null, null, null, null);

    List<String> providers = new ArrayList<String>();
    when(locationManager.getAllProviders()).thenReturn(providers);
    TestHelper.setField(bestLocationDelegate, "locationManager", locationManager);

    when(passesCriteria.passes(any(Location.class), any(Location.class))).thenReturn(true);
    when(failsCriteria.passes(any(Location.class), any(Location.class))).thenReturn(false);

    List<LocationCriteria> criteria = new ArrayList<LocationCriteria>();
    TestHelper.setField(bestLocationDelegate, "criteria", criteria);
  }
  @Test
  public void shouldReturnPreviousGoodLocationIfACriteriaFailsForCandidate() {
    LocationCriteria failsForCandidateCriteria = mock(LocationCriteria.class);

    mockLessAccurateLocation(locationManager);
    mockAccurateLocation(locationManager);

    addCriteria(failsForCandidateCriteria);

    when(failsForCandidateCriteria.passes(eq(previousLocation), any(Location.class)))
        .thenReturn(true);
    when(failsForCandidateCriteria.passes(candidateLocation, previousLocation)).thenReturn(false);

    Location bestLastKnownLocation = bestLocationDelegate.getBestLastKnownLocation();

    assertSame(previousLocation, bestLastKnownLocation);
  }