Created
April 5, 2019 08:55
-
-
Save jasongorman/e995329c06fc3393d7a78c12be90926f 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
@Test | |
void buyCdPaymentAccepted() { | |
int stock = 10; | |
double price = 9.99; | |
String creditCardNumber = "1234"; | |
Payments payments = new PaymentsStub(PaymentResponse.ACCEPTED); | |
stock = buy(new CompactDisc(stock, price, payments), creditCardNumber); | |
assertEquals(9, stock ); | |
} | |
private int buy(CompactDisc cd, String creditCardNumber) { | |
int stock = cd.getStock(); | |
if(cd.getPayments().process(cd.getPrice(), creditCardNumber) == PaymentResponse.ACCEPTED) | |
stock--; | |
return stock; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment