Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step1 하는중입니다! 풀리퀘 날려지나 확인차 올렸습니다 :) #13

Open
wants to merge 8 commits into
base: 2zerozu
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -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)
}
}