-
Notifications
You must be signed in to change notification settings - Fork 355
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
Step4 #1003
base: gongwho
Are you sure you want to change the base?
Step4 #1003
Changes from all commits
45ba384
097da6d
a5dd616
9a4122a
1b40de8
604d93d
3484985
c30e951
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package lotto.generator | ||
|
||
import lotto.domain.LottoTickets | ||
import lotto.generator.ticket.AutoTicketGenerator | ||
import lotto.generator.ticket.ManualTicketGenerator | ||
|
||
class ActualLottoShop( | ||
private val autoTicketGenerator: AutoTicketGenerator, | ||
private val manualTicketGenerator: ManualTicketGenerator, | ||
Comment on lines
+8
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AutoTicketGenerator, ManualTicketGenerator ActualLottoShop 관련해서 Fake객체를 주입시켜, 구체적인 테스트도 작성할수 있을거같아요 |
||
) : LottoShop { | ||
override fun provideAutoTickets(ticketCount: Int, preGeneratedTicketCount: Int): LottoTickets = autoTicketGenerator.create(ticketCount - preGeneratedTicketCount) | ||
override fun provideManualTickets(manualNumbersList: List<List<Int>>): LottoTickets = | ||
manualTicketGenerator.create(manualNumbersList) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package lotto.generator | ||
|
||
import lotto.domain.LottoTickets | ||
|
||
interface LottoShop { | ||
fun provideAutoTickets(ticketCount: Int, preGeneratedTicketCount: Int): LottoTickets | ||
fun provideManualTickets(manualNumbersList: List<List<Int>>): LottoTickets | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. List<List>가 어떤데이터인지 알기힘들진 않을까요? |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package lotto.generator.ticket | ||
|
||
import lotto.domain.LottoNumber | ||
import lotto.domain.LottoTicket | ||
import lotto.domain.LottoTickets | ||
|
||
object ManualTicketGenerator { | ||
fun create(manualNumbersList: List<List<Int>>): LottoTickets { | ||
return LottoTickets( | ||
manualNumbersList.map { list -> | ||
LottoTicket(list.map { LottoNumber(it) }) | ||
} | ||
) | ||
} | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,10 @@ | ||||||||||||||||||||||
package lotto.generator | ||||||||||||||||||||||
|
||||||||||||||||||||||
import lotto.domain.LottoTickets | ||||||||||||||||||||||
import lotto.generator.ticket.ManualTicketGenerator | ||||||||||||||||||||||
|
||||||||||||||||||||||
class MockLottoShop(private val manualTicketGenerator: ManualTicketGenerator) : LottoShop { | ||||||||||||||||||||||
override fun provideAutoTickets(ticketCount: Int, preGeneratedTicketCount: Int): LottoTickets = LottoTickets(listOf()) | ||||||||||||||||||||||
override fun provideManualTickets(manualNumbersList: List<List<Int>>): LottoTickets = | ||||||||||||||||||||||
manualTicketGenerator.create(manualNumbersList) | ||||||||||||||||||||||
Comment on lines
+6
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 해당 Mock객체는 정상적인 동작을 한다고 보기는 힘들지 않을까요? 추상화를 한 이유와 Fake객체를 사용하는 이유가 무엇일지 고민해보면 어떨까요?
Suggested change
|
||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package lotto.generator.ticket | ||
|
||
import io.kotest.core.spec.style.BehaviorSpec | ||
import io.kotest.matchers.shouldBe | ||
|
||
class AutoTicketGeneratorTest : BehaviorSpec({ | ||
given("auto ticket generator") { | ||
`when`("creates lotto Tickets") { | ||
then("should provide correct ticket count") { | ||
AutoTicketGenerator.create(3).lottoTicketList.size shouldBe 3 | ||
} | ||
} | ||
} | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package lotto.generator.ticket | ||
|
||
import io.kotest.core.spec.style.BehaviorSpec | ||
import io.kotest.matchers.shouldBe | ||
import lotto.domain.LottoNumber | ||
import lotto.domain.LottoTicket | ||
|
||
class ManualTicketGeneratorTest : BehaviorSpec({ | ||
given("manual ticket generator") { | ||
`when`("creates lotto Tickets") { | ||
then("should provide correct tickets") { | ||
val ticketBlueprint1 = listOf(1, 2, 3, 4, 5, 6) | ||
val ticketBlueprint2 = listOf(3, 4, 5, 6, 7, 8) | ||
val ticketBlueprint3 = listOf(5, 6, 7, 8, 9, 13) | ||
|
||
val lottoTickets = ManualTicketGenerator.create( | ||
listOf( | ||
ticketBlueprint1, | ||
ticketBlueprint2, | ||
ticketBlueprint3, | ||
) | ||
) | ||
lottoTickets.lottoTicketList.size shouldBe 3 | ||
lottoTickets.lottoTicketList[0] shouldBe LottoTicket(ticketBlueprint1.map { LottoNumber(it) }) | ||
lottoTickets.lottoTicketList[1] shouldBe LottoTicket(ticketBlueprint2.map { LottoNumber(it) }) | ||
lottoTickets.lottoTicketList[2] shouldBe LottoTicket(ticketBlueprint3.map { LottoNumber(it) }) | ||
gongwho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} | ||
}) |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
자동로또와 수동로또를 구매하는 역할도 LottoShop이 가지고 있어도 좋을거 같다는 생각이들어요!
단순히 provide해주는 객체가 아닌, manualNumbers와 budget 정보만으로 로또를 생성해줄수 있지않을까요?
LottoSimulator는 Controller역할로 View와의 상호작용에 대한 책임만 있지, 어떤 로또가 provide등의 책임은 LottoShop에게 모두 위임해보아요!