Skip to content

Commit 9961870

Browse files
committed
feat(tiered_pricing): 🔴 test for non positive values
1 parent 239c953 commit 9961870

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

exercises/tiered_pricing/solutions/oflorez/src/test/java/tv/codely/checkout/TieredPricingShould.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.stream.IntStream;
66

77
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
import static org.junit.jupiter.api.Assertions.assertThrows;
89

910
public class TieredPricingShould {
1011

@@ -48,6 +49,13 @@ void calculate_total_value_for_fifth_pricing_tier() {
4849
assertEquals(calculateTotalPriceExpected(tier.getUnitPrice(), subscription), pricing.calculateTotalPrice(subscription));
4950
}
5051

52+
@Test
53+
void throws_illegal_argument_when_subscription_be_non_positive_value() {
54+
var pricing = new TieredPricing();
55+
var subscription = IntStream.rangeClosed(-100000, 0).findAny().getAsInt();
56+
assertThrows(IllegalArgumentException.class, () -> pricing.calculateTotalPrice(subscription));
57+
}
58+
5159
private int retrieveSubscriptionGivenTier(Tier tier) {
5260
return IntStream.rangeClosed(tier.getLowerLimit(), tier.getUpperLimit()).findAny().getAsInt();
5361
}

0 commit comments

Comments
 (0)