Skip to content

Instantly share code, notes, and snippets.

@kikers25
Created January 8, 2017 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kikers25/6c24caa35129276937cc51dfe2c40b20 to your computer and use it in GitHub Desktop.
Save kikers25/6c24caa35129276937cc51dfe2c40b20 to your computer and use it in GitHub Desktop.
Unit tests with dates 11
@Test
public void should_return_false_when_today_isnt_the_birthday_of_user() throws Exception {
User user = new User().setDateOfBirth(five_july_2000);
SystemTime.setTimeSource(new TimeSource() {
@Override
public long millis() {
return six_july_2010.getTime();
}
});
assertThat(user.isBirthDay(), is(false));
}
@Test
public void should_return_true_when_today_is_the_birthday_of_user() throws Exception {
User user = new User().setDateOfBirth(five_july_2000);
SystemTime.setTimeSource(new TimeSource() {
@Override
public long millis() {
return five_july_2010.getTime();
}
});
assertThat(user.isBirthDay(), is(true));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment