Created
May 17, 2016 22:54
-
-
Save dlemures/3c5993b67c3dc066afc8729df4484b5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SmoothieMakerTest { | |
@Rule public EasyMockRule mocks = new EasyMockRule(this); | |
@TestSubject private SmoothieMaker smoothieMakerUnderTest = new SmoothieMaker(); | |
@Mock private Blender mockBlender; | |
@Mock private Freezer mockFreezer; | |
@After | |
public void tearDown() throws Exception { | |
ToothPick.reset(); | |
} | |
@Test | |
public void testMakeSmoothie() throws Exception { | |
//GIVEN | |
mockBlender.mix(); | |
mockFreezer.freeze(); | |
replay(mockBlender, mockFreezer); | |
Scope scope = ToothPick.openScope("TestScope"); | |
scope.installTestModules(new TestModule()); | |
//WHEN | |
smoothieMakerUnderTest.makeSmoothie(); | |
//THEN | |
verify(mockBlender, mockFreezer); | |
} | |
private class TestModule extends Module { | |
public TestModule() { | |
bind(Blender.class).to(mockBlender); | |
bind(Freezer.class).to(mockFreezer); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment