Skip to content

Instantly share code, notes, and snippets.

@justinhj
Last active December 2, 2019 05:13
Show Gist options
  • Save justinhj/f1f6739fd86833b629d62d08ae36ecb5 to your computer and use it in GitHub Desktop.
Save justinhj/f1f6739fd86833b629d62d08ae36ecb5 to your computer and use it in GitHub Desktop.
"handle deposit and successful withdrawal" in withTestDriver
{ driver =>
val t1 = Instant.now
val t2 = t1.plusSeconds(100)
val outcome = driver.run(DepositCmd(t1, "Opening deposit", 100))
outcome.replies should contain only 100
val outcome2 = driver.run(WithdrawCmd(t2, "Transfer to savings", 20))
outcome2.replies should contain only SuccessfulWithdrawalResponse(80)
outcome2.issues should be(Nil)
outcome2.state should ===(AccountState(80))
outcome2.events should ===(Vector(WithdrawEvt(t2, "Transfer to savings", 20)))
}
"handle deposit and failed withdrawal" in withTestDriver
{ driver =>
val outcome = driver.run(DepositCmd(Instant.now, "Opening deposit", 100))
outcome.replies should contain only 100
val outcome2 = driver.run(WithdrawCmd(Instant.now, "Transfer to savings", 200))
outcome2.replies should contain only FailedWithdrawalResponse("Insufficient funds (current balance 100)")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment