ContractVersion Superclass: Object Instance variables: pay date
Using Time Travel, we can refactor the naïve test case [⇒ testNaivePayToday] into one that can remember changing pay rates [⇒ testPayToday ⇒ testPayLastMonth].
For now we can use simple Dates as the lookup key.
NavigationTest>>testPayToday | contract version | contract := Contract new. version := ContractVersion pay: 1000. contract versionAt: '2/1/99' asDate put: version. self assert: (contract versionAt: '2/1/99' asDate) pay = 1000
To make this test case run, first we create Contract (the History part of our Time Travel):
Contract Superclass: Object Instance variables: versions
Now we can define the ContractVersion (we omit the Constructor Method #pay:)
ContractVersion Superclass: Object Instance variables: pay date
With this in place, we can implement the two visible methods in Contract- #versionAt:put: and #versionAt:.