public void testIsStale_DuringDelay() {
    assertFalse(target.isStale());
    assertFalse(delayed.isStale());

    target.setValue(newValue);

    assertFalse(target.isStale());
    assertTrue(delayed.isStale());
  }
  public void testSetValue_PropagatesToTarget() {
    assertEquals(oldValue, delayed.getValue());
    assertEquals(oldValue, target.getValue());

    delayed.setValue(newValue);

    assertEquals(newValue, target.getValue());
    assertEquals(newValue, delayed.getValue());
  }
  public void testIsStale_WhenTargetIsStale() {
    assertFalse(target.isStale());
    assertFalse(delayed.isStale());

    target.fireStale();

    assertTrue(target.isStale());
    assertTrue(delayed.isStale());
  }
  public void testSetValue_CachesGetValueFromTarget() {
    Object overrideValue = target.overrideValue = new Object();

    assertEquals(oldValue, delayed.getValue());
    assertEquals(oldValue, target.getValue());

    delayed.setValue(newValue);

    assertEquals(overrideValue, target.getValue());
    assertEquals(overrideValue, delayed.getValue());
  }
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   target = new ObservableValueStub(Realm.getDefault());
   oldValue = new Object();
   newValue = new Object();
   target.setValue(oldValue);
   delayed = Observables.observeDelayedValue(1, target);
 }
  private void assertFiresPendingValueChange(Runnable runnable) {
    ValueChangeEventTracker tracker = ValueChangeEventTracker.observe(delayed);

    target.setValue(newValue);
    assertTrue(delayed.isStale());
    assertEquals(0, tracker.count);

    runnable.run();

    assertFalse(delayed.isStale());
    assertEquals(1, tracker.count);
    assertEquals(oldValue, tracker.event.diff.getOldValue());
    assertEquals(newValue, tracker.event.diff.getNewValue());
  }
 public void testGetValueType_SameAsTarget() {
   assertEquals(target.getValueType(), delayed.getValueType());
 }
 @Override
 protected void tearDown() throws Exception {
   target.dispose();
   target = null;
   super.tearDown();
 }