Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
DealPresenterTestV1 - TP article
public class DealPresenterTest {
private DealUtil dealUtil;
private DealApiClient dealApiClient;
private WishlistManager wishlistManager;
private DealViewStateModel dealViewStateModel = new DealViewStateModel();
private DealPresenter dealPresenterUnderTest;
@Before
public void setUp() {
dealUtil = mock(DealUtil.class);
dealApiClient = mock(DealApiClient.class);
wishlistManager = mock(WishlistManager.class);
dealPresenterUnderTest = new DealPresenter(dealUtil, dealApiClient, wishlistManager, dealViewStateModel);
...
}
...
@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