더북(TheBook)
enum class Item { carrot, milk }

interface CashierActions : DdtActions<DdtProtocol> {
    fun setupPrices(prices: Map<String, Double>)
    fun totalFor(actorName: String): Double
    fun addItem(actorName: String, qty: Int, item: Item)
}

class CashierDDT : DomainDrivenTest<CashierActions>(allActions) {
    val alice by NamedActor(::Customer)
 
    @DDT
    fun `customer can buy an item`() = ddtScenario {
        val prices = mapOf(carrot to 2.0, milk to 5.0)
        setUp {
            setupPrices(prices)
        }.thenPlay(
            alice.`can add #qty #item`(3, carrot),
            alice.`can add #qty #item`(1, milk),
            alice.`check total is #total`(11.0)
        )
}
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.