|
1 | | -using System; |
2 | 1 | using Xunit; |
3 | 2 |
|
4 | 3 | public class BookStoreTests |
5 | 4 | { |
6 | 5 | [Fact] |
7 | 6 | public void Only_a_single_book() |
8 | 7 | { |
9 | | - var basket = new[] { 1 }; |
10 | | - Assert.Equal(8m, BookStore.Total(basket)); |
| 8 | + Assert.Equal(8m, BookStore.Total([1])); |
11 | 9 | } |
12 | 10 |
|
13 | 11 | [Fact(Skip = "Remove this Skip property to run this test")] |
14 | 12 | public void Two_of_the_same_book() |
15 | 13 | { |
16 | | - var basket = new[] { 2, 2 }; |
17 | | - Assert.Equal(16m, BookStore.Total(basket)); |
| 14 | + Assert.Equal(16m, BookStore.Total([2, 2])); |
18 | 15 | } |
19 | 16 |
|
20 | 17 | [Fact(Skip = "Remove this Skip property to run this test")] |
21 | 18 | public void Empty_basket() |
22 | 19 | { |
23 | | - var basket = Array.Empty<int>(); |
24 | | - Assert.Equal(0m, BookStore.Total(basket)); |
| 20 | + Assert.Equal(0m, BookStore.Total([])); |
25 | 21 | } |
26 | 22 |
|
27 | 23 | [Fact(Skip = "Remove this Skip property to run this test")] |
28 | 24 | public void Two_different_books() |
29 | 25 | { |
30 | | - var basket = new[] { 1, 2 }; |
31 | | - Assert.Equal(15.2m, BookStore.Total(basket)); |
| 26 | + Assert.Equal(15.2m, BookStore.Total([1, 2])); |
32 | 27 | } |
33 | 28 |
|
34 | 29 | [Fact(Skip = "Remove this Skip property to run this test")] |
35 | 30 | public void Three_different_books() |
36 | 31 | { |
37 | | - var basket = new[] { 1, 2, 3 }; |
38 | | - Assert.Equal(21.6m, BookStore.Total(basket)); |
| 32 | + Assert.Equal(21.6m, BookStore.Total([1, 2, 3])); |
39 | 33 | } |
40 | 34 |
|
41 | 35 | [Fact(Skip = "Remove this Skip property to run this test")] |
42 | 36 | public void Four_different_books() |
43 | 37 | { |
44 | | - var basket = new[] { 1, 2, 3, 4 }; |
45 | | - Assert.Equal(25.6m, BookStore.Total(basket)); |
| 38 | + Assert.Equal(25.6m, BookStore.Total([1, 2, 3, 4])); |
46 | 39 | } |
47 | 40 |
|
48 | 41 | [Fact(Skip = "Remove this Skip property to run this test")] |
49 | 42 | public void Five_different_books() |
50 | 43 | { |
51 | | - var basket = new[] { 1, 2, 3, 4, 5 }; |
52 | | - Assert.Equal(30m, BookStore.Total(basket)); |
| 44 | + Assert.Equal(30m, BookStore.Total([1, 2, 3, 4, 5])); |
53 | 45 | } |
54 | 46 |
|
55 | 47 | [Fact(Skip = "Remove this Skip property to run this test")] |
56 | 48 | public void Two_groups_of_four_is_cheaper_than_group_of_five_plus_group_of_three() |
57 | 49 | { |
58 | | - var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 5 }; |
59 | | - Assert.Equal(51.2m, BookStore.Total(basket)); |
| 50 | + Assert.Equal(51.2m, BookStore.Total([1, 1, 2, 2, 3, 3, 4, 5])); |
60 | 51 | } |
61 | 52 |
|
62 | 53 | [Fact(Skip = "Remove this Skip property to run this test")] |
63 | 54 | public void Two_groups_of_four_is_cheaper_than_groups_of_five_and_three() |
64 | 55 | { |
65 | | - var basket = new[] { 1, 1, 2, 3, 4, 4, 5, 5 }; |
66 | | - Assert.Equal(51.2m, BookStore.Total(basket)); |
| 56 | + Assert.Equal(51.2m, BookStore.Total([1, 1, 2, 3, 4, 4, 5, 5])); |
67 | 57 | } |
68 | 58 |
|
69 | 59 | [Fact(Skip = "Remove this Skip property to run this test")] |
70 | 60 | public void Group_of_four_plus_group_of_two_is_cheaper_than_two_groups_of_three() |
71 | 61 | { |
72 | | - var basket = new[] { 1, 1, 2, 2, 3, 4 }; |
73 | | - Assert.Equal(40.8m, BookStore.Total(basket)); |
| 62 | + Assert.Equal(40.8m, BookStore.Total([1, 1, 2, 2, 3, 4])); |
74 | 63 | } |
75 | 64 |
|
76 | 65 | [Fact(Skip = "Remove this Skip property to run this test")] |
77 | 66 | public void Two_each_of_first_four_books_and_one_copy_each_of_rest() |
78 | 67 | { |
79 | | - var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5 }; |
80 | | - Assert.Equal(55.6m, BookStore.Total(basket)); |
| 68 | + Assert.Equal(55.6m, BookStore.Total([1, 1, 2, 2, 3, 3, 4, 4, 5])); |
81 | 69 | } |
82 | 70 |
|
83 | 71 | [Fact(Skip = "Remove this Skip property to run this test")] |
84 | 72 | public void Two_copies_of_each_book() |
85 | 73 | { |
86 | | - var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 }; |
87 | | - Assert.Equal(60m, BookStore.Total(basket)); |
| 74 | + Assert.Equal(60m, BookStore.Total([1, 1, 2, 2, 3, 3, 4, 4, 5, 5])); |
88 | 75 | } |
89 | 76 |
|
90 | 77 | [Fact(Skip = "Remove this Skip property to run this test")] |
91 | 78 | public void Three_copies_of_first_book_and_two_each_of_remaining() |
92 | 79 | { |
93 | | - var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1 }; |
94 | | - Assert.Equal(68m, BookStore.Total(basket)); |
| 80 | + Assert.Equal(68m, BookStore.Total([1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1])); |
95 | 81 | } |
96 | 82 |
|
97 | 83 | [Fact(Skip = "Remove this Skip property to run this test")] |
98 | 84 | public void Three_each_of_first_two_books_and_two_each_of_remaining_books() |
99 | 85 | { |
100 | | - var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2 }; |
101 | | - Assert.Equal(75.2m, BookStore.Total(basket)); |
| 86 | + Assert.Equal(75.2m, BookStore.Total([1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2])); |
102 | 87 | } |
103 | 88 |
|
104 | 89 | [Fact(Skip = "Remove this Skip property to run this test")] |
105 | 90 | public void Four_groups_of_four_are_cheaper_than_two_groups_each_of_five_and_three() |
106 | 91 | { |
107 | | - var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 5, 1, 1, 2, 2, 3, 3, 4, 5 }; |
108 | | - Assert.Equal(102.4m, BookStore.Total(basket)); |
| 92 | + Assert.Equal(102.4m, BookStore.Total([1, 1, 2, 2, 3, 3, 4, 5, 1, 1, 2, 2, 3, 3, 4, 5])); |
109 | 93 | } |
110 | 94 |
|
111 | 95 | [Fact(Skip = "Remove this Skip property to run this test")] |
112 | 96 | public void Check_that_groups_of_four_are_created_properly_even_when_there_are_more_groups_of_three_than_groups_of_five() |
113 | 97 | { |
114 | | - var basket = new[] { 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5 }; |
115 | | - Assert.Equal(145.6m, BookStore.Total(basket)); |
| 98 | + Assert.Equal(145.6m, BookStore.Total([1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5])); |
116 | 99 | } |
117 | 100 |
|
118 | 101 | [Fact(Skip = "Remove this Skip property to run this test")] |
119 | 102 | public void One_group_of_one_and_four_is_cheaper_than_one_group_of_two_and_three() |
120 | 103 | { |
121 | | - var basket = new[] { 1, 1, 2, 3, 4 }; |
122 | | - Assert.Equal(33.6m, BookStore.Total(basket)); |
| 104 | + Assert.Equal(33.6m, BookStore.Total([1, 1, 2, 3, 4])); |
123 | 105 | } |
124 | 106 |
|
125 | 107 | [Fact(Skip = "Remove this Skip property to run this test")] |
126 | 108 | public void One_group_of_one_and_two_plus_three_groups_of_four_is_cheaper_than_one_group_of_each_size() |
127 | 109 | { |
128 | | - var basket = new[] { 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5 }; |
129 | | - Assert.Equal(100m, BookStore.Total(basket)); |
| 110 | + Assert.Equal(100m, BookStore.Total([1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5])); |
130 | 111 | } |
131 | 112 | } |
0 commit comments