Slide 17
Slide 17 text
Comparing test code for the Domain Object
17
val sut: Task = Task.create(
…, Subject("Test"), …
)
val actualChecked =
sut.canEditSubject
assert(actualChecked)
// Can not test domain logic
// and event creation in this test.
val actualEntity =
sut.editSubject(Subject("Edited"))
assert(actualEntity ==
Task(…, Subject("Edited"), …)
)
val sut: Task = Task.applyEvent(
Task.create(
…, Subject("Test"), …
)
)
val actualEvent =
sut.editSubject(Subject("Edited"))
assert(actualEvent ==
Right(SubjectEdited(Subject("Edited")))
)
val actualEntity =
sut.applyEvent(actualEvent)
assert(actualEntity ==
Task(…, Subject("Edited"), …)
)
val sut: Task = Task.create(
…, Subject("Test"), …
)
.entity
val actual =
sut.editSubject(Subject("Edited"))
assert(actual.event ==
SubjectEdited(Subject("Edited"))
)
assert(actual.entity ==
Task( …, Subject("Edited"), …)
)
To create test target,
needs create and
apply an EVENT…🤔
Create test target
easily!!👍
Style A Style B Style C