Skip to content

Instantly share code, notes, and snippets.

@erikrozendaal
Created February 9, 2011 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikrozendaal/819082 to your computer and use it in GitHub Desktop.
Save erikrozendaal/819082 to your computer and use it in GitHub Desktop.
Code for immutable domain blog part 5
"draft invoice" should {
val invoice: DraftInvoice = Invoice.loadFromHistory(Seq(InvoiceCreated(1)))
"support adding invoice items" in {
val updated = invoice.addItem("Food", "2.95") flatMap (_.addItem("Water", "1.95")) flatMap (_.removeItem(1))
updated.changes must contain(InvoiceItemAdded(1, InvoiceItem(1, "Food", "2.95"), "2.95"))
updated.changes must contain(InvoiceItemAdded(1, InvoiceItem(2, "Water", "1.95"), "4.90"))
updated.changes must contain(InvoiceItemRemoved(1, InvoiceItem(1, "Food", "2.95"), "1.95"))
}
"not be ready to send" in {
invoice.send.rejected must beEqualTo("recipient and items must be specified before sending")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment