import static org.junit.Assert.assertEquals; import java.util.List; import java.util.ArrayList; import java.util.Arrays; import org.junit.Test; public class BookstoreTest{ @Test public void onlyASingleBook(){ List books = new ArrayList<>(Arrays.asList(1)); Bookstore bookstore = new Bookstore(books); assertEquals(8,bookstore.calculateTotalCost(),2); } @Ignore @Test public void twoOfSameBook(){ List books = new ArrayList<>(Arrays.asList(1,1)); Bookstore bookstore = new Bookstore(books); assertEquals(16,bookstore.calculateTotalCost(),2); } @Ignore @Test public void emptyBasket(){ List books = new ArrayList<>(); Bookstore bookstore = new Bookstore(books); assertEquals(0,bookstore.calculateTotalCost(),2); } @Ignore @Test public void twoDifferentBooks(){ List books = new ArrayList<>(Arrays.asList(1,2)); Bookstore bookstore = new Bookstore(books); assertEquals(15.20,bookstore.calculateTotalCost(),2); } @Ignore @Test public void threeDifferentBooks(){ List books = new ArrayList<>(Arrays.asList(1,2,3)); Bookstore bookstore = new Bookstore(books); assertEquals(21.6,bookstore.calculateTotalCost(),2); } @Ignore @Test public void fourDifferentBooks(){ ArrayList books = new ArrayList<>(Arrays.asList(1,2,3,4)); Bookstore bookstore = new Bookstore(books); assertEquals(25.6,bookstore.calculateTotalCost(),2); } @Ignore @Test public void fiveDifferentBooks(){ ArrayList books = new ArrayList<>(Arrays.asList(1,2,3,4,5)); Bookstore bookstore = new Bookstore(books); assertEquals(30,bookstore.calculateTotalCost(),2); } @Ignore @Test public void twoGroupsOfFourIsCheaperThanGroupOfFivePlusGroupOfThree(){ List books = new ArrayList<>(Arrays.asList(1,1,2,2,3,3,4,5)); Bookstore bookstore = new Bookstore(books); assertEquals(51.20,bookstore.calculateTotalCost(),2); } @Ignore @Test public void groupOfFourPlusGroupOfTwoIsCheaperThanTwoGroupsOfThree(){ List books = new ArrayList<>(Arrays.asList(1,1,2,2,3,4)); Bookstore bookstore = new Bookstore(books); assertEquals(40.8,bookstore.calculateTotalCost(),2); } @Ignore @Test public void twoEachOfFirst4BooksAnd1CopyEachOfRest(){ Integer[] p = {1,1,2,2,3,3,4,4,5}; List books = new ArrayList<>(Arrays.asList(1,1,2,2,3,3,4,4,5)); Bookstore bookstore = new Bookstore(books); assertEquals(55.60,bookstore.calculateTotalCost(),2); } @Ignore @Test public void twoCopiesOfEachBook(){ List books = new ArrayList<>(Arrays.asList(1,1,2,2,3,3,4,4,5,5)); Bookstore bookstore = new Bookstore(books); assertEquals(60.00,bookstore.calculateTotalCost(),2); } @Ignore @Test public void threeCopiesOfFirstBookAnd2EachOfRemaining(){ List books = new ArrayList<>(Arrays.asList(1,1,2,2,3,3,4,4,5,5,1)); Bookstore bookstore = new Bookstore(books); assertEquals(68.00,bookstore.calculateTotalCost(),2); } @Ignore @Test public void threeEachOFirst2BooksAnd2EachOfRemainingBooks(){ List books = new ArrayList<>(Arrays.asList(1,1,2,2,3,3,4,4,5,5,1,2)); Bookstore bookstore = new Bookstore(books); assertEquals(75.20,bookstore.calculateTotalCost(),2); } }