-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/test/java/com/programmers/vouchermanagement/voucher/domain/DiscountTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.programmers.vouchermanagement.voucher.domain; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
class DiscountTypeTest { | ||
|
||
@Nested | ||
@DisplayName("할인 유형에 적합한 DiscountType 을 반환한다.") | ||
class returnAppropriateDiscountType { | ||
|
||
@Test | ||
@DisplayName("fix 가 들어온 경우") | ||
void WhenFixComeInto() { | ||
// when | ||
String name = "fix"; | ||
|
||
// given | ||
DiscountType result = DiscountType.from(name); | ||
|
||
// then | ||
assertThat(result).isEqualTo(DiscountType.FIX); | ||
} | ||
|
||
@Test | ||
@DisplayName("percent 가 들어온 경우") | ||
void WhenPercentComeInto() { | ||
// when | ||
String name = "percent"; | ||
|
||
// given | ||
DiscountType result = DiscountType.from(name); | ||
|
||
// then | ||
assertThat(result).isEqualTo(DiscountType.PERCENT); | ||
} | ||
} | ||
|
||
@Test | ||
@DisplayName("존재하지 않는 할인 유형이 들어오면 에외가 발생한다.") | ||
void occurExceptionWhenDiscountTypeDoesNotExist() { | ||
// when | ||
String name = "fixx"; | ||
|
||
// given & then | ||
assertThatThrownBy(() -> { | ||
DiscountType.from(name); | ||
}) | ||
.isInstanceOf(IllegalArgumentException.class) | ||
.hasMessage("This discount type does not exist."); | ||
} | ||
} |