TDD, DDD and Encapsulation

后端 未结 8 1173
误落风尘
误落风尘 2021-02-01 05:19

After several years of following the bad practice handed down from \'architects\' at my place of work and thinking that there must be a better way, I\'ve recently been reading u

8条回答
  •  青春惊慌失措
    2021-02-01 05:29

    OK, this answer is one year too late ;-)

    But when you want to test CQRS models, you can make assertions on the fired domain events instead of assertions on entity state.

    e.g. if you want to test if calling : customer.Rename("Foo") results in the correct behavior.

    Instead of test if customer.Name equals "foo", you rather test if there is a pending CustomerRename event with the value "Foo" in your pending event store. (in your uow or in your entity event list depending on implementation)

提交回复
热议问题