File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
exercises/tiered_pricing/solutions/mperezi/src
main/java/tv/codely/checkout
test/java/tv/codely/checkout Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,8 @@ public class TieredPricing {
77 private enum Tier {
88 FIRST (299.0 , 1 , 2 ),
99 SECOND (239.0 , 3 , 10 ),
10- THIRD (219.0 , 11 , 25 );
10+ THIRD (219.0 , 11 , 25 ),
11+ FOURTH (199.0 , 26 , 50 );
1112
1213 final double unitPrice ;
1314 final int startRange ;
Original file line number Diff line number Diff line change @@ -42,6 +42,14 @@ void returnTotalPriceForThirdTier(int subscriptions) {
4242 assertThat (totalPrice ).isEqualTo (subscriptions * 219.0 );
4343 }
4444
45+ @ ParameterizedTest
46+ @ MethodSource ("rangeFourthTier" )
47+ void returnTotalPriceForFourthTier (int subscriptions ) {
48+ double totalPrice = tieredPricing .totalPrice (subscriptions );
49+
50+ assertThat (totalPrice ).isEqualTo (subscriptions * 199.0 );
51+ }
52+
4553 private static Stream <Integer > rangeFirstTier () {
4654 return IntStream .rangeClosed (1 , 2 ).boxed ();
4755 }
@@ -53,4 +61,8 @@ private static Stream<Integer> rangeSecondTier() {
5361 private static Stream <Integer > rangeThirdTier () {
5462 return IntStream .rangeClosed (11 , 25 ).boxed ();
5563 }
64+
65+ private static Stream <Integer > rangeFourthTier () {
66+ return IntStream .rangeClosed (26 , 50 ).boxed ();
67+ }
5668}
You can’t perform that action at this time.
0 commit comments