Created
May 31, 2019 08:32
-
-
Save jasongorman/a99008615a7fc2a81dc00d4f8b44254f 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 | |
public void addingItemChangesBasketTotal() { | |
List<Object[]> basket = new ArrayList<>(); | |
String productCode = "P111"; | |
String productDescription = "Widget (Large)"; | |
double price = 10.0; | |
int quantity = 10; | |
ShoppingBasket shoppingBasket = new ShoppingBasket(basket); | |
shoppingBasket.addItem(productCode, productDescription, price, quantity); | |
double total = shoppingBasket.getBasket().stream() | |
.mapToDouble(i -> (double)i[PRICE] * (int)i[QUANTITY]) | |
.sum(); | |
assertEquals(100.0, total , 0.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment