Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created May 31, 2019 08:32
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 jasongorman/a99008615a7fc2a81dc00d4f8b44254f to your computer and use it in GitHub Desktop.
Save jasongorman/a99008615a7fc2a81dc00d4f8b44254f to your computer and use it in GitHub Desktop.
@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