diff --git a/domain/src/test/java/com/malibin/study/domain/lotto/LottoNumberTest.kt b/domain/src/test/java/com/malibin/study/domain/lotto/LottoNumberTest.kt new file mode 100644 index 0000000..9fb8179 --- /dev/null +++ b/domain/src/test/java/com/malibin/study/domain/lotto/LottoNumberTest.kt @@ -0,0 +1,46 @@ +package com.malibin.study.domain.lotto + +import com.google.common.truth.Truth +import org.junit.jupiter.api.Test + +internal class LottoNumberTest { + @Test + fun `입력 숫자는 1보다 작을 수 없다`() { + // given + val number = 0 + + // when + val exception = kotlin.runCatching { + LottoNumber.of(number) + }.exceptionOrNull() + + // then + Truth.assertThat(exception).isInstanceOf(IllegalArgumentException::class.java) + } + + @Test + fun `입력 숫자는 45보다 클 수 없다`() { + // given + val number = 46 + + // when + val exception = kotlin.runCatching { + LottoNumber.of(number) + }.exceptionOrNull() + + // then + Truth.assertThat(exception).isInstanceOf(IllegalArgumentException::class.java) + } + + @Test + fun `입력 숫자는 1 이상 45 이하의 범위여야 한다`() { + // given + val number = 10 + + // when + val actualNumber = LottoNumber.of(number) + + // then + Truth.assertThat(actualNumber.number).isEqualTo(number) + } +} diff --git a/domain/src/test/java/com/malibin/study/domain/lotto/result/MoneyTest.kt b/domain/src/test/java/com/malibin/study/domain/lotto/result/MoneyTest.kt new file mode 100644 index 0000000..f18a481 --- /dev/null +++ b/domain/src/test/java/com/malibin/study/domain/lotto/result/MoneyTest.kt @@ -0,0 +1,48 @@ +package com.malibin.study.domain.lotto.result + +import com.google.common.truth.Truth +import org.junit.jupiter.api.Test + +internal class MoneyTest { + @Test + fun `돈의 액수는 음수가 될 수 없다`() { + // given + val money = Money(-1) + + // when + val exception = kotlin.runCatching { + money + }.exceptionOrNull() + + // then + Truth.assertThat(exception).isInstanceOf(IllegalArgumentException::class.java) + } + + @Test + fun `돈을 더할 수 있다`() { + // given + val money1 = Money(1000) + val money2 = Money(2000) + val plusResult = money1 + money2 + + // when + val actualPlusResult = money1.plus(money2) + + // then + Truth.assertThat(actualPlusResult).isEqualTo(plusResult) + } + + @Test + fun `돈을 뺄 수 있다`() { + // given + val money1 = Money(1000) + val money2 = Money(2000) + val minusResult = money2 - money1 + + // when + val actualMinusResult = money2.minus(money1) + + // then + Truth.assertThat(actualMinusResult).isEqualTo(minusResult) + } +}