Skip to content

Instantly share code, notes, and snippets.

@grimrose
Created February 3, 2013 15:42
Show Gist options
  • Save grimrose/4702217 to your computer and use it in GitHub Desktop.
Save grimrose/4702217 to your computer and use it in GitHub Desktop.
DelegateObjectSampleTest
package chapter11
import org.junit.Test
import static org.hamcrest.CoreMatchers.*
import static org.junit.Assert.assertThat
class DelegateObjectSampleTest {
@Test
void "doSomethingを実行するとdateに現在時刻が設定される"() {
// Setup
Date current = new Date()
DelegateObjectSample sut = new DelegateObjectSample()
sut.dateFactory = new DateFactory() {
@Override
Date newDate() {
current
}
}
// Exercise
sut.doSomething()
// Verify
assertThat(sut.date, is(sameInstance(current)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment