Skip to content

Instantly share code, notes, and snippets.

@jianxiansiqi47
Last active October 12, 2017 20:47
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 jianxiansiqi47/e21e801464335318b6fa76eaf232ff30 to your computer and use it in GitHub Desktop.
Save jianxiansiqi47/e21e801464335318b6fa76eaf232ff30 to your computer and use it in GitHub Desktop.
DealPresenterTestV3 - TP article
public class DealPresenterTest {
@Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
@Rule public ToothPickRule toothPickRule = new ToothPickRule(this, “DealPresenter”);
@Mock DealUtil dealUtil;
@Mock DealApiClient dealApiClient;
@Mock WishlistManager wishlistManager;
@Inject DealPresenter dealPresenterUnderTest;
@Before
public void setUp() {
toothPickRule.inject(this);
}
...
@Test
public void onWishlistSelected_when_wishlistEnabled() throws Exception {
//GIVEN
Deal deal = new Deal();
deal.id = "12345";
dealPresenterUnderTest.deal = deal;
when(dealUtil.isWishlistEnabled(deal)).thenReturn(true);
//WHEN
dealPresenterUnderTest.onWishlistSelected();
//THEN
verify(wishlistManager).addDealToWishlist(deal.id);
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment