|
| 1 | +import static org.junit.Assert.assertEquals; |
| 2 | + |
| 3 | +import java.util.List; |
| 4 | +import java.util.ArrayList; |
| 5 | +import java.util.Arrays; |
| 6 | + |
| 7 | +import org.junit.Test; |
| 8 | + |
| 9 | +public class BookstoreTest{ |
| 10 | + |
| 11 | + @Test |
| 12 | + public void onlyASingleBook(){ |
| 13 | + List<Integer> books = new ArrayList<>(Arrays.asList(1)); |
| 14 | + Bookstore bookstore = new Bookstore(books); |
| 15 | + assertEquals(8,bookstore.calculateTotalCost(),2); |
| 16 | + } |
| 17 | + |
| 18 | + @Ignore |
| 19 | + @Test |
| 20 | + public void twoOfSameBook(){ |
| 21 | + List<Integer> books = new ArrayList<>(Arrays.asList(1,1)); |
| 22 | + Bookstore bookstore = new Bookstore(books); |
| 23 | + assertEquals(16,bookstore.calculateTotalCost(),2); |
| 24 | + } |
| 25 | + |
| 26 | + @Ignore |
| 27 | + @Test |
| 28 | + public void emptyBasket(){ |
| 29 | + List<Integer> books = new ArrayList<>(); |
| 30 | + Bookstore bookstore = new Bookstore(books); |
| 31 | + assertEquals(0,bookstore.calculateTotalCost(),2); |
| 32 | + } |
| 33 | + |
| 34 | + @Ignore |
| 35 | + @Test |
| 36 | + public void twoDifferentBooks(){ |
| 37 | + List<Integer> books = new ArrayList<>(Arrays.asList(1,2)); |
| 38 | + Bookstore bookstore = new Bookstore(books); |
| 39 | + assertEquals(15.20,bookstore.calculateTotalCost(),2); |
| 40 | + } |
| 41 | + |
| 42 | + @Ignore |
| 43 | + @Test |
| 44 | + public void threeDifferentBooks(){ |
| 45 | + List<Integer> books = new ArrayList<>(Arrays.asList(1,2,3)); |
| 46 | + Bookstore bookstore = new Bookstore(books); |
| 47 | + assertEquals(21.6,bookstore.calculateTotalCost(),2); |
| 48 | + } |
| 49 | + |
| 50 | + @Ignore |
| 51 | + @Test |
| 52 | + public void fourDifferentBooks(){ |
| 53 | + ArrayList<Integer> books = new ArrayList<>(Arrays.asList(1,2,3,4)); |
| 54 | + Bookstore bookstore = new Bookstore(books); |
| 55 | + assertEquals(25.6,bookstore.calculateTotalCost(),2); |
| 56 | + |
| 57 | + } |
| 58 | + |
| 59 | + @Ignore |
| 60 | + @Test |
| 61 | + public void fiveDifferentBooks(){ |
| 62 | + ArrayList<Integer> books = new ArrayList<>(Arrays.asList(1,2,3,4,5)); |
| 63 | + Bookstore bookstore = new Bookstore(books); |
| 64 | + assertEquals(30,bookstore.calculateTotalCost(),2); |
| 65 | + } |
| 66 | + |
| 67 | + @Ignore |
| 68 | + @Test |
| 69 | + public void twoGroupsOfFourIsCheaperThanGroupOfFivePlusGroupOfThree(){ |
| 70 | + List<Integer> books = new ArrayList<>(Arrays.asList(1,1,2,2,3,3,4,5)); |
| 71 | + Bookstore bookstore = new Bookstore(books); |
| 72 | + assertEquals(51.20,bookstore.calculateTotalCost(),2); |
| 73 | + } |
| 74 | + |
| 75 | + @Ignore |
| 76 | + @Test |
| 77 | + public void groupOfFourPlusGroupOfTwoIsCheaperThanTwoGroupsOfThree(){ |
| 78 | + List<Integer> books = new ArrayList<>(Arrays.asList(1,1,2,2,3,4)); |
| 79 | + Bookstore bookstore = new Bookstore(books); |
| 80 | + assertEquals(40.8,bookstore.calculateTotalCost(),2); |
| 81 | + } |
| 82 | + |
| 83 | + @Ignore |
| 84 | + @Test |
| 85 | + public void twoEachOfFirst4BooksAnd1CopyEachOfRest(){ |
| 86 | + Integer[] p = {1,1,2,2,3,3,4,4,5}; |
| 87 | + List<Integer> books = new ArrayList<>(Arrays.asList(1,1,2,2,3,3,4,4,5)); |
| 88 | + Bookstore bookstore = new Bookstore(books); |
| 89 | + assertEquals(55.60,bookstore.calculateTotalCost(),2); |
| 90 | + } |
| 91 | + |
| 92 | + @Ignore |
| 93 | + @Test |
| 94 | + public void twoCopiesOfEachBook(){ |
| 95 | + List<Integer> books = new ArrayList<>(Arrays.asList(1,1,2,2,3,3,4,4,5,5)); |
| 96 | + Bookstore bookstore = new Bookstore(books); |
| 97 | + assertEquals(60.00,bookstore.calculateTotalCost(),2); |
| 98 | + } |
| 99 | + |
| 100 | + @Ignore |
| 101 | + @Test |
| 102 | + public void threeCopiesOfFirstBookAnd2EachOfRemaining(){ |
| 103 | + List<Integer> books = new ArrayList<>(Arrays.asList(1,1,2,2,3,3,4,4,5,5,1)); |
| 104 | + Bookstore bookstore = new Bookstore(books); |
| 105 | + assertEquals(68.00,bookstore.calculateTotalCost(),2); |
| 106 | + } |
| 107 | + |
| 108 | + @Ignore |
| 109 | + @Test |
| 110 | + public void threeEachOFirst2BooksAnd2EachOfRemainingBooks(){ |
| 111 | + List<Integer> books = new ArrayList<>(Arrays.asList(1,1,2,2,3,3,4,4,5,5,1,2)); |
| 112 | + Bookstore bookstore = new Bookstore(books); |
| 113 | + assertEquals(75.20,bookstore.calculateTotalCost(),2); |
| 114 | + } |
| 115 | + |
| 116 | +} |
| 117 | + |
0 commit comments