Skip to content

Instantly share code, notes, and snippets.


jasongorman/ Secret

Created Apr 10, 2021
What would you like to do?
public interface Payments {
Boolean process(double amount, CreditCard card);
public class BuyCdTest {
private Payments payments;
private CompactDisc cd;
private CreditCard card;
public void setUp() {
payments = mock(Payments.class);
when(payments.process(any(), any())).thenReturn(true); // payment accepted
cd = new CompactDisc(10, 9.99);
card = new CreditCard(
public void saleIsSuccessful(){, card);
assertEquals(9, cd.getStock());
public void cardIsChargedCorrectAmount(){, card);
verify(payments).process(19.98, card);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment