コード例 #1
0
  public void testIsStale_WhenTargetIsStale() {
    assertFalse(target.isStale());
    assertFalse(delayed.isStale());

    target.fireStale();

    assertTrue(target.isStale());
    assertTrue(delayed.isStale());
  }
コード例 #2
0
  public void testIsStale_DuringDelay() {
    assertFalse(target.isStale());
    assertFalse(delayed.isStale());

    target.setValue(newValue);

    assertFalse(target.isStale());
    assertTrue(delayed.isStale());
  }
コード例 #3
0
  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());
  }