Value Object
(DDD)
Small object
Represents a concept
Equality based on value
Immutable:
• Should be created consistent
• Mutators should return new instances
Slide 4
Slide 4 text
So… How do you TDD a VO?
Slide 5
Slide 5 text
TDD VO Think of an invalid example
Write a test that fails expecting exception
Make the test pass
Repeat as needed to test invalid cases
Slide 6
Slide 6 text
TDD VO Think of a valid example
Write a test that fails asserting value
Make the test pass
Slide 7
Slide 7 text
TDD VO
Equality
Write a test that fails expecting inequality
Make the test pass
Then write a test that fails expecting
equality
Make the test pass
Slide 8
Slide 8 text
TDD VO
Immutability
Think of a valid example of a mutator
Write a test that fails expecting a different
instance
Make the test pass