@Test public void shouldReturnSumOfGoodsPricesPurchased() { ShoppingBasket basket = new ShoppingBasket(); Good good1 = new Good("rice", 34.90, new Type("food")); Good good2 = new Good("wheat", 34.90, new Type("food")); basket.addToIt(good1, 1); basket.addToIt(good2, 2); assertEquals(new Receipt(basket).sumOfItemPrices(), 34.90 * 3, 0.01); }
@Test public void shouldReturnSumOfTotalTaxAndPriceForGoodsPurchased() { ShoppingBasket basket = new ShoppingBasket(); Good good1 = new Good("rice", 12.49, new Type("book")); Good good2 = new Good("wheat", 14.99, new Type("cd")); Good good3 = new Good("choco", 0.85, new Type("food")); basket.addToIt(good1, 1); basket.addToIt(good2, 1); basket.addToIt(good3, 1); basket.purchase(); assertEquals(new Receipt(basket).total(), 29.83, 0.1); }
public void putIntoBasket(int numberOfBook, int seriesNumberOfBook) { if (seriesNumberOfBook <= 0 || seriesNumberOfBook > DiscountStrategy.MAX_SERIES_NUMBER) { throw new IllegalStateException( "series number of book should be between 1 and " + DiscountStrategy.MAX_SERIES_NUMBER); } shoppingBasket.sortBooksInBasket(numberOfBook, seriesNumberOfBook); }
public void initializeBasket() { this.shoppingBasket = new ShoppingBasket(); shoppingBasket.initializeBasket(); }