Created
February 9, 2011 19:26
-
-
Save erikrozendaal/819082 to your computer and use it in GitHub Desktop.
Code for immutable domain blog part 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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