|
| 1 | +package com.baeldung.enums |
| 2 | + |
| 3 | +import org.junit.jupiter.api.Assertions.assertEquals |
| 4 | +import org.junit.jupiter.api.Test |
| 5 | + |
| 6 | +internal class CardTypeUnitTest { |
| 7 | + |
| 8 | + @Test |
| 9 | + fun givenSilverCardType_whenCalculateCashbackPercent_thenReturnCashbackValue() { |
| 10 | + assertEquals(0.25f, CardType.SILVER.calculateCashbackPercent()) |
| 11 | + } |
| 12 | + |
| 13 | + @Test |
| 14 | + fun givenGoldCardType_whenCalculateCashbackPercent_thenReturnCashbackValue() { |
| 15 | + assertEquals(0.5f, CardType.GOLD.calculateCashbackPercent()) |
| 16 | + } |
| 17 | + |
| 18 | + @Test |
| 19 | + fun givenPlatinumCardType_whenCalculateCashbackPercent_thenReturnCashbackValue() { |
| 20 | + assertEquals(0.75f, CardType.PLATINUM.calculateCashbackPercent()) |
| 21 | + } |
| 22 | + |
| 23 | + @Test |
| 24 | + fun givenSilverCardType_whenGetCreditLimit_thenReturnCreditLimit() { |
| 25 | + assertEquals(100000, CardType.SILVER.getCreditLimit()) |
| 26 | + } |
| 27 | + |
| 28 | + @Test |
| 29 | + fun givenGoldCardType_whenGetCreditLimit_thenReturnCreditLimit() { |
| 30 | + assertEquals(200000, CardType.GOLD.getCreditLimit()) |
| 31 | + } |
| 32 | + |
| 33 | + @Test |
| 34 | + fun givenPlatinumCardType_whenGetCreditLimit_thenReturnCreditLimit() { |
| 35 | + assertEquals(300000, CardType.PLATINUM.getCreditLimit()) |
| 36 | + } |
| 37 | + |
| 38 | + @Test |
| 39 | + fun givenSilverCardType_whenCheckColor_thenReturnColor() { |
| 40 | + assertEquals("gray", CardType.SILVER.color) |
| 41 | + } |
| 42 | + |
| 43 | + @Test |
| 44 | + fun givenGoldCardType_whenCheckColor_thenReturnColor() { |
| 45 | + assertEquals("yellow", CardType.GOLD.color) |
| 46 | + } |
| 47 | + |
| 48 | + @Test |
| 49 | + fun givenPlatinumCardType_whenCheckColor_thenReturnColor() { |
| 50 | + assertEquals("black", CardType.PLATINUM.color) |
| 51 | + } |
| 52 | +} |
0 commit comments