Skip to content

Instantly share code, notes, and snippets.

@emag
Last active December 8, 2024 14:51
Show Gist options
  • Save emag/f31d8b9a10c1e068ffed33c2fdc9f16f to your computer and use it in GitHub Desktop.
Save emag/f31d8b9a10c1e068ffed33c2fdc9f16f to your computer and use it in GitHub Desktop.
サービスのテスト
import cats.Id
"初期化" should {
"コマンドを受け付ける" in {
// Given
val initA = Map(Cash -> BigDecimal(1_000_000))
val initL = Map(AccruedLiability -> BigDecimal(100_000))
val initializeScenario = RequestContext(
command = CommandMessage(
id = "some-id",
time = ZonedDateTime.now().toInstant,
address = "an-address-id",
payload = BsCommand.Initialize(initA, initL)
),
state = BalanceSheet.NotReady
)
// When
val result: EdomatonResult[
BalanceSheet,
BsEvent,
BsRejection,
BsNotification
] = BalanceSheetService[Id].execute(initializeScenario)
// Then
result shouldBe Accepted(
newState = BalanceSheet.Ready(initA, initL),
events = NonEmptyChain(BsEvent.Initialized(initA, initL)),
notifications = Chain(
BsNotification.BalanceSheetPrepared(
"an-address-id",
BalanceSheet.Ready(initA, initL)
)
)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment