1
exercism fetch scala book-store

src/test/scala/BookStoreTest.scala

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import org.scalatest.{Matchers, FunSuite}

/** @version 1.3.0 */
class BookStoreTest extends FunSuite with Matchers {

  test("Only a single book") {
    BookStore.total(List(1)) should be (800)
  }

  test("Two of the same book") {
    pending
    BookStore.total(List(2, 2)) should be (1600)
  }

  test("Empty basket") {
    pending
    BookStore.total(List()) should be (0)
  }

  test("Two different books") {
    pending
    BookStore.total(List(1, 2)) should be (1520)
  }

  test("Three different books") {
    pending
    BookStore.total(List(1, 2, 3)) should be (2160)
  }

  test("Four different books") {
    pending
    BookStore.total(List(1, 2, 3, 4)) should be (2560)
  }

  test("Five different books") {
    pending
    BookStore.total(List(1, 2, 3, 4, 5)) should be (3000)
  }

  test("Two groups of four is cheaper than group of five plus group of three") {
    pending
    BookStore.total(List(1, 1, 2, 2, 3, 3, 4, 5)) should be (5120)
  }

  test("Group of four plus group of two is cheaper than two groups of three") {
    pending
    BookStore.total(List(1, 1, 2, 2, 3, 4)) should be (4080)
  }

  test("Two each of first 4 books and 1 copy each of rest") {
    pending
    BookStore.total(List(1, 1, 2, 2, 3, 3, 4, 4, 5)) should be (5560)
  }

  test("Two copies of each book") {
    pending
    BookStore.total(List(1, 1, 2, 2, 3, 3, 4, 4, 5, 5)) should be (6000)
  }

  test("Three copies of first book and 2 each of remaining") {
    pending
    BookStore.total(List(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1)) should be (6800)
  }

  test("Three each of first 2 books and 2 each of remaining books") {
    pending
    BookStore.total(List(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2)) should be (7520)
  }

  test("Four groups of four are cheaper than two groups each of five and three") {
    pending
    BookStore.total(List(1, 1, 2, 2, 3, 3, 4, 5, 1, 1, 2, 2, 3, 3, 4, 5)) should be (10240)
  }
}